#include "frame.h"
#include "engine.h"
#include "event.h"
+#include "grab.h"
#include "focus.h"
#include "stacking.h"
#include "dispatch.h"
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 */
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 */
}
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;
}
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);
#include <glib.h>
#include <X11/Xlib.h>
-static guint kgrabs, pgrabs;
+static guint kgrabs, pgrabs, sgrabs;
void grab_keyboard(gboolean grab)
{
}
}
+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);
}