From c4d8ba0f72cbc3326d0d871a9babb9a24d29095a Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 1 Feb 2023 17:41:12 +0100 Subject: [PATCH] wayland: Avoid entering MetaWindow on other than user pointer motions On one hand, this used to be handled generically in all the paths that changed the MetaWaylandPointer focus surface, induced by user interaction or not. On the other hand, just listening for crossing events is not sufficient since those also do happen programmatically. We must only listen to crossing events that have a physical source device, meaning this was created through user interaction. Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/888 Part-of: --- src/wayland/meta-wayland-pointer.c | 40 ++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/src/wayland/meta-wayland-pointer.c b/src/wayland/meta-wayland-pointer.c index d324d167e..e18ad9ed2 100644 --- a/src/wayland/meta-wayland-pointer.c +++ b/src/wayland/meta-wayland-pointer.c @@ -681,7 +681,33 @@ meta_wayland_pointer_update (MetaWaylandPointer *pointer, event->type == CLUTTER_ENTER || event->type == CLUTTER_LEAVE) && !clutter_event_get_event_sequence (event)) - repick_for_event (pointer, event); + { + repick_for_event (pointer, event); + + if (event->type == CLUTTER_ENTER) + { + MetaWindow *focus_window = NULL; + ClutterInputDevice *device; + + device = clutter_event_get_source_device (event); + + if (clutter_input_device_get_device_mode (device) != CLUTTER_INPUT_MODE_LOGICAL) + { + if (pointer->focus_surface) + focus_window = meta_wayland_surface_get_window (pointer->focus_surface); + + if (focus_window) + { + graphene_point_t pos; + + clutter_event_get_coords (event, &pos.x, &pos.y); + meta_window_handle_enter (focus_window, + clutter_event_get_time (event), + pos.x, pos.y); + } + } + } + } if (event->type == CLUTTER_MOTION || event->type == CLUTTER_BUTTON_PRESS || @@ -1044,10 +1070,7 @@ meta_wayland_pointer_set_focus (MetaWaylandPointer *pointer, if (surface != NULL) { - ClutterStage *stage = CLUTTER_STAGE (meta_backend_get_stage (backend)); struct wl_client *client = wl_resource_get_client (surface->resource); - graphene_point_t pos; - MetaWindow *focus_window; pointer->focus_surface = surface; @@ -1056,15 +1079,6 @@ meta_wayland_pointer_set_focus (MetaWaylandPointer *pointer, G_CALLBACK (focus_surface_destroyed), pointer); - clutter_stage_get_device_coords (stage, pointer->device, NULL, &pos); - - focus_window = meta_wayland_surface_get_window (pointer->focus_surface); - if (focus_window) - meta_window_handle_enter (focus_window, - /* XXX -- can we reliably get a timestamp for setting focus? */ - clutter_get_current_event_time (), - pos.x, pos.y); - toplevel_window = surface_get_effective_window (pointer->focus_surface); if (toplevel_window) {