From d4a90f267df88316de32d65e66c17bfd25c221eb Mon Sep 17 00:00:00 2001 From: Torsten Paul Date: Mon, 10 Oct 2016 19:01:41 +0200 Subject: [PATCH] Fix handling of enable flag for xdg-screensaver. --- gfx/common/x11_common.c | 45 +++++------------------------------------ 1 file changed, 5 insertions(+), 40 deletions(-) diff --git a/gfx/common/x11_common.c b/gfx/common/x11_common.c index 41bc6ac077..b5b8080312 100644 --- a/gfx/common/x11_common.c +++ b/gfx/common/x11_common.c @@ -41,7 +41,6 @@ static unsigned int dbus_screensaver_cookie = 0; #endif static bool xdg_screensaver_available = true; -static bool xdg_screensaver_running = false; Colormap g_x11_cmap; Window g_x11_win; @@ -290,9 +289,6 @@ static void xdg_screensaver_inhibit(Window wnd) if (!xdg_screensaver_available) return; - if (xdg_screensaver_running) - return; - RARCH_LOG("Suspending screensaver (X11, xdg-screensaver).\n"); snprintf(cmd, sizeof(cmd), "xdg-screensaver suspend 0x%x", (int)wnd); @@ -308,46 +304,15 @@ static void xdg_screensaver_inhibit(Window wnd) xdg_screensaver_available = false; RARCH_WARN("Could not suspend screen saver.\n"); } - else - { - xdg_screensaver_running = true; - } -} - -static void xdg_screensaver_uninhibit(Window wnd) -{ - int ret; - char cmd[64] = {0}; - - if (!xdg_screensaver_available) - return; - - if (!xdg_screensaver_running) - return; - - RARCH_LOG("Resuming screensaver (X11, xdg-screensaver).\n"); - - snprintf(cmd, sizeof(cmd), "xdg-screensaver resume 0x%x", (int)wnd); - - ret = system(cmd); - - if (ret == -1) - { - xdg_screensaver_available = false; - RARCH_WARN("Failed to launch xdg-screensaver.\n"); - } - else if (WEXITSTATUS(ret)) - { - xdg_screensaver_available = false; - RARCH_WARN("Could not suspend screen saver.\n"); - } } void x11_suspend_screensaver_xdg_screensaver(Window wnd, bool enable) { - if (enable) - xdg_screensaver_inhibit(wnd); - xdg_screensaver_uninhibit(wnd); + // Check if screensaver suspend is enabled in config + if (!enable) + return; + + xdg_screensaver_inhibit(wnd); } void x11_suspend_screensaver(Window wnd, bool enable)