mirror of
https://github.com/brl/mutter.git
synced 2025-02-21 07:24:09 +00:00
keybindings: Add API to freeze/unfreeze the keyboard
We'll use this in gnome-shell to freeze the keyboard right before switching input source and unfreeze it after that's finished so that we don't lose any key events to the wrong input source. https://bugzilla.gnome.org/show_bug.cgi?id=697001
This commit is contained in:
parent
f97d8dfb6c
commit
bda4af5504
@ -1248,7 +1248,8 @@ grab_status_to_string (int status)
|
|||||||
static gboolean
|
static gboolean
|
||||||
grab_keyboard (MetaDisplay *display,
|
grab_keyboard (MetaDisplay *display,
|
||||||
Window xwindow,
|
Window xwindow,
|
||||||
guint32 timestamp)
|
guint32 timestamp,
|
||||||
|
int grab_mode)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
int grab_status;
|
int grab_status;
|
||||||
@ -1269,7 +1270,7 @@ grab_keyboard (MetaDisplay *display,
|
|||||||
xwindow,
|
xwindow,
|
||||||
timestamp,
|
timestamp,
|
||||||
None,
|
None,
|
||||||
XIGrabModeAsync, XIGrabModeAsync,
|
grab_mode, grab_mode,
|
||||||
True, /* owner_events */
|
True, /* owner_events */
|
||||||
&mask);
|
&mask);
|
||||||
|
|
||||||
@ -1323,7 +1324,7 @@ meta_screen_grab_all_keys (MetaScreen *screen, guint32 timestamp)
|
|||||||
|
|
||||||
meta_topic (META_DEBUG_KEYBINDINGS,
|
meta_topic (META_DEBUG_KEYBINDINGS,
|
||||||
"Grabbing all keys on RootWindow\n");
|
"Grabbing all keys on RootWindow\n");
|
||||||
retval = grab_keyboard (screen->display, screen->xroot, timestamp);
|
retval = grab_keyboard (screen->display, screen->xroot, timestamp, XIGrabModeAsync);
|
||||||
if (retval)
|
if (retval)
|
||||||
{
|
{
|
||||||
screen->all_keys_grabbed = TRUE;
|
screen->all_keys_grabbed = TRUE;
|
||||||
@ -1376,7 +1377,7 @@ meta_window_grab_all_keys (MetaWindow *window,
|
|||||||
|
|
||||||
meta_topic (META_DEBUG_KEYBINDINGS,
|
meta_topic (META_DEBUG_KEYBINDINGS,
|
||||||
"Grabbing all keys on window %s\n", window->desc);
|
"Grabbing all keys on window %s\n", window->desc);
|
||||||
retval = grab_keyboard (window->display, grabwindow, timestamp);
|
retval = grab_keyboard (window->display, grabwindow, timestamp, XIGrabModeAsync);
|
||||||
if (retval)
|
if (retval)
|
||||||
{
|
{
|
||||||
window->keys_grabbed = FALSE;
|
window->keys_grabbed = FALSE;
|
||||||
@ -1403,6 +1404,44 @@ meta_window_ungrab_all_keys (MetaWindow *window, guint32 timestamp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_display_grab_keyboard (MetaDisplay *display, guint32 timestamp)
|
||||||
|
{
|
||||||
|
grab_keyboard (display, DefaultRootWindow (display->xdisplay), timestamp, XIGrabModeSync);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_display_ungrab_keyboard (MetaDisplay *display, guint32 timestamp)
|
||||||
|
{
|
||||||
|
ungrab_keyboard (display, timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_display_freeze_keyboard (MetaDisplay *display, guint32 timestamp)
|
||||||
|
{
|
||||||
|
meta_error_trap_push (display);
|
||||||
|
|
||||||
|
meta_topic (META_DEBUG_KEYBINDINGS,
|
||||||
|
"Freezing keyboard with timestamp %u\n",
|
||||||
|
timestamp);
|
||||||
|
XIAllowEvents (display->xdisplay, META_VIRTUAL_CORE_KEYBOARD_ID,
|
||||||
|
XISyncDevice, timestamp);
|
||||||
|
meta_error_trap_pop (display);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_display_unfreeze_keyboard (MetaDisplay *display, guint32 timestamp)
|
||||||
|
{
|
||||||
|
meta_error_trap_push (display);
|
||||||
|
|
||||||
|
meta_topic (META_DEBUG_KEYBINDINGS,
|
||||||
|
"Unfreezing keyboard with timestamp %u\n",
|
||||||
|
timestamp);
|
||||||
|
XIAllowEvents (display->xdisplay, META_VIRTUAL_CORE_KEYBOARD_ID,
|
||||||
|
XIAsyncDevice, timestamp);
|
||||||
|
meta_error_trap_pop (display);
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
is_modifier (MetaDisplay *display,
|
is_modifier (MetaDisplay *display,
|
||||||
unsigned int keycode)
|
unsigned int keycode)
|
||||||
|
@ -187,4 +187,12 @@ void meta_display_unmanage_screen (MetaDisplay *display,
|
|||||||
|
|
||||||
void meta_display_clear_mouse_mode (MetaDisplay *display);
|
void meta_display_clear_mouse_mode (MetaDisplay *display);
|
||||||
|
|
||||||
|
void meta_display_grab_keyboard (MetaDisplay *display,
|
||||||
|
guint32 timestamp);
|
||||||
|
void meta_display_ungrab_keyboard (MetaDisplay *display,
|
||||||
|
guint32 timestamp);
|
||||||
|
void meta_display_freeze_keyboard (MetaDisplay *display,
|
||||||
|
guint32 timestamp);
|
||||||
|
void meta_display_unfreeze_keyboard (MetaDisplay *display,
|
||||||
|
guint32 timestamp);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user