keybindings: Grab keys with XI2

https://bugzilla.gnome.org/show_bug.cgi?id=688779
This commit is contained in:
Jasper St. Pierre 2012-11-20 18:04:42 -05:00
parent afcdfd158f
commit 7c20621112

View File

@ -809,6 +809,12 @@ meta_change_keygrab (MetaDisplay *display,
{ {
unsigned int ignored_mask; unsigned int ignored_mask;
unsigned char mask_bits[XIMaskLen (XI_LASTEVENT)] = { 0 };
XIEventMask mask = { XIAllMasterDevices, sizeof (mask_bits), mask_bits };
XISetMask (mask.mask, XI_KeyPress);
XISetMask (mask.mask, XI_KeyRelease);
/* Grab keycode/modmask, together with /* Grab keycode/modmask, together with
* all combinations of ignored modifiers. * all combinations of ignored modifiers.
* X provides no better way to do this. * X provides no better way to do this.
@ -826,6 +832,8 @@ meta_change_keygrab (MetaDisplay *display,
ignored_mask = 0; ignored_mask = 0;
while (ignored_mask <= display->ignored_modifier_mask) while (ignored_mask <= display->ignored_modifier_mask)
{ {
XIGrabModifiers mods;
if (ignored_mask & ~(display->ignored_modifier_mask)) if (ignored_mask & ~(display->ignored_modifier_mask))
{ {
/* Not a combination of ignored modifiers /* Not a combination of ignored modifiers
@ -835,18 +843,20 @@ meta_change_keygrab (MetaDisplay *display,
continue; continue;
} }
mods = (XIGrabModifiers) { modmask | ignored_mask, 0 };
if (meta_is_debugging ()) if (meta_is_debugging ())
meta_error_trap_push_with_return (display); meta_error_trap_push_with_return (display);
if (grab) if (grab)
XGrabKey (display->xdisplay, keycode, XIGrabKeycode (display->xdisplay,
modmask | ignored_mask, META_VIRTUAL_CORE_KEYBOARD_ID,
xwindow, keycode, xwindow,
True, XIGrabModeSync, XIGrabModeAsync,
GrabModeAsync, GrabModeSync); False, &mask, 1, &mods);
else else
XUngrabKey (display->xdisplay, keycode, XIUngrabKeycode (display->xdisplay,
modmask | ignored_mask, META_VIRTUAL_CORE_KEYBOARD_ID,
xwindow); keycode, xwindow, 1, &mods);
if (meta_is_debugging ()) if (meta_is_debugging ())
{ {