core: Move away from MetaEventRoute

We can check MetaGrabOp for the same effect, just do that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
This commit is contained in:
Carlos Garnacho 2022-09-29 21:45:55 +02:00 committed by Marge Bot
parent bb9cab1491
commit ee94b07159
4 changed files with 41 additions and 52 deletions

View File

@ -69,7 +69,7 @@ meta_window_show_close_dialog (MetaWindow *window)
meta_close_dialog_show (window->close_dialog); meta_close_dialog_show (window->close_dialog);
if (window->display && if (window->display &&
window->display->event_route == META_EVENT_ROUTE_NORMAL && window->display->grab_op == META_GRAB_OP_NONE &&
window == window->display->focus_window) window == window->display->focus_window)
meta_close_dialog_focus (window->close_dialog); meta_close_dialog_focus (window->close_dialog);
} }

View File

@ -1267,13 +1267,10 @@ meta_display_windows_are_interactable (MetaDisplay *display)
if (clutter_stage_get_grab_actor (CLUTTER_STAGE (stage))) if (clutter_stage_get_grab_actor (CLUTTER_STAGE (stage)))
return FALSE; return FALSE;
switch (display->event_route) if (display->grab_op == META_GRAB_OP_NONE)
{ return TRUE;
case META_EVENT_ROUTE_NORMAL:
return TRUE; return FALSE;
default:
return FALSE;
}
} }
/** /**
@ -1880,16 +1877,13 @@ meta_display_begin_grab_op (MetaDisplay *display,
event_route = get_event_route_from_grab_op (op); event_route = get_event_route_from_grab_op (op);
if (event_route == META_EVENT_ROUTE_WINDOW_OP) if (meta_prefs_get_raise_on_click ())
meta_window_raise (window);
else
{ {
if (meta_prefs_get_raise_on_click ()) display->grab_initial_x = root_x;
meta_window_raise (window); display->grab_initial_y = root_y;
else display->grab_threshold_movement_reached = FALSE;
{
display->grab_initial_x = root_x;
display->grab_initial_y = root_y;
display->grab_threshold_movement_reached = FALSE;
}
} }
grab_window = window; grab_window = window;
@ -1928,17 +1922,14 @@ meta_display_begin_grab_op (MetaDisplay *display,
} }
/* Grab keys when beginning window ops; see #126497 */ /* Grab keys when beginning window ops; see #126497 */
if (event_route == META_EVENT_ROUTE_WINDOW_OP) display->grab_have_keyboard = meta_window_grab_all_keys (grab_window, timestamp);
{
display->grab_have_keyboard = meta_window_grab_all_keys (grab_window, timestamp);
if (!display->grab_have_keyboard) if (!display->grab_have_keyboard)
{ {
meta_topic (META_DEBUG_WINDOW_OPS, "grabbing all keys failed, ungrabbing pointer"); meta_topic (META_DEBUG_WINDOW_OPS, "grabbing all keys failed, ungrabbing pointer");
meta_backend_ungrab_device (backend, META_VIRTUAL_CORE_POINTER_ID, timestamp); meta_backend_ungrab_device (backend, META_VIRTUAL_CORE_POINTER_ID, timestamp);
display->grab_have_pointer = FALSE; display->grab_have_pointer = FALSE;
return FALSE; return FALSE;
}
} }
display->event_route = event_route; display->event_route = event_route;
@ -1973,8 +1964,7 @@ meta_display_begin_grab_op (MetaDisplay *display,
g_signal_emit (display, display_signals[GRAB_OP_BEGIN], 0, g_signal_emit (display, display_signals[GRAB_OP_BEGIN], 0,
display->grab_window, display->grab_op); display->grab_window, display->grab_op);
if (display->event_route == META_EVENT_ROUTE_WINDOW_OP) meta_window_grab_op_began (display->grab_window, display->grab_op);
meta_window_grab_op_began (display->grab_window, display->grab_op);
return TRUE; return TRUE;
} }
@ -1989,7 +1979,7 @@ meta_display_end_grab_op (MetaDisplay *display,
meta_topic (META_DEBUG_WINDOW_OPS, meta_topic (META_DEBUG_WINDOW_OPS,
"Ending grab op %u at time %u", grab_op, timestamp); "Ending grab op %u at time %u", grab_op, timestamp);
if (display->event_route == META_EVENT_ROUTE_NORMAL) if (display->grab_op == META_GRAB_OP_NONE)
return; return;
g_assert (grab_window != NULL); g_assert (grab_window != NULL);
@ -1999,23 +1989,20 @@ meta_display_end_grab_op (MetaDisplay *display,
* up to date. */ * up to date. */
display->grab_op = META_GRAB_OP_NONE; display->grab_op = META_GRAB_OP_NONE;
if (display->event_route == META_EVENT_ROUTE_WINDOW_OP) /* Clear out the edge cache */
{ meta_display_cleanup_edges (display);
/* Clear out the edge cache */
meta_display_cleanup_edges (display);
/* Only raise the window in orthogonal raise /* Only raise the window in orthogonal raise
* ('do-not-raise-on-click') mode if the user didn't try to move * ('do-not-raise-on-click') mode if the user didn't try to move
* or resize the given window by at least a threshold amount. * or resize the given window by at least a threshold amount.
* For raise on click mode, the window was raised at the * For raise on click mode, the window was raised at the
* beginning of the grab_op. * beginning of the grab_op.
*/ */
if (!meta_prefs_get_raise_on_click () && if (!meta_prefs_get_raise_on_click () &&
!display->grab_threshold_movement_reached) !display->grab_threshold_movement_reached)
meta_window_raise (display->grab_window); meta_window_raise (display->grab_window);
meta_window_grab_op_ended (grab_window, grab_op); meta_window_grab_op_ended (grab_window, grab_op);
}
if (display->grab_have_pointer) if (display->grab_have_pointer)
{ {

View File

@ -43,6 +43,8 @@
#include "wayland/meta-wayland-private.h" #include "wayland/meta-wayland-private.h"
#endif #endif
#define META_GRAB_OP_GET_BASE_TYPE(op) (op & 0x00FF)
#define IS_GESTURE_EVENT(e) ((e)->type == CLUTTER_TOUCHPAD_SWIPE || \ #define IS_GESTURE_EVENT(e) ((e)->type == CLUTTER_TOUCHPAD_SWIPE || \
(e)->type == CLUTTER_TOUCHPAD_PINCH || \ (e)->type == CLUTTER_TOUCHPAD_PINCH || \
(e)->type == CLUTTER_TOUCHPAD_HOLD || \ (e)->type == CLUTTER_TOUCHPAD_HOLD || \
@ -85,9 +87,9 @@ get_window_for_event (MetaDisplay *display,
const ClutterEvent *event, const ClutterEvent *event,
ClutterActor *event_actor) ClutterActor *event_actor)
{ {
switch (display->event_route) switch (META_GRAB_OP_GET_BASE_TYPE (display->grab_op))
{ {
case META_EVENT_ROUTE_NORMAL: case META_GRAB_OP_NONE:
{ {
MetaWindowActor *window_actor; MetaWindowActor *window_actor;
@ -107,7 +109,7 @@ get_window_for_event (MetaDisplay *display,
else else
return NULL; return NULL;
} }
case META_EVENT_ROUTE_WINDOW_OP: case META_GRAB_OP_WINDOW_BASE:
return display->grab_window; return display->grab_window;
default: default:
g_assert_not_reached (); g_assert_not_reached ();
@ -387,7 +389,7 @@ meta_display_handle_event (MetaDisplay *display,
goto out; goto out;
} }
if (display->event_route == META_EVENT_ROUTE_WINDOW_OP) if (display->grab_op != META_GRAB_OP_NONE)
{ {
if (meta_window_handle_mouse_grab_op_event (window, event)) if (meta_window_handle_mouse_grab_op_event (window, event))
{ {
@ -413,7 +415,7 @@ meta_display_handle_event (MetaDisplay *display,
/* Do not pass keyboard events to Wayland if key focus is not on the /* Do not pass keyboard events to Wayland if key focus is not on the
* stage in normal mode (e.g. during keynav in the panel) * stage in normal mode (e.g. during keynav in the panel)
*/ */
if (display->event_route == META_EVENT_ROUTE_NORMAL) if (display->grab_op == META_GRAB_OP_NONE)
{ {
if (IS_KEY_EVENT (event) && !stage_has_key_focus (display)) if (IS_KEY_EVENT (event) && !stage_has_key_focus (display))
{ {
@ -482,7 +484,7 @@ meta_display_handle_event (MetaDisplay *display,
* event, and if it doesn't, replay the event to release our * event, and if it doesn't, replay the event to release our
* own sync grab. */ * own sync grab. */
if (display->event_route == META_EVENT_ROUTE_WINDOW_OP) if (display->grab_op != META_GRAB_OP_NONE)
{ {
bypass_clutter = TRUE; bypass_clutter = TRUE;
bypass_wayland = TRUE; bypass_wayland = TRUE;

View File

@ -4642,7 +4642,7 @@ meta_window_focus (MetaWindow *window,
backend = backend_from_window (window); backend = backend_from_window (window);
stage = CLUTTER_STAGE (meta_backend_get_stage (backend)); stage = CLUTTER_STAGE (meta_backend_get_stage (backend));
if (window->display->event_route == META_EVENT_ROUTE_NORMAL && if (window->display->grab_op == META_GRAB_OP_NONE &&
clutter_stage_get_grab_actor (stage) == NULL) clutter_stage_get_grab_actor (stage) == NULL)
clutter_stage_set_key_focus (stage, NULL); clutter_stage_set_key_focus (stage, NULL);