From: Dana Jansens Date: Tue, 18 Mar 2003 20:00:44 +0000 (+0000) Subject: add 'grab_server' for grabbing .. the .. server! X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=7d215bd255d0744101b9ceb52c235bdc985fa034;p=chaz%2Fopenbox add 'grab_server' for grabbing .. the .. server! --- diff --git a/openbox/client.c b/openbox/client.c index c8d33e83..790dba5a 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -5,6 +5,7 @@ #include "frame.h" #include "engine.h" #include "event.h" +#include "grab.h" #include "focus.h" #include "stacking.h" #include "dispatch.h" @@ -120,9 +121,8 @@ void client_manage(Window window) XWindowAttributes attrib; XSetWindowAttributes attrib_set; /* XWMHints *wmhint; */ - - XGrabServer(ob_display); - XSync(ob_display, FALSE); + + grab_server(TRUE); /* check if it has already been unmapped by the time we started mapping the grab does a sync so we don't have to here */ @@ -130,16 +130,14 @@ void client_manage(Window window) XCheckTypedWindowEvent(ob_display, window, UnmapNotify, &e)) { XPutBackEvent(ob_display, &e); - XUngrabServer(ob_display); - XFlush(ob_display); + grab_server(FALSE); return; /* don't manage it */ } /* make sure it isn't an override-redirect window */ if (!XGetWindowAttributes(ob_display, window, &attrib) || attrib.override_redirect) { - XUngrabServer(ob_display); - XFlush(ob_display); + grab_server(FALSE); return; /* don't manage it */ } @@ -148,8 +146,7 @@ void client_manage(Window window) if ((wmhint->flags & StateHint) && wmhint->initial_state == WithdrawnState) { /\* XXX: make dock apps work! *\/ - XUngrabServer(ob_display); - XFlush(ob_display); + grab_server(FALSE); XFree(wmhint); return; } @@ -184,8 +181,7 @@ void client_manage(Window window) client_apply_startup_state(client); - XUngrabServer(ob_display); - XFlush(ob_display); + grab_server(FALSE); client_list = g_slist_append(client_list, client); stacking_list = g_list_append(stacking_list, client); 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 #include -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); } diff --git a/openbox/grab.h b/openbox/grab.h index 49c6a436..d6a1b78a 100644 --- a/openbox/grab.h +++ b/openbox/grab.h @@ -9,5 +9,6 @@ void grab_shutdown(); void grab_keyboard(gboolean grab); void grab_pointer(gboolean grab, Cursor cur); +void grab_server(gboolean grab); #endif