summaryrefslogtreecommitdiff
path: root/plugins/dfinput/xkb.c
diff options
context:
space:
mode:
authorSND\ckain_cp <SND\ckain_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2013-07-26 09:59:05 +0000
committerSND\ckain_cp <SND\ckain_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2013-07-26 09:59:05 +0000
commit13e08db872f4775ca23df12fcc03f1916ed9691e (patch)
treec66601f85caab2ad0f7b78f3d4973d1fa9b1ae81 /plugins/dfinput/xkb.c
parent6131285e0c96333cf10b7257441e54caae661cdf (diff)
downloadpcsxr-13e08db872f4775ca23df12fcc03f1916ed9691e.tar.gz
GTK/dfinput: added "prevent screensaver" feature. Makes ugly call to xdg-screensaver script which seems to be only sopisticated way of handling multiple screensaver backends.
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@86254 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'plugins/dfinput/xkb.c')
-rwxr-xr-xplugins/dfinput/xkb.c26
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)