Hi, To my knowledge, the main use of godot,-main is running Godot apps (games). I've been doing that a bit, but ran into the issue that with gamepad-controlled games, the X server puts the display to sleep after a while because of the timeout on keyboard/mouse input.
I looked at what sdl2 does, as the biggest framework in the ecosystem. Found out that sdl2 just disables the screensaver by default [1-2]. Looking through Godot, there is nothing to suspend/disable the X11 sceen saver in the code. There has been some work on a setting by the name of 'keep_screen_on' which seems to exist on Linux using some probably overengineered DBus-way of stopping the screen saver [3]. A review of pertinent issues over time shows this is not implemented on some platforms. I tried to build a diff based on the keep_screen_on code, but that didn't work to disable the screen saver. This diff below is a much simpler approach that just calls XScreenSaverSuspend() during the init. It is set up so that a flag '-DSUSPEND_SCREENSAVER' enables this, and the diff below is set up such that this only happens for the godot binary without tools, so that anyone using the editor still has working X11 screen saving. Some reworking based on input from op@ is included here, but wanted to share this more broadly. sharpyuv was also missing from WANTLIB when I ran `make port-lib-depends-check`, so I added this. ok? [1] https://wiki.libsdl.org/SDL2/SDL_HINT_VIDEO_ALLOW_SCREENSAVER [2] https://github.com/libsdl-org/SDL/blob/71099149b8fc062ea0ece232ccdd9f0ee9b3588b/src/video/x11/SDL_x11events.c#L1856 [3] https://github.com/godotengine/godot/issues/5073 Index: Makefile =================================================================== RCS file: /cvs/ports/games/godot/Makefile,v retrieving revision 1.45 diff -u -p -r1.45 Makefile --- Makefile 30 Jul 2023 19:57:20 -0000 1.45 +++ Makefile 31 Jul 2023 23:02:47 -0000 @@ -7,7 +7,7 @@ V = 3.5.2 GODOTSTEAM_V = g352-s157-gs3193 DISTNAME = godot-${V}-stable PKGNAME = godot-${V} -REVISION = 1 +REVISION = 2 CATEGORIES = games @@ -24,11 +24,12 @@ WANTLIB += ${COMPILER_LIBCXX} BulletColl WANTLIB += GL LinearMath X11 X11-xcb Xau Xcursor Xdmcp Xext Xfixes WANTLIB += Xi Xinerama Xrandr Xrender Xxf86vm c drm enet execinfo WANTLIB += intl m mbedcrypto mbedtls mbedx509 mpcdec ogg opus -WANTLIB += opusfile pcre2-32 sndio steam_api theora theoradec +WANTLIB += opusfile pcre2-32 sharpyuv sndio steam_api theora theoradec WANTLIB += usbhid vorbis vorbisfile vpx webp xcb xcb-dri2 xcb-glx WANTLIB += zstd -WANTLIB-tools = ${WANTLIB} +WANTLIB-main = ${WANTLIB} Xss +WANTLIB-tools = ${WANTLIB} # C++14 COMPILER = base-clang ports-gcc @@ -46,9 +47,7 @@ MODULES = devel/scons # sharedlib_ext in modules/mono/config.py to '.so.1.0' MODSCONS_FLAGS = CC="${CC}" \ CXX="${CXX}" \ - CFLAGS="${CFLAGS}" \ CXXFLAGS="${CXXFLAGS} -Wno-deprecated-register" \ - LINKFLAGS="${LDFLAGS} -lintl -lmpcdec -lusbhid" \ builtin_bullet=no \ builtin_enet=no \ builtin_glew=no \ @@ -129,8 +128,12 @@ pre-configure: ${SUBST_CMD} ${WRKSRC}/misc/dist/linux/*.desktop do-build: - @${MODSCONS_BUILD_TARGET} tools=no target=release - @${MODSCONS_BUILD_TARGET} tools=yes target=release_debug + @${MODSCONS_BUILD_TARGET} tools=no target=release \ + CFLAGS="${CFLAGS} -DSUSPEND_SCREENSAVER=1" \ + LINKFLAGS="${LDFLAGS} -lintl -lmpcdec -lusbhid -lXss" + @${MODSCONS_BUILD_TARGET} tools=yes target=release_debug \ + CFLAGS="${CFLAGS}" \ + LINKFLAGS="${LDFLAGS} -lintl -lmpcdec -lusbhid" do-install: ${INSTALL_PROGRAM} ${WRKBUILD}/bin/godot.x11.opt.${BINSUFFIX} \ Index: patches/patch-platform_x11_os_x11_cpp =================================================================== RCS file: /cvs/ports/games/godot/patches/patch-platform_x11_os_x11_cpp,v retrieving revision 1.12 diff -u -p -r1.12 patch-platform_x11_os_x11_cpp --- patches/patch-platform_x11_os_x11_cpp 11 Aug 2022 19:40:59 -0000 1.12 +++ patches/patch-platform_x11_os_x11_cpp 31 Jul 2023 23:02:47 -0000 @@ -1,10 +1,22 @@ fix libXrandr library name and load sndio use OpenBSD joypad class +suspend X11 screensaver for release builds Index: platform/x11/os_x11.cpp --- platform/x11/os_x11.cpp.orig +++ platform/x11/os_x11.cpp -@@ -173,7 +173,7 @@ Error OS_X11::initialize(const VideoMode &p_desired, i +@@ -55,6 +55,10 @@ + #include <X11/extensions/Xinerama.h> + #include <X11/extensions/shape.h> + ++#ifdef SUSPEND_SCREENSAVER ++#include <X11/extensions/scrnsaver.h> ++#endif ++ + // ICCCM + #define WM_NormalState 1L // window normal state + #define WM_IconicState 3L // window minimized +@@ -173,7 +177,7 @@ Error OS_X11::initialize(const VideoMode &p_desired, i int xrandr_minor = 0; int event_base, error_base; xrandr_ext_ok = XRRQueryExtension(x11_display, &event_base, &error_base); @@ -13,7 +25,7 @@ Index: platform/x11/os_x11.cpp if (!xrandr_handle) { err = dlerror(); // For some arcane reason, NetBSD now ships libXrandr.so.3 while the rest of the world has libXrandr.so.2... -@@ -610,7 +610,7 @@ Error OS_X11::initialize(const VideoMode &p_desired, i +@@ -610,9 +614,13 @@ Error OS_X11::initialize(const VideoMode &p_desired, i window_has_focus = true; // Set focus to true at init #ifdef JOYDEV_ENABLED @@ -21,8 +33,14 @@ Index: platform/x11/os_x11.cpp + joypad = memnew(JoypadOpenBSD(input)); #endif ++#ifdef SUSPEND_SCREENSAVER ++ XScreenSaverSuspend(x11_display, true); ++#endif ++ power_manager = memnew(PowerX11); -@@ -4414,6 +4414,11 @@ void OS_X11::update_real_mouse_position() { + + if (p_desired.layered) { +@@ -4414,6 +4422,11 @@ void OS_X11::update_real_mouse_position() { } OS_X11::OS_X11() {
