[PATCH v2 11/42] Hook up the ownership events

Peter Hutterer peter.hutterer at who-t.net
Sun Dec 18 15:10:50 PST 2011


This patch applies most of the protocol conversions and the internal event
type for ownership events.

Note that ownership events are generated by the DIX only, they do not pass
through the event queue.

Co-authored-by: Daniel Stone <daniel at fooishbar.org>
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
Changes to v1:
- swap root, event, child in STouchOwnershipEvent

(this time with the right In-Reply-To set)

 Xi/extinit.c       |   20 ++++++++++++++++++++
 dix/eventconvert.c |   27 +++++++++++++++++++++++++++
 dix/events.c       |    7 +++++++
 include/events.h   |    1 +
 include/eventstr.h |   20 ++++++++++++++++++++
 mi/mieq.c          |    3 +++
 6 files changed, 78 insertions(+), 0 deletions(-)

diff --git a/Xi/extinit.c b/Xi/extinit.c
index 0b7bc34..a81c8f1 100644
--- a/Xi/extinit.c
+++ b/Xi/extinit.c
@@ -829,6 +829,22 @@ static void SRawEvent(xXIRawEvent *from, xXIRawEvent *to)
     swaps(&to->valuators_len);
 }
 
+static void STouchOwnershipEvent(xXITouchOwnershipEvent *from,
+                                 xXITouchOwnershipEvent *to)
+{
+    *to = *from;
+    swaps(&to->sequenceNumber);
+    swapl(&to->length);
+    swaps(&to->evtype);
+    swaps(&to->deviceid);
+    swapl(&to->time);
+    swaps(&to->sourceid);
+    swapl(&to->touchid);
+    swapl(&to->flags);
+    swapl(&to->root);
+    swapl(&to->event);
+    swapl(&to->child);
+}
 
 /** Event swapping function for XI2 events. */
 void
@@ -863,6 +879,10 @@ XI2EventSwap(xGenericEvent *from, xGenericEvent *to)
         case XI_TouchEnd:
             SDeviceEvent((xXIDeviceEvent*)from, (xXIDeviceEvent*)to);
             break;
+        case XI_TouchOwnership:
+            STouchOwnershipEvent((xXITouchOwnershipEvent*)from,
+                                 (xXITouchOwnershipEvent*)to);
+            break;
         case XI_RawMotion:
         case XI_RawKeyPress:
         case XI_RawKeyRelease:
diff --git a/dix/eventconvert.c b/dix/eventconvert.c
index 582769a..017c871 100644
--- a/dix/eventconvert.c
+++ b/dix/eventconvert.c
@@ -58,6 +58,7 @@ static int eventToKeyButtonPointer(DeviceEvent *ev, xEvent **xi, int *count);
 static int eventToDeviceChanged(DeviceChangedEvent *ev, xEvent **dcce);
 static int eventToDeviceEvent(DeviceEvent *ev, xEvent **xi);
 static int eventToRawEvent(RawDeviceEvent *ev, xEvent **xi);
+static int eventToTouchOwnershipEvent(TouchOwnershipEvent *ev, xEvent **xi);
 
 /* Do not use, read comments below */
 BOOL EventIsKeyRepeat(xEvent *event);
@@ -164,6 +165,7 @@ EventToCore(InternalEvent *event, xEvent **core_out, int *count_out)
         case ET_TouchBegin:
         case ET_TouchUpdate:
         case ET_TouchEnd:
+        case ET_TouchOwnership:
             ret = BadMatch;
             break;
         default:
@@ -220,6 +222,7 @@ EventToXI(InternalEvent *ev, xEvent **xi, int *count)
         case ET_TouchBegin:
         case ET_TouchUpdate:
         case ET_TouchEnd:
+        case ET_TouchOwnership:
             *count = 0;
             *xi = NULL;
             return BadMatch;
@@ -265,6 +268,8 @@ EventToXI2(InternalEvent *ev, xEvent **xi)
         case ET_TouchUpdate:
         case ET_TouchEnd:
             return eventToDeviceEvent(&ev->device_event, xi);
+        case ET_TouchOwnership:
+            return eventToTouchOwnershipEvent(&ev->touch_ownership_event, xi);
         case ET_ProximityIn:
         case ET_ProximityOut:
             *xi = NULL;
@@ -722,6 +727,27 @@ eventToDeviceEvent(DeviceEvent *ev, xEvent **xi)
 }
 
 static int
+eventToTouchOwnershipEvent(TouchOwnershipEvent *ev, xEvent **xi)
+{
+    int len = sizeof(xXITouchOwnershipEvent);
+    xXITouchOwnershipEvent *xtoe;
+
+    *xi = calloc(1, len);
+    xtoe = (xXITouchOwnershipEvent*)*xi;
+    xtoe->type          = GenericEvent;
+    xtoe->extension     = IReqCode;
+    xtoe->length        = bytes_to_int32(len - sizeof(xEvent));
+    xtoe->evtype        = GetXI2Type(ev->type);
+    xtoe->deviceid      = ev->deviceid;
+    xtoe->time          = ev->time;
+    xtoe->sourceid      = ev->sourceid;
+    xtoe->touchid       = ev->touchid;
+    xtoe->flags         = 0; /* we don't have wire flags for ownership yet */
+
+    return Success;
+}
+
+static int
 eventToRawEvent(RawDeviceEvent *ev, xEvent **xi)
 {
     xXIRawEvent* raw;
@@ -844,6 +870,7 @@ GetXI2Type(enum EventType type)
         case ET_TouchBegin:     xi2type = XI_TouchBegin;       break;
         case ET_TouchEnd:       xi2type = XI_TouchEnd;         break;
         case ET_TouchUpdate:    xi2type = XI_TouchUpdate;      break;
+        case ET_TouchOwnership: xi2type = XI_TouchOwnership;   break;
         default:
             break;
     }
diff --git a/dix/events.c b/dix/events.c
index f80b8fd..f8ea94f 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -2476,6 +2476,13 @@ FixUpEventFromWindow(
 
         event->root = RootWindow(pSprite)->drawable.id;
         event->event = pWin->drawable.id;
+
+        if (evtype == XI_TouchOwnership)
+        {
+            event->child = child;
+            return;
+        }
+
         if (pSprite->hot.pScreen == pWin->drawable.pScreen)
         {
             event->event_x = event->root_x - FP1616(pWin->drawable.x, 0);
diff --git a/include/events.h b/include/events.h
index 375173a..222cc3d 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 3323073..e4410a7 100644
--- a/include/eventstr.h
+++ b/include/eventstr.h
@@ -53,6 +53,7 @@ enum EventType {
     ET_TouchBegin,
     ET_TouchUpdate,
     ET_TouchEnd,
+    ET_TouchOwnership,
     ET_Enter,
     ET_Leave,
     ET_FocusIn,
@@ -123,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
@@ -238,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/mi/mieq.c b/mi/mieq.c
index 8335289..ea8bcf0 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -375,6 +375,9 @@ ChangeDeviceID(DeviceIntPtr dev, InternalEvent* event)
         case ET_TouchEnd:
             event->device_event.deviceid = dev->id;
             break;
+        case ET_TouchOwnership:
+            event->touch_ownership_event.deviceid = dev->id;
+            break;
 #if XFreeXDGA
         case ET_DGAEvent:
             break;
-- 
1.7.7.1

Cheers,
  Peter


More information about the xorg-devel mailing list