[mutter/wip/gestures: 12/14] backend: Use the most recent event time on replayed touch events



commit 73ae449bdedfd5bb91fb6d157a7ccb34d090614b
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Jun 19 23:16:50 2014 +0200

    backend: Use the most recent event time on replayed touch events
    
    When a touch sequence is passively grabbed and later rejected, events
    will be replayed on the next client in propagation order, although those
    events (either transformed to pointer events or not) will contain the
    original timestamps, this will make grabs fail with InvalidTime if triggered
    from the replayed ButtonPress/TouchBegin handler.
    
    In order to work around this, store the most recent event time (presumably
    gotten from the XI_TouchEnd caused by the passive grab being rejected), and
    use that time on the events being replayed afterwards, that will make grabs
    happen with a not so old timestamp.

 src/backends/x11/meta-backend-x11.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/src/backends/x11/meta-backend-x11.c b/src/backends/x11/meta-backend-x11.c
index d687c33..71d526a 100644
--- a/src/backends/x11/meta-backend-x11.c
+++ b/src/backends/x11/meta-backend-x11.c
@@ -51,6 +51,7 @@ struct _MetaBackendX11Private
   int xinput_opcode;
   int xinput_event_base;
   int xinput_error_base;
+  Time latest_evtime;
 };
 typedef struct _MetaBackendX11Private MetaBackendX11Private;
 
@@ -71,6 +72,7 @@ static void
 translate_device_event (MetaBackendX11 *x11,
                         XIDeviceEvent  *device_event)
 {
+  MetaBackendX11Private *priv = meta_backend_x11_get_instance_private (x11);
   Window stage_window = meta_backend_x11_get_xwindow (x11);
 
   if (device_event->event != stage_window)
@@ -88,6 +90,23 @@ translate_device_event (MetaBackendX11 *x11,
       device_event->event_x = device_event->root_x;
       device_event->event_y = device_event->root_y;
     }
+
+  if (!device_event->send_event && device_event->time != CurrentTime)
+    {
+      if ((device_event->flags & XIPointerEmulated) == 0)
+        {
+          /* Update the internal latest evtime, for any possible later use */
+          priv->latest_evtime = MAX (device_event->time, priv->latest_evtime);
+        }
+      else if (device_event->time < priv->latest_evtime)
+        {
+          /* Emulated pointer events received after XIRejectTouch is received
+           * on a passive touch grab will contain older timestamps, update those
+           * so we dont get InvalidTime at grabs.
+           */
+          device_event->time = priv->latest_evtime;
+        }
+    }
 }
 
 /* Clutter makes the assumption that there is only one X window


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