On Mon, Jul 31, 2023 at 07:04:15PM -0400, Thomas Frohwein wrote:
> 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
I made a mistake with the original diff - the -D flag needs to be in
CXXFLAGS, not CFLAGS, otherwise the XScreenSaverSuspend call isn't
compiled in.
Updated diff that I tested and that works as intended here - ok?
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 1 Aug 2023 06:45:57 -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
@@ -47,8 +48,6 @@ MODULES = devel/scons
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 \
+ CXXFLAGS="${CXXFLAGS} -Wno-deprecated-register -DSUSPEND_SCREENSAVER=1" \
+ LINKFLAGS="${LDFLAGS} -lintl -lmpcdec -lusbhid -lXss"
+ @${MODSCONS_BUILD_TARGET} tools=yes target=release_debug \
+ CXXFLAGS="${CXXFLAGS} -Wno-deprecated-register" \
+ 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 1 Aug 2023 06:45:57 -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>
++
No comments:
Post a Comment