X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=openbox%2Fgrab.c;h=97a1a3db2acb631f86351fc16b59bbd64b5ced48;hb=e75ead70a6d98bd7e368c5844c05d2f85f275f65;hp=f90eb6b537d6964a34a5611f8b15f812a69e2da7;hpb=f29dd7e0cd0ceef0bfe95c865b6b22d34b065b7b;p=chaz%2Fopenbox diff --git a/openbox/grab.c b/openbox/grab.c index f90eb6b5..97a1a3db 100644 --- a/openbox/grab.c +++ b/openbox/grab.c @@ -1,5 +1,6 @@ #include "openbox.h" #include "event.h" +#include "xerror.h" #include #include @@ -14,18 +15,12 @@ static unsigned int mask_list[MASK_LIST_SIZE]; void grab_keyboard(gboolean grab) { if (grab) { - if (kgrabs++ == 0) { - g_message("GRABBING KEYBOARD %d", kgrabs); + if (kgrabs++ == 0) XGrabKeyboard(ob_display, ob_root, 0, GrabModeAsync, GrabModeSync, event_lasttime); - } else - g_message("NOT GRABBING KEYBOARD %d", kgrabs); } else if (kgrabs > 0) { - if (--kgrabs == 0) { - g_message("UNGRABBING KEYBOARD %d", kgrabs); + if (--kgrabs == 0) XUngrabKeyboard(ob_display, event_lasttime); - } else - g_message("NOT UNGRABBING KEYBOARD %d", kgrabs); } } @@ -87,7 +82,7 @@ void grab_button(guint button, guint state, Window win, guint mask, for (i = 0; i < MASK_LIST_SIZE; ++i) XGrabButton(ob_display, button, state | mask_list[i], win, FALSE, mask, - pointer_mode, GrabModeAsync, None, None); + pointer_mode, GrabModeSync, None, None); } void ungrab_button(guint button, guint state, Window win) @@ -102,9 +97,14 @@ void grab_key(guint keycode, guint state, int keyboard_mode) { guint i; + xerror_set_ignore(TRUE); /* can get BadAccess' from these */ + xerror_occured = FALSE; for (i = 0; i < MASK_LIST_SIZE; ++i) XGrabKey(ob_display, keycode, state | mask_list[i], ob_root, FALSE, - GrabModeAsync, keyboard_mode); + GrabModeSync, keyboard_mode); + xerror_set_ignore(FALSE); + if (xerror_occured) + g_warning("failed to grab keycode %d modifiers %d", keycode, state); } void ungrab_all_keys()