diff options
Diffstat (limited to 'plugins/dfinput/xkb.c')
| -rwxr-xr-x | plugins/dfinput/xkb.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/plugins/dfinput/xkb.c b/plugins/dfinput/xkb.c index ed13c7c4..53fb90d4 100755 --- a/plugins/dfinput/xkb.c +++ b/plugins/dfinput/xkb.c @@ -23,6 +23,7 @@ static Atom wmprotocols, wmdelwindow; static int g_currentMouse_X; static int g_currentMouse_Y; static Window window; +static uint8_t resumeScrSaver = 0; void InitKeyboard() { int revert_to; @@ -30,6 +31,7 @@ void InitKeyboard() { wmprotocols = XInternAtom(g.Disp, "WM_PROTOCOLS", 0); wmdelwindow = XInternAtom(g.Disp, "WM_DELETE_WINDOW", 0); + // Hide cursor and lock cursor to window if type is mouse XkbSetDetectableAutoRepeat(g.Disp, 1, NULL); XGetInputFocus(g.Disp, &window, &revert_to); if (g.cfg.PadDef[0].Type == PSE_PAD_TYPE_MOUSE || @@ -40,6 +42,20 @@ void InitKeyboard() { showCursor(g.Disp, window, 0); } + // Disable screensaver - this could be in different place + resumeScrSaver = 0; + if (g.cfg.PreventScrSaver) { + char buf[64]; + snprintf(buf, 64, "xdg-screensaver suspend 0x%x > /dev/null 2>&1", window); + if (pclose(popen(buf, "r")) == 0) { + resumeScrSaver = 1; + printf("Suspending Window ID 0x%x of activating screensaver.\n", window); + } else { + //resumeScrSaver = 0; + fprintf(stderr, "Failed to execute xdg-screensaver (maybe not installed?)\n"); + } + } + g_currentMouse_X = 0; g_currentMouse_Y = 0; @@ -50,6 +66,7 @@ void InitKeyboard() { void DestroyKeyboard() { XkbSetDetectableAutoRepeat(g.Disp, 0, NULL); + // Enable cursor and revert grab cursor if mouse if (g.cfg.PadDef[0].Type == PSE_PAD_TYPE_MOUSE || g.cfg.PadDef[1].Type == PSE_PAD_TYPE_MOUSE) { grabCursor(g.Disp, window, 0); @@ -57,6 +74,15 @@ void DestroyKeyboard() { } else if (g.cfg.HideCursor) { showCursor(g.Disp, window, 1); } + + // Enable screensaver if it was disabled - this could be in different place + if (resumeScrSaver) { + char buf[64]; + printf("Resuming Window ID 0x%x to activate screensaver.\n", window); + snprintf(buf, 64, "xdg-screensaver resume 0x%x", window); + FILE *phandle = popen(buf, "r"); + pclose(phandle); + } } static void bdown(int pad, int bit) |
