mirror of
https://github.com/brl/mutter.git
synced 2025-03-25 04:33:52 +00:00
keybindings: Grab keyboard with XI2
https://bugzilla.gnome.org/show_bug.cgi?id=688779
This commit is contained in:
parent
8fb9e0072c
commit
afcdfd158f
@ -1055,22 +1055,32 @@ grab_keyboard (MetaDisplay *display,
|
|||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
int grab_status;
|
int grab_status;
|
||||||
|
|
||||||
|
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 the keyboard, so we get key releases and all key
|
/* Grab the keyboard, so we get key releases and all key
|
||||||
* presses
|
* presses
|
||||||
*/
|
*/
|
||||||
meta_error_trap_push_with_return (display);
|
meta_error_trap_push_with_return (display);
|
||||||
|
|
||||||
grab_status = XGrabKeyboard (display->xdisplay,
|
grab_status = XIGrabDevice (display->xdisplay,
|
||||||
xwindow, True,
|
META_VIRTUAL_CORE_KEYBOARD_ID,
|
||||||
GrabModeAsync, GrabModeAsync,
|
xwindow,
|
||||||
timestamp);
|
timestamp,
|
||||||
|
None,
|
||||||
if (grab_status != GrabSuccess)
|
XIGrabModeAsync, XIGrabModeAsync,
|
||||||
|
True, /* owner_events */
|
||||||
|
&mask);
|
||||||
|
|
||||||
|
if (grab_status != Success)
|
||||||
{
|
{
|
||||||
meta_error_trap_pop_with_return (display);
|
meta_error_trap_pop_with_return (display);
|
||||||
meta_topic (META_DEBUG_KEYBINDINGS,
|
meta_topic (META_DEBUG_KEYBINDINGS,
|
||||||
"XGrabKeyboard() returned failure status %s time %u\n",
|
"XIGrabDevice() returned failure status %s time %u\n",
|
||||||
grab_status_to_string (grab_status),
|
grab_status_to_string (grab_status),
|
||||||
timestamp);
|
timestamp);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -1081,7 +1091,7 @@ grab_keyboard (MetaDisplay *display,
|
|||||||
if (result != Success)
|
if (result != Success)
|
||||||
{
|
{
|
||||||
meta_topic (META_DEBUG_KEYBINDINGS,
|
meta_topic (META_DEBUG_KEYBINDINGS,
|
||||||
"XGrabKeyboard() resulted in an error\n");
|
"XIGrabDevice() resulted in an error\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1099,7 +1109,7 @@ ungrab_keyboard (MetaDisplay *display, guint32 timestamp)
|
|||||||
meta_topic (META_DEBUG_KEYBINDINGS,
|
meta_topic (META_DEBUG_KEYBINDINGS,
|
||||||
"Ungrabbing keyboard with timestamp %u\n",
|
"Ungrabbing keyboard with timestamp %u\n",
|
||||||
timestamp);
|
timestamp);
|
||||||
XUngrabKeyboard (display->xdisplay, timestamp);
|
XIUngrabDevice (display->xdisplay, META_VIRTUAL_CORE_KEYBOARD_ID, timestamp);
|
||||||
meta_error_trap_pop (display);
|
meta_error_trap_pop (display);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user