[PATCH 26/42] dix: add TouchGetPointerEventType helper function

Peter Hutterer peter.hutterer at who-t.net
Wed Dec 14 19:02:03 PST 2011


From: Chase Douglas <chase.douglas at canonical.com>

Returns the respective pointer event type for a given touch event type.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 dix/touch.c     |   21 +++++++++++++++++++++
 include/input.h |    1 +
 2 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/dix/touch.c b/dix/touch.c
index 90349bd..718719d 100644
--- a/dix/touch.c
+++ b/dix/touch.c
@@ -587,3 +587,24 @@ TouchEnsureSprite(DeviceIntPtr sourcedev, TouchPointInfoPtr ti,
 
     return TRUE;
 }
+
+/**
+ * Return the corresponding pointer emulation internal event type for the given
+ * touch event or 0 if no such event type exists.
+ */
+int
+TouchGetPointerEventType(const InternalEvent *event)
+{
+    int type = 0;
+
+    switch(event->any.type)
+    {
+        case ET_TouchBegin:  type = ET_ButtonPress;   break;
+        case ET_TouchUpdate: type = ET_Motion;        break;
+        case ET_TouchEnd:    type = ET_ButtonRelease; break;
+        default:
+            break;
+    }
+    return type;
+}
+
diff --git a/include/input.h b/include/input.h
index 897f1d7..74e770f 100644
--- a/include/input.h
+++ b/include/input.h
@@ -615,6 +615,7 @@ extern void TouchEventHistoryReplay(TouchPointInfoPtr ti, DeviceIntPtr dev, XID
 extern Bool TouchEnsureSprite(DeviceIntPtr sourcedev, TouchPointInfoPtr ti,
                               InternalEvent *ev);
 extern Bool TouchBuildSpriteTrace(DeviceIntPtr dev, SpritePtr sprite);
+extern int TouchGetPointerEventType(const InternalEvent *ev);
 
 /* misc event helpers */
 extern Mask GetEventMask(DeviceIntPtr dev, xEvent* ev, InputClientsPtr clients);
-- 
1.7.7.1



More information about the xorg-devel mailing list