X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fgrab.c;h=91f7915cbe7b5661575918fbdedf308336482197;hb=740c5b2a20d5110435d0874f8cc6a4c9dfd14777;hp=a53fe5e8241039a92ccfe4c8067740cfd5989ae3;hpb=32047fd66c796fe837168ce2ac6677aa0d2b20b4;p=chaz%2Fopenbox diff --git a/openbox/grab.c b/openbox/grab.c index a53fe5e8..91f7915c 100644 --- a/openbox/grab.c +++ b/openbox/grab.c @@ -31,7 +31,7 @@ #define MASK_LIST_SIZE 8 /*! A list of all possible combinations of keyboard lock masks */ -static unsigned int mask_list[MASK_LIST_SIZE]; +static guint mask_list[MASK_LIST_SIZE]; static guint kgrabs = 0; static guint pgrabs = 0; @@ -50,11 +50,13 @@ gboolean grab_keyboard(gboolean grab) gboolean ret = FALSE; if (grab) { - if (kgrabs++ == 0) + if (kgrabs++ == 0) { ret = XGrabKeyboard(ob_display, RootWindow(ob_display, ob_screen), FALSE, GrabModeAsync, GrabModeAsync, event_lasttime) == Success; - else + if (!ret) + --kgrabs; + } else ret = TRUE; } else if (kgrabs > 0) { if (--kgrabs == 0) @@ -70,16 +72,19 @@ gboolean grab_pointer(gboolean grab, ObCursor cur) gboolean ret = FALSE; if (grab) { - if (pgrabs++ == 0) + if (pgrabs++ == 0) { ret = XGrabPointer(ob_display, screen_support_win, False, GRAB_PTR_MASK, GrabModeAsync, GrabModeAsync, FALSE, ob_cursor(cur), event_lasttime) == Success; - else + if (!ret) + --pgrabs; + } else ret = TRUE; } else if (pgrabs > 0) { - if (--pgrabs == 0) + if (--pgrabs == 0) { XUngrabPointer(ob_display, event_lasttime); + } ret = TRUE; } return ret; @@ -90,16 +95,19 @@ gboolean grab_pointer_window(gboolean grab, ObCursor cur, Window win) gboolean ret = FALSE; if (grab) { - if (pgrabs++ == 0) + if (pgrabs++ == 0) { ret = XGrabPointer(ob_display, win, False, GRAB_PTR_MASK, GrabModeAsync, GrabModeAsync, TRUE, ob_cursor(cur), event_lasttime) == Success; - else + if (!ret) + --pgrabs; + } else ret = TRUE; } else if (pgrabs > 0) { - if (--pgrabs == 0) + if (--pgrabs == 0) { XUngrabPointer(ob_display, event_lasttime); + } ret = TRUE; } return ret; @@ -150,7 +158,7 @@ void grab_shutdown(gboolean reconfig) } void grab_button_full(guint button, guint state, Window win, guint mask, - int pointer_mode, ObCursor cur) + gint pointer_mode, ObCursor cur) { guint i; @@ -177,7 +185,7 @@ void ungrab_button(guint button, guint state, Window win) XUngrabButton(ob_display, button, state | mask_list[i], win); } -void grab_key(guint keycode, guint state, Window win, int keyboard_mode) +void grab_key(guint keycode, guint state, Window win, gint keyboard_mode) { guint i;