[mutter] MetaWaylandTouch: fix running without touch hardware



commit e56f96357405b224f74bb0f43c6cde7e021dbc2c
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Wed Jul 30 15:45:18 2014 +0200

    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 files changed, 11 insertions(+), 0 deletions(-)
---
diff --git a/src/wayland/meta-wayland-touch.c b/src/wayland/meta-wayland-touch.c
index da86302..926e813 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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]