events: Move keybindings event handling out of the giant switch
This commit is contained in:
parent
9b95eda42a
commit
bbfdf5dd2a
@ -1927,6 +1927,19 @@ meta_display_handle_event (MetaDisplay *display,
|
||||
}
|
||||
}
|
||||
|
||||
/* For key events, it's important to enforce single-handling, or
|
||||
* we can get into a confused state. So if a keybinding is
|
||||
* handled (because it's one of our hot-keys, or because we are
|
||||
* in a keyboard-grabbed mode like moving a window, we don't
|
||||
* want to pass the key event to the compositor or Wayland at all.
|
||||
*/
|
||||
if (meta_keybindings_process_event (display, window, event))
|
||||
{
|
||||
bypass_clutter = TRUE;
|
||||
bypass_wayland = TRUE;
|
||||
goto out;
|
||||
}
|
||||
|
||||
switch (event->type)
|
||||
{
|
||||
case CLUTTER_BUTTON_PRESS:
|
||||
@ -2098,21 +2111,6 @@ meta_display_handle_event (MetaDisplay *display,
|
||||
display->overlay_key_only_pressed = FALSE;
|
||||
break;
|
||||
|
||||
case CLUTTER_KEY_PRESS:
|
||||
case CLUTTER_KEY_RELEASE:
|
||||
/* For key events, it's important to enforce single-handling, or
|
||||
* we can get into a confused state. So if a keybinding is
|
||||
* handled (because it's one of our hot-keys, or because we are
|
||||
* in a keyboard-grabbed mode like moving a window, we don't
|
||||
* want to pass the key event to the compositor or Wayland at all.
|
||||
*/
|
||||
if (meta_display_process_key_event (display, window, (ClutterKeyEvent *) event))
|
||||
{
|
||||
bypass_clutter = TRUE;
|
||||
bypass_wayland = TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -100,9 +100,9 @@ gboolean meta_window_grab_all_keys (MetaWindow *window,
|
||||
guint32 timestamp);
|
||||
void meta_window_ungrab_all_keys (MetaWindow *window,
|
||||
guint32 timestamp);
|
||||
gboolean meta_display_process_key_event (MetaDisplay *display,
|
||||
MetaWindow *window,
|
||||
ClutterKeyEvent *event);
|
||||
gboolean meta_keybindings_process_event (MetaDisplay *display,
|
||||
MetaWindow *window,
|
||||
const ClutterEvent *event);
|
||||
void meta_display_process_mapping_event (MetaDisplay *display,
|
||||
XEvent *event);
|
||||
|
||||
|
@ -1738,24 +1738,10 @@ process_iso_next_group (MetaDisplay *display,
|
||||
return activate;
|
||||
}
|
||||
|
||||
/* Handle a key event. May be called recursively: some key events cause
|
||||
* grabs to be ended and then need to be processed again in their own
|
||||
* right. This cannot cause infinite recursion because we never call
|
||||
* ourselves when there wasn't a grab, and we always clear the grab
|
||||
* first; the invariant is enforced using an assertion. See #112560.
|
||||
*
|
||||
* The return value is whether we handled the key event.
|
||||
*
|
||||
* FIXME: We need to prove there are no race conditions here.
|
||||
* FIXME: Does it correctly handle alt-Tab being followed by another
|
||||
* grabbing keypress without letting go of alt?
|
||||
* FIXME: An iterative solution would probably be simpler to understand
|
||||
* (and help us solve the other fixmes).
|
||||
*/
|
||||
gboolean
|
||||
meta_display_process_key_event (MetaDisplay *display,
|
||||
MetaWindow *window,
|
||||
ClutterKeyEvent *event)
|
||||
static gboolean
|
||||
process_key_event (MetaDisplay *display,
|
||||
MetaWindow *window,
|
||||
ClutterKeyEvent *event)
|
||||
{
|
||||
gboolean keep_grab;
|
||||
gboolean all_keys_grabbed;
|
||||
@ -1853,6 +1839,36 @@ meta_display_process_key_event (MetaDisplay *display,
|
||||
return process_event (display, screen, window, event);
|
||||
}
|
||||
|
||||
/* Handle a key event. May be called recursively: some key events cause
|
||||
* grabs to be ended and then need to be processed again in their own
|
||||
* right. This cannot cause infinite recursion because we never call
|
||||
* ourselves when there wasn't a grab, and we always clear the grab
|
||||
* first; the invariant is enforced using an assertion. See #112560.
|
||||
*
|
||||
* The return value is whether we handled the key event.
|
||||
*
|
||||
* FIXME: We need to prove there are no race conditions here.
|
||||
* FIXME: Does it correctly handle alt-Tab being followed by another
|
||||
* grabbing keypress without letting go of alt?
|
||||
* FIXME: An iterative solution would probably be simpler to understand
|
||||
* (and help us solve the other fixmes).
|
||||
*/
|
||||
gboolean
|
||||
meta_keybindings_process_event (MetaDisplay *display,
|
||||
MetaWindow *window,
|
||||
const ClutterEvent *event)
|
||||
{
|
||||
switch (event->type)
|
||||
{
|
||||
case CLUTTER_KEY_PRESS:
|
||||
case CLUTTER_KEY_RELEASE:
|
||||
return process_key_event (display, window, (ClutterKeyEvent *) event);
|
||||
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
process_mouse_move_resize_grab (MetaDisplay *display,
|
||||
MetaScreen *screen,
|
||||
|
Loading…
Reference in New Issue
Block a user