From e22891346b85a7db40dec7260a100f90b451cbc8 Mon Sep 17 00:00:00 2001
From: marha <marha@users.sourceforge.net>
Date: Fri, 23 Dec 2011 10:01:52 +0100
Subject: git mesa pixman xserver xkeyboard-config update 24 dec 2011

---
 xorg-server/include/dix.h               |  7 +++
 xorg-server/include/events.h            |  1 +
 xorg-server/include/eventstr.h          | 30 +++++++++++-
 xorg-server/include/exevents.h          | 12 +++++
 xorg-server/include/input.h             | 87 ++++++++++++++++++++++++++++++++-
 xorg-server/include/inputstr.h          | 55 ++++++++++++++++++++-
 xorg-server/include/misc.h              |  4 +-
 xorg-server/include/protocol-versions.h |  2 +-
 8 files changed, 192 insertions(+), 6 deletions(-)

(limited to 'xorg-server/include')

diff --git a/xorg-server/include/dix.h b/xorg-server/include/dix.h
index 272fd4161..f3f68d39c 100644
--- a/xorg-server/include/dix.h
+++ b/xorg-server/include/dix.h
@@ -405,6 +405,12 @@ extern int DeliverOneGrabbedEvent(
     DeviceIntPtr /* dev */,
     enum InputLevel /* level */);
 
+extern void DeliverTouchEvents(
+    DeviceIntPtr /* dev */,
+    TouchPointInfoPtr /* ti */,
+    InternalEvent* /* ev */,
+    XID /* resource */);
+
 extern void InitializeSprite(
     DeviceIntPtr /* pDev */,
     WindowPtr    /* pWin */);
@@ -582,6 +588,7 @@ extern Bool DevHasCursor(DeviceIntPtr pDev);
 extern _X_EXPORT Bool IsPointerDevice(DeviceIntPtr dev);
 extern _X_EXPORT Bool IsKeyboardDevice(DeviceIntPtr dev);
 extern Bool IsPointerEvent(InternalEvent *event);
+extern Bool IsTouchEvent(InternalEvent *event);
 extern _X_EXPORT Bool IsMaster(DeviceIntPtr dev);
 extern _X_EXPORT Bool IsFloating(DeviceIntPtr dev);
 
diff --git a/xorg-server/include/events.h b/xorg-server/include/events.h
index 375173adc..222cc3d19 100644
--- a/xorg-server/include/events.h
+++ b/xorg-server/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/xorg-server/include/eventstr.h b/xorg-server/include/eventstr.h
index 4d836fb14..e4410a79f 100644
--- a/xorg-server/include/eventstr.h
+++ b/xorg-server/include/eventstr.h
@@ -50,6 +50,10 @@ enum EventType {
     ET_ButtonPress,
     ET_ButtonRelease,
     ET_Motion,
+    ET_TouchBegin,
+    ET_TouchUpdate,
+    ET_TouchEnd,
+    ET_TouchOwnership,
     ET_Enter,
     ET_Leave,
     ET_FocusIn,
@@ -64,6 +68,9 @@ enum EventType {
     ET_RawButtonPress,
     ET_RawButtonRelease,
     ET_RawMotion,
+    ET_RawTouchBegin,
+    ET_RawTouchUpdate,
+    ET_RawTouchEnd,
     ET_XQuartz,
     ET_Internal = 0xFF /* First byte */
 };
@@ -84,9 +91,11 @@ struct _DeviceEvent
     int deviceid;         /**< Device to post this event for */
     int sourceid;         /**< The physical source device */
     union {
-        uint32_t button;  /**< Button number */
+        uint32_t button;  /**< Button number (also used in pointer emulating
+                               touch events) */
         uint32_t key;     /**< Key code */
     } detail;
+    uint32_t touchid;     /**< Touch ID (client_id) */
     int16_t root_x;       /**< Pos relative to root window in integral data */
     float root_x_frac;    /**< Pos relative to root window in frac part */
     int16_t root_y;       /**< Pos relative to root window in integral part */
@@ -115,6 +124,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;       /**< ::XIAcceptTouch, ::XIRejectTouch */
+    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
@@ -230,6 +257,7 @@ union _InternalEvent {
         } any;
         DeviceEvent device_event;
         DeviceChangedEvent changed_event;
+        TouchOwnershipEvent touch_ownership_event;
 #if XFreeXDGA
         DGAEvent dga_event;
 #endif
diff --git a/xorg-server/include/exevents.h b/xorg-server/include/exevents.h
index 0ab04f525..bd1697066 100644
--- a/xorg-server/include/exevents.h
+++ b/xorg-server/include/exevents.h
@@ -221,6 +221,14 @@ GrabWindow(
 	GrabParameters*        /* param */,
 	GrabMask*              /* eventMask */);
 
+extern int
+GrabTouch(
+       ClientPtr              /* client */,
+       DeviceIntPtr           /* dev */,
+       DeviceIntPtr           /* mod_dev */,
+       GrabParameters*        /* param */,
+       GrabMask*              /* eventMask */);
+
 extern int
 SelectForWindow(
 	DeviceIntPtr           /* dev */,
@@ -245,6 +253,10 @@ InputClientGone(
 	WindowPtr              /* pWin */,
 	XID                    /* id */);
 
+extern void
+WindowGone(
+	WindowPtr              /* win */);
+
 extern int
 SendEvent (
 	ClientPtr              /* client */,
diff --git a/xorg-server/include/input.h b/xorg-server/include/input.h
index bd12f6829..fb456175a 100644
--- a/xorg-server/include/input.h
+++ b/xorg-server/include/input.h
@@ -71,6 +71,15 @@ SOFTWARE.
 #define POINTER_NORAW		(1 << 5)	/* Don't generate RawEvents */
 #define POINTER_EMULATED	(1 << 6)	/* Event was emulated from another event */
 
+/* GetTouchEvent flags */
+#define TOUCH_ACCEPT            (1 << 0)
+#define TOUCH_REJECT            (1 << 1)
+#define TOUCH_PENDING_END       (1 << 2)
+#define TOUCH_CLIENT_ID         (1 << 3)        /* touch ID is the client-visible id */
+#define TOUCH_REPLAYING         (1 << 4)        /* event is being replayed */
+#define TOUCH_POINTER_EMULATED  (1 << 5)        /* touch event may be pointer emulated */
+#define TOUCH_END               (1 << 6)        /* really end this touch now */
+
 /*int constants for pointer acceleration schemes*/
 #define PtrAccelNoOp            0
 #define PtrAccelPredictable     1
@@ -115,6 +124,9 @@ typedef struct _DeviceIntRec *DeviceIntPtr;
 typedef struct _ValuatorClassRec *ValuatorClassPtr;
 typedef struct _ClassesRec *ClassesPtr;
 typedef struct _SpriteRec *SpritePtr;
+typedef struct _TouchClassRec *TouchClassPtr;
+typedef struct _TouchPointInfo *TouchPointInfoPtr;
+typedef struct _DDXTouchPointInfo *DDXTouchPointInfoPtr;
 typedef union _GrabMask GrabMask;
 
 typedef struct _ValuatorMask ValuatorMask;
@@ -315,6 +327,12 @@ extern _X_EXPORT Bool InitPointerAccelerationScheme(
 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*/,
@@ -471,6 +489,28 @@ extern _X_EXPORT void QueueKeyboardEvents(
     int key_code,
     const ValuatorMask *mask);
 
+extern int GetTouchEvents(
+    InternalEvent *events,
+    DeviceIntPtr pDev,
+    uint32_t ddx_touchid,
+    uint16_t type,
+    uint32_t flags,
+    const ValuatorMask *mask);
+
+void QueueTouchEvents(DeviceIntPtr device,
+                      int type,
+                      uint32_t ddx_touchid,
+                      int flags,
+                      const ValuatorMask *mask);
+
+extern int GetTouchOwnershipEvents(
+    InternalEvent *events,
+    DeviceIntPtr pDev,
+    TouchPointInfoPtr ti,
+    uint8_t mode,
+    XID resource,
+    uint32_t flags);
+
 extern _X_EXPORT int GetProximityEvents(
     InternalEvent *events,
     DeviceIntPtr pDev,
@@ -540,6 +580,51 @@ extern void SendDevicePresenceEvent(int deviceid, int type);
 extern _X_EXPORT InputAttributes *DuplicateInputAttributes(InputAttributes *attrs);
 extern _X_EXPORT void FreeInputAttributes(InputAttributes *attrs);
 
+enum TouchListenerState{
+    LISTENER_AWAITING_BEGIN = 0,   /**< Waiting for a TouchBegin event */
+    LISTENER_AWAITING_OWNER,       /**< Waiting for a TouchOwnership event */
+    LISTENER_IS_OWNER,             /**< Is the current owner */
+    LISTENER_HAS_END,              /**< Has already received the end event */
+};
+
+enum TouchListenerType {
+    LISTENER_GRAB,
+    LISTENER_POINTER_GRAB,
+    LISTENER_REGULAR,
+    LISTENER_POINTER_REGULAR,
+};
+
+extern void TouchInitDDXTouchPoint(DeviceIntPtr dev, DDXTouchPointInfoPtr ddxtouch);
+extern DDXTouchPointInfoPtr TouchBeginDDXTouch(DeviceIntPtr dev, uint32_t ddx_id);
+extern void TouchEndDDXTouch(DeviceIntPtr dev, DDXTouchPointInfoPtr ti);
+extern DDXTouchPointInfoPtr TouchFindByDDXID(DeviceIntPtr dev,
+                                             uint32_t ddx_id,
+                                             Bool create);
+extern Bool TouchInitTouchPoint(TouchClassPtr touch, ValuatorClassPtr v, int index);
+extern void TouchFreeTouchPoint(DeviceIntPtr dev, int index);
+extern TouchPointInfoPtr TouchBeginTouch(DeviceIntPtr dev, int sourceid,
+                                         uint32_t touchid, Bool emulate_pointer);
+extern TouchPointInfoPtr TouchFindByClientID(DeviceIntPtr dev,
+                                             uint32_t client_id);
+extern void TouchEndTouch(DeviceIntPtr dev, TouchPointInfoPtr ti);
+extern Bool TouchEventHistoryAllocate(TouchPointInfoPtr ti);
+extern void TouchEventHistoryFree(TouchPointInfoPtr ti);
+extern void TouchEventHistoryPush(TouchPointInfoPtr ti, const DeviceEvent *ev);
+extern void TouchEventHistoryReplay(TouchPointInfoPtr ti, DeviceIntPtr dev, XID resource);
+extern Bool TouchResourceIsOwner(TouchPointInfoPtr ti, XID resource);
+extern void TouchAddListener(TouchPointInfoPtr ti, XID resource, enum InputLevel level,
+                                     enum TouchListenerType type, enum TouchListenerState state);
+extern Bool TouchRemoveListener(TouchPointInfoPtr ti, XID resource);
+extern void TouchSetupListeners(DeviceIntPtr dev, TouchPointInfoPtr ti, InternalEvent *ev);
+extern Bool TouchEnsureSprite(DeviceIntPtr sourcedev, TouchPointInfoPtr ti,
+                              InternalEvent *ev);
+extern Bool TouchBuildDependentSpriteTrace(DeviceIntPtr dev, SpritePtr sprite);
+extern int TouchConvertToPointerEvent(const InternalEvent *ev,
+                                      InternalEvent *motion, InternalEvent *button);
+extern int TouchGetPointerEventType(const InternalEvent *ev);
+extern void TouchRemovePointerGrab(DeviceIntPtr dev);
+extern void TouchListenerGone(XID resource);
+
 /* misc event helpers */
 extern Mask GetEventMask(DeviceIntPtr dev, xEvent* ev, InputClientsPtr clients);
 extern Mask GetEventFilter(DeviceIntPtr dev, xEvent *event);
@@ -553,7 +638,7 @@ void FixUpEventFromWindow(SpritePtr pSprite,
 extern WindowPtr XYToWindow(SpritePtr pSprite, int x, int y);
 extern int EventIsDeliverable(DeviceIntPtr dev, int evtype, WindowPtr win);
 extern Bool ActivatePassiveGrab(DeviceIntPtr dev, GrabPtr grab,
-                                InternalEvent *ev);
+                                InternalEvent *ev, InternalEvent *real_event);
 /**
  * Masks specifying the type of event to deliver for an InternalEvent; used
  * by EventIsDeliverable.
diff --git a/xorg-server/include/inputstr.h b/xorg-server/include/inputstr.h
index 5aae1b512..518e2f4f7 100644
--- a/xorg-server/include/inputstr.h
+++ b/xorg-server/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_RawTouchEnd
 #define XI2MASKSIZE     ((XI2LASTEVENT >> 3) + 1) /* no of bytes for masks */
 
 /**
@@ -298,6 +300,53 @@ typedef struct _ValuatorClassRec {
     int                   v_scroll_axis; /* vert smooth-scrolling axis */
 } ValuatorClassRec;
 
+typedef struct _TouchPointInfo {
+    uint32_t    client_id;          /* touch ID as seen in client events */
+    int         sourceid;           /* Source device's ID for this touchpoint */
+    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 */
+    SpriteRec   sprite;             /* window trace for delivery */
+    ValuatorMask *valuators;        /* last recorded axis values */
+    struct _TouchListener {
+        XID         listener;           /* grabs/event selection IDs receiving
+                                         * events for this touch */
+        enum TouchListenerType type;
+        enum TouchListenerState state;
+        enum InputLevel level;      /* matters only for emulating touches */
+    } *listeners;
+    int         num_listeners;
+    int         num_grabs;          /* number of open grabs on this touch
+                                     * which have not accepted or rejected */
+    Bool        emulate_pointer;
+    DeviceEvent *history;           /* History of events on this touchpoint */
+    size_t      history_elements;   /* Number of current elements in history */
+    size_t      history_size;       /* Size of history in elements */
+} TouchPointInfoRec;
+
+typedef struct _TouchListener TouchListener;
+
+typedef struct _DDXTouchPointInfo {
+    uint32_t    client_id;          /* touch ID as seen in client events */
+    Bool        active;             /* whether or not the touch is active */
+    uint32_t    ddx_id;             /* touch ID given by the DDX */
+    Bool        emulate_pointer;
+
+    ValuatorMask* valuators;        /* last recorded axis values */
+} DDXTouchPointInfoRec;
+
+typedef struct _TouchClassRec {
+    int                sourceid;
+    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 */
+    /* for pointer-emulation */
+    CARD8              buttonsDown;    /* number of buttons down */
+    unsigned short     state;          /* logical button state */
+    Mask               motionMask;
+} TouchClassRec;
+
 typedef struct _ButtonClassRec {
     int			sourceid;
     CARD8		numButtons;
@@ -381,6 +430,7 @@ typedef struct _LedFeedbackClassRec {
 typedef struct _ClassesRec {
     KeyClassPtr		key;
     ValuatorClassPtr	valuator;
+    TouchClassPtr	touch;
     ButtonClassPtr	button;
     FocusClassPtr	focus;
     ProximityClassPtr	proximity;
@@ -508,6 +558,7 @@ typedef struct _DeviceIntRec {
     int			id;
     KeyClassPtr		key;
     ValuatorClassPtr	valuator;
+    TouchClassPtr	touch;
     ButtonClassPtr	button;
     FocusClassPtr	focus;
     ProximityClassPtr	proximity;
@@ -539,6 +590,8 @@ typedef struct _DeviceIntRec {
         int             numValuators;
         DeviceIntPtr    slave;
         ValuatorMask    *scroll;
+        int             num_touches; /* size of the touches array */
+        DDXTouchPointInfoPtr touches;
     } last;
 
     /* Input device property handling. */
diff --git a/xorg-server/include/misc.h b/xorg-server/include/misc.h
index 09f928a50..3d08511ec 100644
--- a/xorg-server/include/misc.h
+++ b/xorg-server/include/misc.h
@@ -370,8 +370,8 @@ extern _X_EXPORT unsigned long serverGeneration;
               xorg_backtrace();                                           \
           } } while(0)
 
-#define BUG_WARN_MSG(cond, msg, ...)                                      \
-          __BUG_WARN_MSG(cond, 1, msg, __VA_ARGS__)
+#define BUG_WARN_MSG(cond, ...)                                           \
+          __BUG_WARN_MSG(cond, 1, __VA_ARGS__)
 
 #define BUG_WARN(cond)  __BUG_WARN_MSG(cond, 0, NULL)
 
diff --git a/xorg-server/include/protocol-versions.h b/xorg-server/include/protocol-versions.h
index 832bcf756..479ac2f77 100644
--- a/xorg-server/include/protocol-versions.h
+++ b/xorg-server/include/protocol-versions.h
@@ -127,7 +127,7 @@
 
 /* X Input */
 #define SERVER_XI_MAJOR_VERSION			2
-#define SERVER_XI_MINOR_VERSION			1
+#define SERVER_XI_MINOR_VERSION			2
 
 /* XKB */
 #define SERVER_XKB_MAJOR_VERSION		1
-- 
cgit v1.2.3