[mutter] wayland: Only send full sequences of touch events to clients



commit 798026498d9b8a0e3de1a2a69a6b22cbcc11db0c
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Dec 21 11:30:16 2017 +0100

    wayland: Only send full sequences of touch events to clients
    
    If input happens to be grabbed somewhere along the shell, and ungrabbed
    while a touch operation is ongoing, the wayland bits will happily start
    sending wl_touch.update events from an undeterminate point, without
    clients having ever received wl_touch.down for that id.
    
    Consider those touches grabbed for the entirety of their lifetime, if
    wl_touch.down wasn't received by the client, no other events will.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=776220

 src/wayland/meta-wayland-touch.c |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)
---
diff --git a/src/wayland/meta-wayland-touch.c b/src/wayland/meta-wayland-touch.c
index 6593d7c..55b7725 100644
--- a/src/wayland/meta-wayland-touch.c
+++ b/src/wayland/meta-wayland-touch.c
@@ -56,6 +56,7 @@ struct _MetaWaylandTouchInfo
   gfloat x;
   gfloat y;
   guint updated : 1;
+  guint begin_delivered : 1;
 };
 
 static void
@@ -278,6 +279,8 @@ handle_touch_begin (MetaWaylandTouch   *touch,
                           wl_fixed_from_double (touch_info->x),
                           wl_fixed_from_double (touch_info->y));
     }
+
+  touch_info->begin_delivered = TRUE;
 }
 
 static void
@@ -292,7 +295,7 @@ handle_touch_update (MetaWaylandTouch   *touch,
   sequence = clutter_event_get_event_sequence (event);
   touch_info = touch_get_info (touch, sequence, FALSE);
 
-  if (!touch_info)
+  if (!touch_info || !touch_info->begin_delivered)
     return;
 
   l = &touch_info->touch_surface->resource_list;
@@ -321,12 +324,15 @@ handle_touch_end (MetaWaylandTouch   *touch,
   if (!touch_info)
     return;
 
-  l = &touch_info->touch_surface->resource_list;
-  wl_resource_for_each(resource, l)
+  if (touch_info->begin_delivered)
     {
-      wl_touch_send_up (resource, touch_info->slot_serial,
-                        clutter_event_get_time (event),
-                        touch_info->slot);
+      l = &touch_info->touch_surface->resource_list;
+      wl_resource_for_each(resource, l)
+        {
+          wl_touch_send_up (resource, touch_info->slot_serial,
+                            clutter_event_get_time (event),
+                            touch_info->slot);
+        }
     }
 
   g_hash_table_remove (touch->touches, sequence);


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