[pygobject] overrides: Add Gdk.EventTouch union discrimination



commit 17ec0d39069b7a4cc19691ea1284f821caf84d24
Author: Simon Feltman <sfeltman src gnome org>
Date:   Wed Sep 10 13:30:48 2014 -0700

    overrides: Add Gdk.EventTouch union discrimination
    
    Add EventTouch to get/setattr pass-through to support BEGIN, UPDATE, END,
    and CANCEL touch event types. Ensure Gdk.Event methods get_state(),
    get_axis(), get_coords(), and get_root_coords() are patched onto
    Gdk.EventTouch.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=736380

 gi/overrides/Gdk.py         |    5 +++++
 tests/test_overrides_gdk.py |   12 ++++++++++++
 2 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/gi/overrides/Gdk.py b/gi/overrides/Gdk.py
index 95030f8..c127550 100644
--- a/gi/overrides/Gdk.py
+++ b/gi/overrides/Gdk.py
@@ -190,6 +190,10 @@ class Event(Gdk.Event):
         Gdk.EventType.DROP_FINISHED: 'dnd',
         Gdk.EventType.CLIENT_EVENT: 'client',
         Gdk.EventType.VISIBILITY_NOTIFY: 'visibility',
+        Gdk.EventType.TOUCH_BEGIN: 'touch',
+        Gdk.EventType.TOUCH_UPDATE: 'touch',
+        Gdk.EventType.TOUCH_END: 'touch',
+        Gdk.EventType.TOUCH_CANCEL: 'touch',
     }
 
     if Gdk._version == '2.0':
@@ -228,6 +232,7 @@ event_member_classes = ['EventAny',
                         'EventVisibility',
                         'EventMotion',
                         'EventButton',
+                        'EventTouch',
                         'EventScroll',
                         'EventKey',
                         'EventCrossing',
diff --git a/tests/test_overrides_gdk.py b/tests/test_overrides_gdk.py
index 60d5ae4..da96855 100644
--- a/tests/test_overrides_gdk.py
+++ b/tests/test_overrides_gdk.py
@@ -70,6 +70,18 @@ class TestGdk(unittest.TestCase):
         event.type = Gdk.EventType.SCROLL
         self.assertRaises(AttributeError, lambda: getattr(event, 'foo_bar'))
 
+    def test_event_touch(self):
+        event = Gdk.Event.new(Gdk.EventType.TOUCH_BEGIN)
+        self.assertEqual(event.type, Gdk.EventType.TOUCH_BEGIN)
+
+        # emulating_pointer is unique to touch events
+        self.assertFalse(event.emulating_pointer)
+        self.assertFalse(event.touch.emulating_pointer)
+
+        event.emulating_pointer = True
+        self.assertTrue(event.emulating_pointer)
+        self.assertTrue(event.touch.emulating_pointer)
+
     def test_event_setattr(self):
         event = Gdk.Event.new(Gdk.EventType.DRAG_MOTION)
         event.x_root, event.y_root = 0, 5


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