summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Xi/exevents.c44
-rw-r--r--dix/eventconvert.c60
-rw-r--r--include/dix.h7
-rw-r--r--include/eventconvert.h3
-rw-r--r--include/eventstr.h6
5 files changed, 120 insertions, 0 deletions
diff --git a/Xi/exevents.c b/Xi/exevents.c
index dd3e90ae5..c8751ce18 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -95,6 +95,7 @@ SOFTWARE.
#include "exevents.h"
#include "extnsionst.h"
#include "exglobals.h"
+#include "eventstr.h"
#include "dixevents.h" /* DeliverFocusedEvent */
#include "dixgrabs.h" /* CreateGrab() */
#include "scrnintstr.h"
@@ -168,6 +169,49 @@ IsTouchEvent(InternalEvent *event)
return FALSE;
}
+Bool
+IsGestureEvent(InternalEvent *event)
+{
+ switch (event->any.type) {
+ case ET_GesturePinchBegin:
+ case ET_GesturePinchUpdate:
+ case ET_GesturePinchEnd:
+ case ET_GestureSwipeBegin:
+ case ET_GestureSwipeUpdate:
+ case ET_GestureSwipeEnd:
+ return TRUE;
+ default:
+ break;
+ }
+ return FALSE;
+}
+
+Bool
+IsGestureBeginEvent(InternalEvent *event)
+{
+ switch (event->any.type) {
+ case ET_GesturePinchBegin:
+ case ET_GestureSwipeBegin:
+ return TRUE;
+ default:
+ break;
+ }
+ return FALSE;
+}
+
+Bool
+IsGestureEndEvent(InternalEvent *event)
+{
+ switch (event->any.type) {
+ case ET_GesturePinchEnd:
+ case ET_GestureSwipeEnd:
+ return TRUE;
+ default:
+ break;
+ }
+ return FALSE;
+}
+
/**
* @return the device matching the deviceid of the device set in the event, or
* NULL if the event is not an XInput event.
diff --git a/dix/eventconvert.c b/dix/eventconvert.c
index 4a07b6b6f..9bba2c7c5 100644
--- a/dix/eventconvert.c
+++ b/dix/eventconvert.c
@@ -969,8 +969,68 @@ GetXI2Type(enum EventType type)
case ET_BarrierLeave:
xi2type = XI_BarrierLeave;
break;
+ case ET_GesturePinchBegin:
+ xi2type = XI_GesturePinchBegin;
+ break;
+ case ET_GesturePinchUpdate:
+ xi2type = XI_GesturePinchUpdate;
+ break;
+ case ET_GesturePinchEnd:
+ xi2type = XI_GesturePinchEnd;
+ break;
+ case ET_GestureSwipeBegin:
+ xi2type = XI_GestureSwipeBegin;
+ break;
+ case ET_GestureSwipeUpdate:
+ xi2type = XI_GestureSwipeUpdate;
+ break;
+ case ET_GestureSwipeEnd:
+ xi2type = XI_GestureSwipeEnd;
+ break;
default:
break;
}
return xi2type;
}
+
+/**
+ * Converts a gesture type to corresponding Gesture{Pinch,Swipe}Begin.
+ * Returns 0 if the input type is not a gesture.
+ */
+enum EventType
+GestureTypeToBegin(enum EventType type)
+{
+ switch (type) {
+ case ET_GesturePinchBegin:
+ case ET_GesturePinchUpdate:
+ case ET_GesturePinchEnd:
+ return ET_GesturePinchBegin;
+ case ET_GestureSwipeBegin:
+ case ET_GestureSwipeUpdate:
+ case ET_GestureSwipeEnd:
+ return ET_GestureSwipeBegin;
+ default:
+ return 0;
+ }
+}
+
+/**
+ * Converts a gesture type to corresponding Gesture{Pinch,Swipe}End.
+ * Returns 0 if the input type is not a gesture.
+ */
+enum EventType
+GestureTypeToEnd(enum EventType type)
+{
+ switch (type) {
+ case ET_GesturePinchBegin:
+ case ET_GesturePinchUpdate:
+ case ET_GesturePinchEnd:
+ return ET_GesturePinchEnd;
+ case ET_GestureSwipeBegin:
+ case ET_GestureSwipeUpdate:
+ case ET_GestureSwipeEnd:
+ return ET_GestureSwipeEnd;
+ default:
+ return 0;
+ }
+}
diff --git a/include/dix.h b/include/dix.h
index ece8b6f76..07d3607f2 100644
--- a/include/dix.h
+++ b/include/dix.h
@@ -610,6 +610,13 @@ extern Bool
IsPointerEvent(InternalEvent *event);
extern Bool
IsTouchEvent(InternalEvent *event);
+Bool
+IsGestureEvent(InternalEvent *event);
+Bool
+IsGestureBeginEvent(InternalEvent *event);
+Bool
+IsGestureEndEvent(InternalEvent *event);
+
extern _X_EXPORT Bool
IsMaster(DeviceIntPtr dev);
extern _X_EXPORT Bool
diff --git a/include/eventconvert.h b/include/eventconvert.h
index 01172f0ee..cf425f7a9 100644
--- a/include/eventconvert.h
+++ b/include/eventconvert.h
@@ -36,4 +36,7 @@ _X_INTERNAL int GetCoreType(enum EventType type);
_X_INTERNAL int GetXIType(enum EventType type);
_X_INTERNAL int GetXI2Type(enum EventType type);
+_X_INTERNAL enum EventType GestureTypeToBegin(enum EventType type);
+_X_INTERNAL enum EventType GestureTypeToEnd(enum EventType type);
+
#endif /* _EVENTCONVERT_H_ */
diff --git a/include/eventstr.h b/include/eventstr.h
index bf3b95fe4..16df595d6 100644
--- a/include/eventstr.h
+++ b/include/eventstr.h
@@ -75,6 +75,12 @@ enum EventType {
ET_XQuartz,
ET_BarrierHit,
ET_BarrierLeave,
+ ET_GesturePinchBegin,
+ ET_GesturePinchUpdate,
+ ET_GesturePinchEnd,
+ ET_GestureSwipeBegin,
+ ET_GestureSwipeUpdate,
+ ET_GestureSwipeEnd,
ET_Internal = 0xFF /* First byte */
};