add 'grab_server' for grabbing .. the .. server!

This commit is contained in:
Dana Jansens 2003-03-18 20:00:44 +00:00
parent 598c5d6c07
commit 7d215bd255
3 changed files with 26 additions and 13 deletions

View file

@ -5,6 +5,7 @@
#include "frame.h" #include "frame.h"
#include "engine.h" #include "engine.h"
#include "event.h" #include "event.h"
#include "grab.h"
#include "focus.h" #include "focus.h"
#include "stacking.h" #include "stacking.h"
#include "dispatch.h" #include "dispatch.h"
@ -120,9 +121,8 @@ void client_manage(Window window)
XWindowAttributes attrib; XWindowAttributes attrib;
XSetWindowAttributes attrib_set; XSetWindowAttributes attrib_set;
/* XWMHints *wmhint; */ /* XWMHints *wmhint; */
XGrabServer(ob_display); grab_server(TRUE);
XSync(ob_display, FALSE);
/* check if it has already been unmapped by the time we started mapping /* 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 */ 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)) { XCheckTypedWindowEvent(ob_display, window, UnmapNotify, &e)) {
XPutBackEvent(ob_display, &e); XPutBackEvent(ob_display, &e);
XUngrabServer(ob_display); grab_server(FALSE);
XFlush(ob_display);
return; /* don't manage it */ return; /* don't manage it */
} }
/* make sure it isn't an override-redirect window */ /* make sure it isn't an override-redirect window */
if (!XGetWindowAttributes(ob_display, window, &attrib) || if (!XGetWindowAttributes(ob_display, window, &attrib) ||
attrib.override_redirect) { attrib.override_redirect) {
XUngrabServer(ob_display); grab_server(FALSE);
XFlush(ob_display);
return; /* don't manage it */ return; /* don't manage it */
} }
@ -148,8 +146,7 @@ void client_manage(Window window)
if ((wmhint->flags & StateHint) && if ((wmhint->flags & StateHint) &&
wmhint->initial_state == WithdrawnState) { wmhint->initial_state == WithdrawnState) {
/\* XXX: make dock apps work! *\/ /\* XXX: make dock apps work! *\/
XUngrabServer(ob_display); grab_server(FALSE);
XFlush(ob_display);
XFree(wmhint); XFree(wmhint);
return; return;
} }
@ -184,8 +181,7 @@ void client_manage(Window window)
client_apply_startup_state(client); client_apply_startup_state(client);
XUngrabServer(ob_display); grab_server(FALSE);
XFlush(ob_display);
client_list = g_slist_append(client_list, client); client_list = g_slist_append(client_list, client);
stacking_list = g_list_append(stacking_list, client); stacking_list = g_list_append(stacking_list, client);

View file

@ -2,7 +2,7 @@
#include <glib.h> #include <glib.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
static guint kgrabs, pgrabs; static guint kgrabs, pgrabs, sgrabs;
void grab_keyboard(gboolean grab) 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() void grab_startup()
{ {
kgrabs = pgrabs = 0; kgrabs = pgrabs = sgrabs = 0;
} }
void grab_shutdown() void grab_shutdown()
{ {
while (kgrabs) grab_keyboard(FALSE); while (kgrabs) grab_keyboard(FALSE);
while (pgrabs) grab_pointer(FALSE, None); while (pgrabs) grab_pointer(FALSE, None);
while (sgrabs) grab_server(FALSE);
} }

View file

@ -9,5 +9,6 @@ void grab_shutdown();
void grab_keyboard(gboolean grab); void grab_keyboard(gboolean grab);
void grab_pointer(gboolean grab, Cursor cur); void grab_pointer(gboolean grab, Cursor cur);
void grab_server(gboolean grab);
#endif #endif