From e56f96357405b224f74bb0f43c6cde7e021dbc2c Mon Sep 17 00:00:00 2001 From: Giovanni Campagna Date: Wed, 30 Jul 2014 15:45:18 +0200 Subject: [PATCH] MetaWaylandTouch: fix running without touch hardware Refuse to create a touch resource if we don't have the capability (for misbehaving clients), and don't attempt to use touch data structures that are not initialized. --- src/wayland/meta-wayland-touch.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/wayland/meta-wayland-touch.c b/src/wayland/meta-wayland-touch.c index da86302ee..926e8133c 100644 --- a/src/wayland/meta-wayland-touch.c +++ b/src/wayland/meta-wayland-touch.c @@ -452,6 +452,9 @@ meta_wayland_touch_cancel (MetaWaylandTouch *touch) { GList *surfaces, *s; + if (touch->display == NULL) + return; + surfaces = s = touch_get_surfaces (touch, FALSE); for (s = surfaces; s; s = s->next) @@ -533,6 +536,7 @@ meta_wayland_touch_release (MetaWaylandTouch *touch) clutter_evdev_remove_filter (evdev_filter_func, touch); g_clear_pointer (&touch->touch_surfaces, (GDestroyNotify) g_hash_table_unref); g_clear_pointer (&touch->touches, (GDestroyNotify) g_hash_table_unref); + touch->display = NULL; } void @@ -543,6 +547,13 @@ meta_wayland_touch_create_new_resource (MetaWaylandTouch *touch, { struct wl_resource *cr; + if (touch->display == NULL) + { + wl_resource_post_error (seat_resource, WL_DISPLAY_ERROR_INVALID_METHOD, + "Cannot retrieve touch interface without touch capability"); + return; + } + cr = wl_resource_create (client, &wl_touch_interface, MIN (META_WL_TOUCH_VERSION, wl_resource_get_version (seat_resource)), id); wl_resource_set_implementation (cr, &touch_interface, touch, unbind_resource);