X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;ds=sidebyside;f=openbox%2Fgrab.c;h=63127117f985a8535d165429db552f44e84803c9;hb=e4fe6da48c7ddb14639ab91f8532e89b16e72deb;hp=3bba14b3a434ca30edb3c6051cd456a571004e2e;hpb=598c5d6c07118517b47d7c416a79dc9743271aa8;p=chaz%2Fopenbox diff --git a/openbox/grab.c b/openbox/grab.c index 3bba14b3..63127117 100644 --- a/openbox/grab.c +++ b/openbox/grab.c @@ -2,7 +2,7 @@ #include #include -static guint kgrabs, pgrabs; +static guint kgrabs, pgrabs, sgrabs; void grab_keyboard(gboolean grab) { @@ -21,20 +21,36 @@ void grab_pointer(gboolean grab, Cursor cur) if (grab) { if (pgrabs++ == 0) XGrabPointer(ob_display, ob_root, False, 0, GrabModeAsync, - GrabModeSync, FALSE, cur, CurrentTime); + GrabModeAsync, FALSE, cur, CurrentTime); } else if (pgrabs > 0) { if (--pgrabs == 0) XUngrabPointer(ob_display, CurrentTime); } } +void grab_server(gboolean grab) +{ + if (grab) { + if (sgrabs++ == 0) { + XGrabServer(ob_display); + XSync(ob_display, FALSE); + } + } else if (sgrabs > 0) { + if (--sgrabs == 0) { + XUngrabServer(ob_display); + XFlush(ob_display); + } + } +} + void grab_startup() { - kgrabs = pgrabs = 0; + kgrabs = pgrabs = sgrabs = 0; } void grab_shutdown() { while (kgrabs) grab_keyboard(FALSE); while (pgrabs) grab_pointer(FALSE, None); + while (sgrabs) grab_server(FALSE); }