mirror of
https://github.com/brl/mutter.git
synced 2024-11-24 00:50:42 -05:00
keybindings: Use meta_device_grab() for keyboard active grabs
This commit is contained in:
parent
61a7789c83
commit
2484e8cd64
@ -3628,11 +3628,15 @@ meta_display_begin_grab_op (MetaDisplay *display,
|
||||
{
|
||||
if (grab_window)
|
||||
grab_info->grab_have_keyboard =
|
||||
meta_window_grab_all_keys (grab_window, timestamp);
|
||||
meta_window_grab_all_keys (grab_window,
|
||||
grab_info->grab_keyboard,
|
||||
timestamp);
|
||||
|
||||
else
|
||||
grab_info->grab_have_keyboard =
|
||||
meta_screen_grab_all_keys (screen, timestamp);
|
||||
meta_screen_grab_all_keys (screen,
|
||||
grab_info->grab_keyboard,
|
||||
timestamp);
|
||||
|
||||
if (!grab_info->grab_have_keyboard)
|
||||
{
|
||||
@ -3847,9 +3851,13 @@ meta_display_end_grab_op (MetaDisplay *display,
|
||||
meta_topic (META_DEBUG_WINDOW_OPS,
|
||||
"Ungrabbing all keys timestamp %u\n", timestamp);
|
||||
if (grab_info->grab_window)
|
||||
meta_window_ungrab_all_keys (grab_info->grab_window, timestamp);
|
||||
meta_window_ungrab_all_keys (grab_info->grab_window,
|
||||
grab_info->grab_keyboard,
|
||||
timestamp);
|
||||
else
|
||||
meta_screen_ungrab_all_keys (grab_info->grab_screen, timestamp);
|
||||
meta_screen_ungrab_all_keys (grab_info->grab_screen,
|
||||
grab_info->grab_keyboard,
|
||||
timestamp);
|
||||
}
|
||||
|
||||
#ifdef HAVE_XSYNC
|
||||
|
@ -36,14 +36,18 @@ void meta_display_shutdown_keys (MetaDisplay *display);
|
||||
void meta_screen_grab_keys (MetaScreen *screen);
|
||||
void meta_screen_ungrab_keys (MetaScreen *screen);
|
||||
gboolean meta_screen_grab_all_keys (MetaScreen *screen,
|
||||
MetaDevice *device,
|
||||
guint32 timestamp);
|
||||
void meta_screen_ungrab_all_keys (MetaScreen *screen,
|
||||
MetaDevice *device,
|
||||
guint32 timestamp);
|
||||
void meta_window_grab_keys (MetaWindow *window);
|
||||
void meta_window_ungrab_keys (MetaWindow *window);
|
||||
gboolean meta_window_grab_all_keys (MetaWindow *window,
|
||||
MetaDevice *device,
|
||||
guint32 timestamp);
|
||||
void meta_window_ungrab_all_keys (MetaWindow *window,
|
||||
MetaDevice *device,
|
||||
guint32 timestamp);
|
||||
gboolean meta_display_process_key_event (MetaDisplay *display,
|
||||
MetaWindow *window,
|
||||
|
@ -926,6 +926,7 @@ meta_window_ungrab_keys (MetaWindow *window)
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
#ifdef WITH_VERBOSE_MODE
|
||||
static const char*
|
||||
grab_status_to_string (int status)
|
||||
@ -947,31 +948,32 @@ grab_status_to_string (int status)
|
||||
}
|
||||
}
|
||||
#endif /* WITH_VERBOSE_MODE */
|
||||
#endif /* 0 */
|
||||
|
||||
static gboolean
|
||||
grab_keyboard (MetaDisplay *display,
|
||||
Window xwindow,
|
||||
MetaDevice *device,
|
||||
guint32 timestamp)
|
||||
{
|
||||
MetaGrabInfo *grab_info;
|
||||
int result;
|
||||
int grab_status;
|
||||
|
||||
/* Grab the keyboard, so we get key releases and all key
|
||||
* presses
|
||||
*/
|
||||
meta_error_trap_push_with_return (display);
|
||||
grab_info = meta_display_get_grab_info (display, device);
|
||||
|
||||
grab_status = XGrabKeyboard (display->xdisplay,
|
||||
xwindow, True,
|
||||
GrabModeAsync, GrabModeAsync,
|
||||
timestamp);
|
||||
|
||||
if (grab_status != GrabSuccess)
|
||||
if (!meta_device_grab (grab_info->grab_keyboard,
|
||||
xwindow,
|
||||
KeyPressMask | KeyReleaseMask,
|
||||
META_CURSOR_DEFAULT,
|
||||
TRUE, FALSE, timestamp))
|
||||
{
|
||||
meta_error_trap_pop_with_return (display);
|
||||
meta_topic (META_DEBUG_KEYBINDINGS,
|
||||
"XGrabKeyboard() returned failure status %s time %u\n",
|
||||
grab_status_to_string (grab_status),
|
||||
"grabbing keyboard failed time %u\n",
|
||||
timestamp);
|
||||
return FALSE;
|
||||
}
|
||||
@ -981,7 +983,7 @@ grab_keyboard (MetaDisplay *display,
|
||||
if (result != Success)
|
||||
{
|
||||
meta_topic (META_DEBUG_KEYBINDINGS,
|
||||
"XGrabKeyboard() resulted in an error\n");
|
||||
"grabbing keyboard resulted in an error\n");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
@ -992,19 +994,27 @@ grab_keyboard (MetaDisplay *display,
|
||||
}
|
||||
|
||||
static void
|
||||
ungrab_keyboard (MetaDisplay *display, guint32 timestamp)
|
||||
ungrab_keyboard (MetaDisplay *display,
|
||||
MetaDevice *device,
|
||||
guint32 timestamp)
|
||||
{
|
||||
MetaGrabInfo *grab_info;
|
||||
|
||||
grab_info = meta_display_get_grab_info (display, device);
|
||||
|
||||
meta_error_trap_push (display);
|
||||
|
||||
meta_topic (META_DEBUG_KEYBINDINGS,
|
||||
"Ungrabbing keyboard with timestamp %u\n",
|
||||
timestamp);
|
||||
XUngrabKeyboard (display->xdisplay, timestamp);
|
||||
meta_device_ungrab (grab_info->grab_keyboard, timestamp);
|
||||
meta_error_trap_pop (display);
|
||||
}
|
||||
|
||||
gboolean
|
||||
meta_screen_grab_all_keys (MetaScreen *screen, guint32 timestamp)
|
||||
meta_screen_grab_all_keys (MetaScreen *screen,
|
||||
MetaDevice *device,
|
||||
guint32 timestamp)
|
||||
{
|
||||
gboolean retval;
|
||||
|
||||
@ -1016,7 +1026,7 @@ meta_screen_grab_all_keys (MetaScreen *screen, guint32 timestamp)
|
||||
|
||||
meta_topic (META_DEBUG_KEYBINDINGS,
|
||||
"Grabbing all keys on RootWindow\n");
|
||||
retval = grab_keyboard (screen->display, screen->xroot, timestamp);
|
||||
retval = grab_keyboard (screen->display, screen->xroot, device, timestamp);
|
||||
if (retval)
|
||||
{
|
||||
screen->all_keys_grabbed = TRUE;
|
||||
@ -1029,11 +1039,13 @@ meta_screen_grab_all_keys (MetaScreen *screen, guint32 timestamp)
|
||||
}
|
||||
|
||||
void
|
||||
meta_screen_ungrab_all_keys (MetaScreen *screen, guint32 timestamp)
|
||||
meta_screen_ungrab_all_keys (MetaScreen *screen,
|
||||
MetaDevice *device,
|
||||
guint32 timestamp)
|
||||
{
|
||||
if (screen->all_keys_grabbed)
|
||||
{
|
||||
ungrab_keyboard (screen->display, timestamp);
|
||||
ungrab_keyboard (screen->display, device, timestamp);
|
||||
|
||||
screen->all_keys_grabbed = FALSE;
|
||||
screen->keys_grabbed = FALSE;
|
||||
@ -1046,6 +1058,7 @@ meta_screen_ungrab_all_keys (MetaScreen *screen, guint32 timestamp)
|
||||
|
||||
gboolean
|
||||
meta_window_grab_all_keys (MetaWindow *window,
|
||||
MetaDevice *device,
|
||||
guint32 timestamp)
|
||||
{
|
||||
Window grabwindow;
|
||||
@ -1069,7 +1082,7 @@ meta_window_grab_all_keys (MetaWindow *window,
|
||||
|
||||
meta_topic (META_DEBUG_KEYBINDINGS,
|
||||
"Grabbing all keys on window %s\n", window->desc);
|
||||
retval = grab_keyboard (window->display, grabwindow, timestamp);
|
||||
retval = grab_keyboard (window->display, grabwindow, device, timestamp);
|
||||
if (retval)
|
||||
{
|
||||
window->keys_grabbed = FALSE;
|
||||
@ -1081,11 +1094,13 @@ meta_window_grab_all_keys (MetaWindow *window,
|
||||
}
|
||||
|
||||
void
|
||||
meta_window_ungrab_all_keys (MetaWindow *window, guint32 timestamp)
|
||||
meta_window_ungrab_all_keys (MetaWindow *window,
|
||||
MetaDevice *device,
|
||||
guint32 timestamp)
|
||||
{
|
||||
if (window->all_keys_grabbed)
|
||||
{
|
||||
ungrab_keyboard (window->display, timestamp);
|
||||
ungrab_keyboard (window->display, device, timestamp);
|
||||
|
||||
window->grab_on_frame = FALSE;
|
||||
window->all_keys_grabbed = FALSE;
|
||||
|
@ -67,6 +67,10 @@ void meta_keybindings_switch_window (MetaDisplay *display,
|
||||
MetaKeyBinding *binding);
|
||||
|
||||
|
||||
void meta_screen_ungrab_all_keys (MetaScreen *screen, guint32 timestamp);
|
||||
gboolean meta_screen_grab_all_keys (MetaScreen *screen, guint32 timestamp);
|
||||
void meta_screen_ungrab_all_keys (MetaScreen *screen,
|
||||
MetaDevice *device,
|
||||
guint32 timestamp);
|
||||
gboolean meta_screen_grab_all_keys (MetaScreen *screen,
|
||||
MetaDevice *device,
|
||||
guint32 timestamp);
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user