From 9827687ca10b71100339788e2f79e364504a9e17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Mon, 12 Apr 2021 14:54:15 +0200 Subject: [PATCH] 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: --- src/wayland/meta-wayland-pointer.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/wayland/meta-wayland-pointer.c b/src/wayland/meta-wayland-pointer.c index dc8429305..3132abfd2 100644 --- a/src/wayland/meta-wayland-pointer.c +++ b/src/wayland/meta-wayland-pointer.c @@ -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)