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)
|
switch (event->type)
|
||||||
{
|
{
|
||||||
case CLUTTER_BUTTON_PRESS:
|
case CLUTTER_BUTTON_PRESS:
|
||||||
@ -2098,21 +2111,6 @@ meta_display_handle_event (MetaDisplay *display,
|
|||||||
display->overlay_key_only_pressed = FALSE;
|
display->overlay_key_only_pressed = FALSE;
|
||||||
break;
|
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:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -100,9 +100,9 @@ gboolean meta_window_grab_all_keys (MetaWindow *window,
|
|||||||
guint32 timestamp);
|
guint32 timestamp);
|
||||||
void meta_window_ungrab_all_keys (MetaWindow *window,
|
void meta_window_ungrab_all_keys (MetaWindow *window,
|
||||||
guint32 timestamp);
|
guint32 timestamp);
|
||||||
gboolean meta_display_process_key_event (MetaDisplay *display,
|
gboolean meta_keybindings_process_event (MetaDisplay *display,
|
||||||
MetaWindow *window,
|
MetaWindow *window,
|
||||||
ClutterKeyEvent *event);
|
const ClutterEvent *event);
|
||||||
void meta_display_process_mapping_event (MetaDisplay *display,
|
void meta_display_process_mapping_event (MetaDisplay *display,
|
||||||
XEvent *event);
|
XEvent *event);
|
||||||
|
|
||||||
|
@ -1738,24 +1738,10 @@ process_iso_next_group (MetaDisplay *display,
|
|||||||
return activate;
|
return activate;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Handle a key event. May be called recursively: some key events cause
|
static gboolean
|
||||||
* grabs to be ended and then need to be processed again in their own
|
process_key_event (MetaDisplay *display,
|
||||||
* right. This cannot cause infinite recursion because we never call
|
MetaWindow *window,
|
||||||
* ourselves when there wasn't a grab, and we always clear the grab
|
ClutterKeyEvent *event)
|
||||||
* 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)
|
|
||||||
{
|
{
|
||||||
gboolean keep_grab;
|
gboolean keep_grab;
|
||||||
gboolean all_keys_grabbed;
|
gboolean all_keys_grabbed;
|
||||||
@ -1853,6 +1839,36 @@ meta_display_process_key_event (MetaDisplay *display,
|
|||||||
return process_event (display, screen, window, event);
|
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
|
static gboolean
|
||||||
process_mouse_move_resize_grab (MetaDisplay *display,
|
process_mouse_move_resize_grab (MetaDisplay *display,
|
||||||
MetaScreen *screen,
|
MetaScreen *screen,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user