summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDaniel Stone <daniel@fooishbar.org>2010-09-20 15:03:06 +1000
committerDaniel Stone <daniel@fooishbar.org>2011-01-24 08:47:45 +1000
commit87be3c1d8ee7073285028ce07a94855d45692fc5 (patch)
treee50de25a3246d6929281a18ada72961749be78fc /include
parent9209c5810cc283f106f51a03bd579d90460d6233 (diff)
Input: Add initial multitouch support from Xi 2.1
Xi 2.1 adds TouchClasses to devices, as well as TouchBegin, TouchMotion and TouchEnd events, to allow support for multiple touchpoints on a single device. Signed-off-by: Daniel Stone <daniel@fooishbar.org> Co-authored-by: Chase Douglas <chase.douglas@canonical.com>
Diffstat (limited to 'include')
-rw-r--r--include/events.h1
-rw-r--r--include/eventstr.h25
-rw-r--r--include/exevents.h20
-rw-r--r--include/input.h37
-rw-r--r--include/inputstr.h42
-rw-r--r--include/protocol-versions.h2
6 files changed, 125 insertions, 2 deletions
diff --git a/include/events.h b/include/events.h
index 375173adc..222cc3d19 100644
--- a/include/events.h
+++ b/include/events.h
@@ -26,6 +26,7 @@
#define EVENTS_H
typedef struct _DeviceEvent DeviceEvent;
typedef struct _DeviceChangedEvent DeviceChangedEvent;
+typedef struct _TouchOwnershipEvent TouchOwnershipEvent;
#if XFreeXDGA
typedef struct _DGAEvent DGAEvent;
#endif
diff --git a/include/eventstr.h b/include/eventstr.h
index e1f5003f9..cf02efe80 100644
--- a/include/eventstr.h
+++ b/include/eventstr.h
@@ -65,6 +65,11 @@ enum EventType {
ET_RawButtonRelease,
ET_RawMotion,
ET_XQuartz,
+ ET_TouchBegin,
+ ET_TouchEnd,
+ ET_TouchMotion,
+ ET_TouchMotionUnowned,
+ ET_TouchOwnership,
ET_Internal = 0xFF /* First byte */
};
@@ -90,6 +95,7 @@ struct _DeviceEvent
union {
uint32_t button; /**< Button number */
uint32_t key; /**< Key code */
+ uint32_t touch; /**< Touch ID (client_id) */
} detail;
int16_t root_x; /**< Pos relative to root window in integral data */
float root_x_frac; /**< Pos relative to root window in frac part */
@@ -120,6 +126,24 @@ struct _DeviceEvent
uint32_t flags; /**< Flags to be copied into the generated event */
};
+/**
+ * Generated internally whenever a touch ownership chain changes - an owner
+ * has accepted or rejected a touch, or a grab/event selection in the delivery
+ * chain has been removed.
+ */
+struct _TouchOwnershipEvent
+{
+ unsigned char header; /**< Always ET_Internal */
+ enum EventType type; /**< One of EventType */
+ int length; /**< Length in bytes */
+ Time time; /**< Time in ms */
+ int deviceid; /**< Device to post this event for */
+ int sourceid; /**< The physical source device */
+ uint32_t touchid; /**< Touch ID (client_id) */
+ uint8_t reason; /**< ::XITouchOwnerAccepted, ::XITouchOwnerRejected */
+ uint32_t resource; /**< Provoking grab or event selection */
+ uint32_t flags; /**< Flags to be copied into the generated event */
+};
/* Flags used in DeviceChangedEvent to signal if the slave has changed */
#define DEVCHANGE_SLAVE_SWITCH 0x2
@@ -235,6 +259,7 @@ union _InternalEvent {
} any;
DeviceEvent device_event;
DeviceChangedEvent changed_event;
+ TouchOwnershipEvent touch_ownership_event;
#if XFreeXDGA
DGAEvent dga_event;
#endif
diff --git a/include/exevents.h b/include/exevents.h
index dc594304f..32a3962a7 100644
--- a/include/exevents.h
+++ b/include/exevents.h
@@ -51,6 +51,14 @@ extern _X_EXPORT void InitValuatorAxisStruct(
int /* max_res */,
int /* mode */);
+extern _X_EXPORT void InitTouchValuatorAxisStruct(
+ DeviceIntPtr /* dev */,
+ int /* axnum */,
+ Atom /* label */,
+ int /* minval */,
+ int /* maxval */,
+ int /* resolution */);
+
/* Input device properties */
extern _X_EXPORT void XIDeleteAllDeviceProperties(
DeviceIntPtr /* device */
@@ -199,6 +207,14 @@ GrabWindow(
GrabMask* /* eventMask */);
extern int
+GrabTouch(
+ ClientPtr /* client */,
+ DeviceIntPtr /* dev */,
+ DeviceIntPtr /* mod_dev */,
+ GrabParameters* /* param */,
+ GrabMask* /* eventMask */);
+
+extern int
SelectForWindow(
DeviceIntPtr /* dev */,
WindowPtr /* pWin */,
@@ -222,6 +238,10 @@ InputClientGone(
WindowPtr /* pWin */,
XID /* id */);
+extern void
+WindowGone(
+ WindowPtr /* win */);
+
extern int
SendEvent (
ClientPtr /* client */,
diff --git a/include/input.h b/include/input.h
index f96a0a988..60cf714fd 100644
--- a/include/input.h
+++ b/include/input.h
@@ -104,6 +104,8 @@ typedef struct _InputClients *InputClientsPtr;
typedef struct _DeviceIntRec *DeviceIntPtr;
typedef struct _ClassesRec *ClassesPtr;
typedef struct _SpriteRec *SpritePtr;
+typedef struct _TouchClassRec *TouchClassPtr;
+typedef struct _TouchPointInfo *TouchPointInfoPtr;
typedef union _GrabMask GrabMask;
typedef struct _EventList {
@@ -314,6 +316,12 @@ extern _X_EXPORT Bool InitAbsoluteClassDeviceStruct(
extern _X_EXPORT Bool InitFocusClassDeviceStruct(
DeviceIntPtr /*device*/);
+extern _X_EXPORT Bool InitTouchClassDeviceStruct(
+ DeviceIntPtr /*device*/,
+ unsigned int /*max_touches*/,
+ unsigned int /*mode*/,
+ unsigned int /*numAxes*/);
+
typedef void (*BellProcPtr)(
int /*percent*/,
DeviceIntPtr /*device*/,
@@ -463,6 +471,22 @@ extern int GetKeyboardValuatorEvents(
int key_code,
const ValuatorMask *mask);
+extern int GetTouchEvents(
+ EventListPtr events,
+ DeviceIntPtr pDev,
+ TouchPointInfoPtr ti,
+ uint16_t type,
+ uint32_t flags,
+ const ValuatorMask *mask);
+
+extern int GetTouchOwnershipEvents(
+ EventListPtr events,
+ DeviceIntPtr pDev,
+ TouchPointInfoPtr ti,
+ uint8_t mode,
+ XID resource,
+ uint32_t flags);
+
extern int GetProximityEvents(
EventListPtr events,
DeviceIntPtr pDev,
@@ -525,6 +549,19 @@ extern void SendDevicePresenceEvent(int deviceid, int type);
extern _X_EXPORT InputAttributes *DuplicateInputAttributes(InputAttributes *attrs);
extern _X_EXPORT void FreeInputAttributes(InputAttributes *attrs);
+/* DDX touch API: create with CreateTouchPoint, use its returned ID to lookup
+ * with FindTouchPoint, and eventually end with FinishTouchPoint. */
+extern TouchPointInfoPtr BeginTouchPoint(DeviceIntPtr dev, uint32_t ddx_id);
+extern TouchPointInfoPtr FindTouchPointByDDXID(DeviceIntPtr dev,
+ uint32_t ddx_id);
+extern TouchPointInfoPtr FindTouchPointByClientID(DeviceIntPtr dev,
+ uint32_t client_id);
+extern void EndTouchPoint(DeviceIntPtr dev, TouchPointInfoPtr ti);
+/* Internal use only, DDX this is not for you */
+extern Bool InitTouchPoint(TouchClassPtr touch, int index);
+extern void FreeTouchPoint(DeviceIntPtr dev, int index);
+extern void TouchListenerGone(XID resource);
+
/* misc event helpers */
extern Mask GetEventMask(DeviceIntPtr dev, xEvent* ev, InputClientsPtr clients);
extern Mask GetEventFilter(DeviceIntPtr dev, xEvent *event);
diff --git a/include/inputstr.h b/include/inputstr.h
index a19b9a9d8..3d86b34e0 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -49,6 +49,8 @@ SOFTWARE.
#ifndef INPUTSTRUCT_H
#define INPUTSTRUCT_H
+#include <X11/extensions/XI2proto.h>
+
#include <pixman.h>
#include "input.h"
#include "window.h"
@@ -71,7 +73,7 @@ extern _X_EXPORT int CountBits(const uint8_t *mask, int len);
* events to the protocol, the server will not support these events until
* this number here is bumped.
*/
-#define XI2LASTEVENT 17 /* XI_RawMotion */
+#define XI2LASTEVENT XI_TouchMotionUnowned
#define XI2MASKSIZE ((XI2LASTEVENT + 7)/8) /* no of bits for masks */
/**
@@ -287,6 +289,42 @@ typedef struct _ValuatorClassRec {
ValuatorAccelerationRec accelScheme;
} ValuatorClassRec, *ValuatorClassPtr;
+typedef struct _TouchPointInfo {
+ Bool active; /* whether or not the touch is active */
+ Bool pending_finish; /* true if the touch is physically inactive
+ * but still owned by a grab */
+ uint32_t client_id; /* touch ID as seen in client events */
+ uint32_t ddx_id; /* touch ID given by the DDX */
+ SpriteRec sprite; /* window trace for delivery */
+ int *valuators; /* last recorded axis values */
+ int num_valuators; /* == TouchClassInfo::num_axes */
+ XID *listeners; /* grabs/event selection IDs receiving
+ * events for this touch */
+ int num_listeners;
+ int num_grabs; /* number of open grabs on this touch
+ * which have not accepted or rejected */
+ Bool emulate_pointer;
+} TouchPointInfoRec;
+
+typedef struct _TouchAxisInfo {
+ int resolution;
+ int min_value;
+ int max_value;
+ Atom label;
+} TouchAxisInfoRec, *TouchAxisInfoPtr;
+
+typedef struct _TouchClassRec {
+ TouchAxisInfoPtr axes;
+ unsigned short num_axes;
+ TouchPointInfoPtr touches;
+ unsigned short num_touches; /* number of allocated touches */
+ unsigned short max_touches; /* maximum number of touches, may be 0 */
+ CARD8 mode; /* ::XIDirectTouch, XIDependentTouch */
+ uint32_t next_client_id; /* next client_id to give out */
+ int x_axis; /* axis number of x axis */
+ int y_axis; /* axis number of y axis */
+} TouchClassRec;
+
typedef struct _ButtonClassRec {
int sourceid;
CARD8 numButtons;
@@ -391,6 +429,7 @@ typedef struct _LedFeedbackClassRec {
typedef struct _ClassesRec {
KeyClassPtr key;
ValuatorClassPtr valuator;
+ TouchClassPtr touch;
ButtonClassPtr button;
FocusClassPtr focus;
ProximityClassPtr proximity;
@@ -515,6 +554,7 @@ typedef struct _DeviceIntRec {
int id;
KeyClassPtr key;
ValuatorClassPtr valuator;
+ TouchClassPtr touch;
ButtonClassPtr button;
FocusClassPtr focus;
ProximityClassPtr proximity;
diff --git a/include/protocol-versions.h b/include/protocol-versions.h
index c8c7f5fc0..42b7d0eb7 100644
--- a/include/protocol-versions.h
+++ b/include/protocol-versions.h
@@ -131,7 +131,7 @@
/* X Input */
#define SERVER_XI_MAJOR_VERSION 2
-#define SERVER_XI_MINOR_VERSION 0
+#define SERVER_XI_MINOR_VERSION 1
/* XKB */
#define SERVER_XKB_MAJOR_VERSION 1