add 'grab_server' for grabbing .. the .. server!
Dana Jansens danakj@orodu.net
3 files changed,
26 insertions(+),
13 deletions(-)
M
openbox/client.c
→
openbox/client.c
@@ -5,6 +5,7 @@ #include "extensions.h"
#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 @@ XEvent e;
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 @@ if (XCheckTypedWindowEvent(ob_display, window, DestroyNotify, &e) ||
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 @@ if ((wmhint = XGetWMHints(ob_display, 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 @@ engine_frame_grab_client(client->frame, client);
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);
M
openbox/grab.c
→
openbox/grab.c
@@ -2,7 +2,7 @@ #include "openbox.h"
#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 @@ 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); }
M
openbox/grab.h
→
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