wayland/seat: Unset resource user data when disabling

We make objects inert when disabling the seat, but we requests may still
have effect. This is especially bad if disabling is followed by
destroying, but also means e.g. set_cursor() not doing an early out
after the pointer capability was disabled.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
This commit is contained in:
Jonas Ådahl 2021-04-12 14:54:15 +02:00 committed by Marge Bot
parent 8303752e32
commit 9827687ca1

View File

@ -121,21 +121,25 @@ meta_wayland_pointer_client_free (MetaWaylandPointerClient *pointer_client)
{
wl_list_remove (wl_resource_get_link (resource));
wl_list_init (wl_resource_get_link (resource));
wl_resource_set_user_data (resource, NULL);
}
wl_resource_for_each_safe (resource, next, &pointer_client->swipe_gesture_resources)
{
wl_list_remove (wl_resource_get_link (resource));
wl_list_init (wl_resource_get_link (resource));
wl_resource_set_user_data (resource, NULL);
}
wl_resource_for_each_safe (resource, next, &pointer_client->pinch_gesture_resources)
{
wl_list_remove (wl_resource_get_link (resource));
wl_list_init (wl_resource_get_link (resource));
wl_resource_set_user_data (resource, NULL);
}
wl_resource_for_each_safe (resource, next, &pointer_client->relative_pointer_resources)
{
wl_list_remove (wl_resource_get_link (resource));
wl_list_init (wl_resource_get_link (resource));
wl_resource_set_user_data (resource, NULL);
}
g_free (pointer_client);
@ -200,6 +204,10 @@ meta_wayland_pointer_unbind_pointer_client_resource (struct wl_resource *resourc
MetaWaylandPointerClient *pointer_client;
struct wl_client *client = wl_resource_get_client (resource);
pointer = wl_resource_get_user_data (resource);
if (!pointer)
return;
wl_list_remove (wl_resource_get_link (resource));
pointer_client = meta_wayland_pointer_get_pointer_client (pointer, client);
@ -1105,9 +1113,13 @@ pointer_set_cursor (struct wl_client *client,
struct wl_resource *surface_resource,
int32_t hot_x, int32_t hot_y)
{
MetaWaylandPointer *pointer = wl_resource_get_user_data (resource);
MetaWaylandPointer *pointer;
MetaWaylandSurface *surface;
pointer = wl_resource_get_user_data (resource);
if (!pointer)
return;
surface = (surface_resource ? wl_resource_get_user_data (surface_resource) : NULL);
if (pointer->focus_surface == NULL)