[gtk+/multitouch-for-3.4: 86/89] gdk: Don't mutate pointer events to touch events just because a grab says so



commit a2d6a173413997dccb3f03a20cee45638019e6ee
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Feb 21 11:22:49 2012 +0100

    gdk: Don't mutate pointer events to touch events just because a grab says so
    
    If a grab with GDK_TOUCH_MASK kicks in due to a touch sequence emulating pointer
    events, don't mutate the sequence into emitting touch events right away.

 gdk/gdkwindow.c |   36 ++++++++++++++++++++++++++++++++----
 1 files changed, 32 insertions(+), 4 deletions(-)
---
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index 1051423..4f2ca0d 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -9372,12 +9372,23 @@ proxy_pointer_event (GdkDisplay                 *display,
                                     &evmask,
                                     serial);
 
-      if ((evmask & GDK_TOUCH_MASK) == 0 &&
-          source_event->type == GDK_TOUCH_MOTION)
+      if (source_event->type == GDK_TOUCH_MOTION)
         {
           if (_gdk_event_get_pointer_emulated (source_event))
-            source_event->type = GDK_MOTION_NOTIFY;
-          else
+            {
+              /* Touch events emulating pointer events are transformed back
+               * to pointer events if:
+               * 1 - The event window doesn't select for touch events
+               * 2 - There's no touch grab for this sequence, which means
+               *     it was started as a pointer sequence, but a device
+               *     grab added touch events afterwards, the sequence must
+               *     not mutate in this case.
+               */
+              if ((evmask & GDK_TOUCH_MASK) == 0 ||
+                  !_gdk_display_has_touch_grab (display, device, touch_id, serial))
+                source_event->type = GDK_MOTION_NOTIFY;
+            }
+          else if ((evmask & GDK_TOUCH_MASK) == 0)
             return TRUE;
         }
 
@@ -9578,6 +9589,23 @@ proxy_button_event (GdkEvent *source_event,
                                 type, state,
                                 &evmask, serial);
 
+  if (type == GDK_TOUCH_PRESS || type == GDK_TOUCH_RELEASE)
+    {
+      if (_gdk_event_get_pointer_emulated (source_event))
+        {
+          if ((evmask & GDK_TOUCH_MASK) == 0 ||
+              !_gdk_display_has_touch_grab (display, device, touch_id, serial))
+            {
+              if (type == GDK_TOUCH_PRESS)
+                source_event->type = type = GDK_BUTTON_PRESS;
+              else if (type == GDK_TOUCH_RELEASE)
+                source_event->type = type = GDK_BUTTON_RELEASE;
+            }
+        }
+      else if ((evmask & GDK_TOUCH_MASK) == 0)
+        return TRUE;
+    }
+
   if ((evmask & GDK_TOUCH_MASK) == 0 &&
       (type == GDK_TOUCH_PRESS || type == GDK_TOUCH_RELEASE))
     {



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