mirror of
https://github.com/libretro/RetroArch
synced 2025-04-10 15:45:19 +00:00
Merge pull request #3770 from t-paul/xdg-screensaver-fix
Fix handling of enable flag for xdg-screensaver.
This commit is contained in:
commit
6865689dad
@ -41,7 +41,6 @@ static unsigned int dbus_screensaver_cookie = 0;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static bool xdg_screensaver_available = true;
|
static bool xdg_screensaver_available = true;
|
||||||
static bool xdg_screensaver_running = false;
|
|
||||||
|
|
||||||
Colormap g_x11_cmap;
|
Colormap g_x11_cmap;
|
||||||
Window g_x11_win;
|
Window g_x11_win;
|
||||||
@ -290,9 +289,6 @@ static void xdg_screensaver_inhibit(Window wnd)
|
|||||||
if (!xdg_screensaver_available)
|
if (!xdg_screensaver_available)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (xdg_screensaver_running)
|
|
||||||
return;
|
|
||||||
|
|
||||||
RARCH_LOG("Suspending screensaver (X11, xdg-screensaver).\n");
|
RARCH_LOG("Suspending screensaver (X11, xdg-screensaver).\n");
|
||||||
|
|
||||||
snprintf(cmd, sizeof(cmd), "xdg-screensaver suspend 0x%x", (int)wnd);
|
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;
|
xdg_screensaver_available = false;
|
||||||
RARCH_WARN("Could not suspend screen saver.\n");
|
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)
|
void x11_suspend_screensaver_xdg_screensaver(Window wnd, bool enable)
|
||||||
{
|
{
|
||||||
if (enable)
|
// Check if screensaver suspend is enabled in config
|
||||||
xdg_screensaver_inhibit(wnd);
|
if (!enable)
|
||||||
xdg_screensaver_uninhibit(wnd);
|
return;
|
||||||
|
|
||||||
|
xdg_screensaver_inhibit(wnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void x11_suspend_screensaver(Window wnd, bool enable)
|
void x11_suspend_screensaver(Window wnd, bool enable)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user