wayland/touch: Store touch serials more persistently

Right now we store touch serials on their according MetaWaylandTouchInfo
entries. These entries are gone as soon as the touchpoint ended though, and
it's not unlikely that clients will respond to that touch-end event after we
removed the touchpoint.

In this case we currently can't match the client provided serial to any of
our known touch sequences, which causes xdg_popup grabs that get requested
shortly after the touch-end to fail.

Let's be a bit more gentle on clients here and store the latest touch-down
serial on the MetaWaylandTouch, so that it continues to be around after the
touch-end and we can match the serial of the xdg_popup_grab() as expected.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2946>
This commit is contained in:
Jonas Dreßler 2023-04-03 14:26:16 +02:00 committed by Marge Bot
parent d53da38198
commit bbb196bdde
2 changed files with 12 additions and 1 deletions

View File

@ -270,6 +270,9 @@ meta_wayland_touch_update (MetaWaylandTouch *touch,
touch_info->slot_serial =
meta_wayland_input_device_next_serial (input_device);
if (event_type == CLUTTER_TOUCH_BEGIN)
touch->latest_touch_down_serial = touch_info->slot_serial;
}
touch_get_relative_coordinates (touch, touch_info->touch_surface->surface,
@ -524,6 +527,8 @@ meta_wayland_touch_enable (MetaWaylandTouch *touch)
touch->touches = g_hash_table_new_full (NULL, NULL, NULL,
(GDestroyNotify) touch_info_free);
touch->latest_touch_down_serial = 0;
wl_list_init (&touch->resource_list);
}
@ -534,6 +539,8 @@ meta_wayland_touch_disable (MetaWaylandTouch *touch)
g_clear_pointer (&touch->touch_surfaces, g_hash_table_unref);
g_clear_pointer (&touch->touches, g_hash_table_unref);
touch->latest_touch_down_serial = 0;
}
void
@ -559,8 +566,10 @@ meta_wayland_touch_can_popup (MetaWaylandTouch *touch,
if (!touch->touches)
return FALSE;
g_hash_table_iter_init (&iter, touch->touches);
if (touch->latest_touch_down_serial == serial)
return TRUE;
g_hash_table_iter_init (&iter, touch->touches);
while (g_hash_table_iter_next (&iter, NULL, (gpointer*) &touch_info))
{
if (touch_info->slot_serial == serial)

View File

@ -40,6 +40,8 @@ struct _MetaWaylandTouch
struct wl_list resource_list;
uint32_t latest_touch_down_serial;
guint queued_frame_id;
GHashTable *touch_surfaces; /* HT of MetaWaylandSurface->MetaWaylandTouchSurface */
GHashTable *touches; /* HT of sequence->MetaWaylandTouchInfo */