From ee8c883201c2d59667321d581a1a6db7b1fc6a1d Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Wed, 20 Jan 2021 15:24:10 +1100 Subject: [PATCH] [client] x11: implement screensaver (un)inhibit --- client/displayservers/X11/CMakeLists.txt | 1 + client/displayservers/X11/x11.c | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/client/displayservers/X11/CMakeLists.txt b/client/displayservers/X11/CMakeLists.txt index bbebecb3..49eb9d36 100644 --- a/client/displayservers/X11/CMakeLists.txt +++ b/client/displayservers/X11/CMakeLists.txt @@ -5,6 +5,7 @@ find_package(PkgConfig) pkg_check_modules(DISPLAYSERVER_X11_PKGCONFIG REQUIRED x11 xfixes + xscrnsaver ) pkg_check_modules(DISPLAYSERVER_X11_OPT_PKGCONFIG diff --git a/client/displayservers/X11/x11.c b/client/displayservers/X11/x11.c index 0a1dcee0..ea166a97 100644 --- a/client/displayservers/X11/x11.c +++ b/client/displayservers/X11/x11.c @@ -27,6 +27,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA #include #include +#include #include #include "app.h" @@ -669,6 +670,16 @@ static void x11WarpPointer(int x, int y, bool exiting) XSync(x11.display, False); } +static void x11InhibitIdle(void) +{ + XScreenSaverSuspend(x11.display, true); +} + +static void x11UninhibitIdle(void) +{ + XScreenSaverSuspend(x11.display, false); +} + static bool x11CBInit() { x11.aSelection = XInternAtom(x11.display, "CLIPBOARD" , False); @@ -1011,9 +1022,8 @@ struct LG_DisplayServerOps LGDS_X11 = .ungrabKeyboard = x11UngrabKeyboard, .warpPointer = x11WarpPointer, - /* Use SDL implementation for now */ - .inhibitIdle = NULL, - .uninhibitIdle = NULL, + .inhibitIdle = x11InhibitIdle, + .uninhibitIdle = x11UninhibitIdle, .cbInit = x11CBInit, .cbNotice = x11CBNotice,