X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fgrab.c;h=719d3301c6bb1bef2069f580a370f291a1a4084b;hb=22f38541c5af082805bf08bff1e04aff8fa430dd;hp=c6beee746bba2d8f6b6972385e1010ff1a030731;hpb=7d215bd255d0744101b9ceb52c235bdc985fa034;p=chaz%2Fopenbox diff --git a/openbox/grab.c b/openbox/grab.c index c6beee74..719d3301 100644 --- a/openbox/grab.c +++ b/openbox/grab.c @@ -1,9 +1,16 @@ #include "openbox.h" +#include "event.h" + #include #include static guint kgrabs, pgrabs, sgrabs; +#define MASK_LIST_SIZE 8 + +/*! A list of all possible combinations of keyboard lock masks */ +static unsigned int mask_list[MASK_LIST_SIZE]; + void grab_keyboard(gboolean grab) { if (grab) { @@ -21,7 +28,7 @@ void grab_pointer(gboolean grab, Cursor cur) if (grab) { if (pgrabs++ == 0) XGrabPointer(ob_display, ob_root, False, 0, GrabModeAsync, - GrabModeSync, FALSE, cur, CurrentTime); + GrabModeAsync, FALSE, cur, CurrentTime); } else if (pgrabs > 0) { if (--pgrabs == 0) XUngrabPointer(ob_display, CurrentTime); @@ -45,7 +52,19 @@ void grab_server(gboolean grab) void grab_startup() { + guint i = 0; + kgrabs = pgrabs = sgrabs = 0; + + mask_list[i++] = 0; + mask_list[i++] = LockMask; + mask_list[i++] = NumLockMask; + mask_list[i++] = LockMask | NumLockMask; + mask_list[i++] = ScrollLockMask; + mask_list[i++] = ScrollLockMask | LockMask; + mask_list[i++] = ScrollLockMask | NumLockMask; + mask_list[i++] = ScrollLockMask | LockMask | NumLockMask; + g_assert(i == MASK_LIST_SIZE); } void grab_shutdown() @@ -54,3 +73,35 @@ void grab_shutdown() while (pgrabs) grab_pointer(FALSE, None); while (sgrabs) grab_server(FALSE); } + +void grab_button(guint button, guint state, Window win, guint mask, + int pointer_mode) +{ + guint i; + + for (i = 0; i < MASK_LIST_SIZE; ++i) + XGrabButton(ob_display, button, state | mask_list[i], win, FALSE, mask, + pointer_mode, GrabModeAsync, None, None); +} + +void ungrab_button(guint button, guint state, Window win) +{ + guint i; + + for (i = 0; i < MASK_LIST_SIZE; ++i) + XUngrabButton(ob_display, button, state | mask_list[i], win); +} + +void grab_key(guint keycode, guint state, int keyboard_mode) +{ + guint i; + + for (i = 0; i < MASK_LIST_SIZE; ++i) + XGrabKey(ob_display, keycode, state | mask_list[i], ob_root, FALSE, + GrabModeAsync, keyboard_mode); +} + +void ungrab_all_keys() +{ + XUngrabKey(ob_display, AnyKey, AnyModifier, ob_root); +}