From 7c206211120df2286cf59c477cf4e94e1bbc333e Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Tue, 20 Nov 2012 18:04:42 -0500 Subject: [PATCH] keybindings: Grab keys with XI2 https://bugzilla.gnome.org/show_bug.cgi?id=688779 --- src/core/keybindings.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/core/keybindings.c b/src/core/keybindings.c index 3ba267004..41003c7be 100644 --- a/src/core/keybindings.c +++ b/src/core/keybindings.c @@ -809,6 +809,12 @@ meta_change_keygrab (MetaDisplay *display, { 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 * all combinations of ignored modifiers. * X provides no better way to do this. @@ -826,6 +832,8 @@ meta_change_keygrab (MetaDisplay *display, ignored_mask = 0; while (ignored_mask <= display->ignored_modifier_mask) { + XIGrabModifiers mods; + if (ignored_mask & ~(display->ignored_modifier_mask)) { /* Not a combination of ignored modifiers @@ -835,18 +843,20 @@ meta_change_keygrab (MetaDisplay *display, continue; } + mods = (XIGrabModifiers) { modmask | ignored_mask, 0 }; + if (meta_is_debugging ()) meta_error_trap_push_with_return (display); if (grab) - XGrabKey (display->xdisplay, keycode, - modmask | ignored_mask, - xwindow, - True, - GrabModeAsync, GrabModeSync); + XIGrabKeycode (display->xdisplay, + META_VIRTUAL_CORE_KEYBOARD_ID, + keycode, xwindow, + XIGrabModeSync, XIGrabModeAsync, + False, &mask, 1, &mods); else - XUngrabKey (display->xdisplay, keycode, - modmask | ignored_mask, - xwindow); + XIUngrabKeycode (display->xdisplay, + META_VIRTUAL_CORE_KEYBOARD_ID, + keycode, xwindow, 1, &mods); if (meta_is_debugging ()) {