Ensure the server can safely handle client requests for wl_touch
resources that have become inert due to a weston_touch object
destruction.

This change involves, among other things, setting the weston_touch
object, instead of the weston_seat object, as the user data for wl_touch
resources. Although this is not strictly required at the moment (since
no code is using the wl_touch user data), it makes the code safer:

 * It makes more sense conceptually.
 * It is consistent with how wl_pointer resources are handled.
 * It allows us to clear the user data during weston_touch
   destruction, so other code can check whether the resource is
   inert.

Signed-off-by: Alexandros Frantzis <[email protected]>
---
 libweston/input.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/libweston/input.c b/libweston/input.c
index 96cabf25..48bcc55c 100644
--- a/libweston/input.c
+++ b/libweston/input.c
@@ -1221,8 +1221,18 @@ weston_touch_create(void)
 WL_EXPORT void
 weston_touch_destroy(struct weston_touch *touch)
 {
-       /* XXX: What about touch->resource_list? */
+       struct wl_resource *resource;
+
+       wl_resource_for_each(resource, &touch->resource_list) {
+               wl_resource_set_user_data(resource, NULL);
+       }
+
+       wl_resource_for_each(resource, &touch->focus_resource_list) {
+               wl_resource_set_user_data(resource, NULL);
+       }
 
+       wl_list_remove(&touch->resource_list);
+       wl_list_remove(&touch->focus_resource_list);
        wl_list_remove(&touch->focus_view_listener.link);
        wl_list_remove(&touch->focus_resource_listener.link);
        free(touch);
@@ -2599,7 +2609,7 @@ seat_get_touch(struct wl_client *client, struct 
wl_resource *resource,
                               wl_resource_get_link(cr));
        }
        wl_resource_set_implementation(cr, &touch_interface,
-                                      seat, unbind_resource);
+                                      touch, unbind_resource);
 }
 
 static void
-- 
2.14.1

_______________________________________________
wayland-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to