1
0
Fork 0

wayland: Only cancel touch when a new event handler takes over

And notably, don't cancel touch when an event handler is being
removed. Touch events are largely unaffected by most Wayland
grabs (pointer constraints, popups), so we might be cancelling
input too early if one of these wayland grabs was effective when
touch interaction began, but stopped sometime between touch updates.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3889>
(cherry picked from commit 77b21ef8dc)
This commit is contained in:
Carlos Garnacho 2024-07-15 22:50:58 +02:00 committed by Jonas Ådahl
parent ac089a1710
commit 1c57f38daf

View file

@ -48,6 +48,12 @@ struct _MetaWaylandInput
ClutterGrab *grab; ClutterGrab *grab;
}; };
typedef enum
{
INVALIDATE_FOCUS_FLAG_DEFAULT = 0,
INVALIDATE_FOCUS_FLAG_CANCEL_TOUCH = 1 << 0,
} InvalidateFocusFlag;
static void meta_wayland_input_sync_focus (MetaWaylandInput *input); static void meta_wayland_input_sync_focus (MetaWaylandInput *input);
G_DEFINE_FINAL_TYPE (MetaWaylandInput, meta_wayland_input, G_TYPE_OBJECT) G_DEFINE_FINAL_TYPE (MetaWaylandInput, meta_wayland_input, G_TYPE_OBJECT)
@ -137,7 +143,8 @@ meta_wayland_event_handler_invalidate_focus (MetaWaylandEventHandler *handler,
} }
static void static void
meta_wayland_input_invalidate_all_focus (MetaWaylandInput *input) meta_wayland_input_invalidate_all_focus (MetaWaylandInput *input,
InvalidateFocusFlag flags)
{ {
MetaWaylandEventHandler *handler; MetaWaylandEventHandler *handler;
MetaWaylandSeat *seat = input->seat; MetaWaylandSeat *seat = input->seat;
@ -161,7 +168,8 @@ meta_wayland_input_invalidate_all_focus (MetaWaylandInput *input)
meta_wayland_event_handler_invalidate_focus (handler, device, NULL); meta_wayland_event_handler_invalidate_focus (handler, device, NULL);
} }
if (meta_wayland_seat_has_touch (seat)) if (meta_wayland_seat_has_touch (seat) &&
(flags & INVALIDATE_FOCUS_FLAG_CANCEL_TOUCH) != 0)
meta_wayland_touch_cancel (seat->touch); meta_wayland_touch_cancel (seat->touch);
g_hash_table_iter_init (&iter, seat->tablet_seat->tablets); g_hash_table_iter_init (&iter, seat->tablet_seat->tablets);
@ -257,7 +265,8 @@ meta_wayland_input_sync_focus (MetaWaylandInput *input)
g_assert (!wl_list_empty (&input->event_handler_list)); g_assert (!wl_list_empty (&input->event_handler_list));
handler = wl_container_of (input->event_handler_list.next, handler, link); handler = wl_container_of (input->event_handler_list.next, handler, link);
meta_wayland_input_invalidate_all_focus (input); meta_wayland_input_invalidate_all_focus (input,
INVALIDATE_FOCUS_FLAG_CANCEL_TOUCH);
} }
static void static void
@ -310,7 +319,8 @@ meta_wayland_input_attach_event_handler (MetaWaylandInput *input,
input); input);
} }
meta_wayland_input_invalidate_all_focus (input); meta_wayland_input_invalidate_all_focus (input,
INVALIDATE_FOCUS_FLAG_DEFAULT);
return handler; return handler;
} }
@ -337,7 +347,8 @@ meta_wayland_input_detach_event_handler (MetaWaylandInput *input,
wl_list_remove (&handler->link); wl_list_remove (&handler->link);
if (handler_change && !wl_list_empty (&input->event_handler_list)) if (handler_change && !wl_list_empty (&input->event_handler_list))
meta_wayland_input_invalidate_all_focus (input); meta_wayland_input_invalidate_all_focus (input,
INVALIDATE_FOCUS_FLAG_DEFAULT);
if (input->grab && !should_be_grabbed (input)) if (input->grab && !should_be_grabbed (input))
{ {