diff options
Diffstat (limited to 'openbox/grab.c')
| -rw-r--r-- | openbox/grab.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/openbox/grab.c b/openbox/grab.c index 3bba14b3..c6beee74 100644 --- a/openbox/grab.c +++ b/openbox/grab.c @@ -2,7 +2,7 @@ #include <glib.h> #include <X11/Xlib.h> -static guint kgrabs, pgrabs; +static guint kgrabs, pgrabs, sgrabs; void grab_keyboard(gboolean grab) { @@ -28,13 +28,29 @@ void grab_pointer(gboolean grab, Cursor cur) } } +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); } |
