[PATCH 14/29] barriers: Send an XI_BarrierLeave event when a barrier is destroyed

Peter Hutterer peter.hutterer at who-t.net
Tue Dec 11 23:19:07 PST 2012


From: "Jasper St. Pierre" <jstpierre at mecheye.net>

This ensures that we always complete an event sequence.

Signed-off-by: Jasper St. Pierre <jstpierre at mecheye.net>
---
 Xi/xibarriers.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/Xi/xibarriers.c b/Xi/xibarriers.c
index b62a18e..2e7f2cc 100644
--- a/Xi/xibarriers.c
+++ b/Xi/xibarriers.c
@@ -539,8 +539,52 @@ static int
 BarrierFreeBarrier(void *data, XID id)
 {
     struct PointerBarrierClient *c;
+    Time ms = GetTimeInMillis();
 
     c = container_of(data, struct PointerBarrierClient, barrier);
+
+    /* FIXME: this is really broken for multidevice */
+    if (c->hit) {
+        DeviceIntPtr dev = NULL;
+        ScreenPtr screen = c->screen;
+        BarrierEvent ev = {
+            .header = ET_Internal,
+            .type = ET_BarrierLeave,
+            .length = sizeof (BarrierEvent),
+            .time = ms,
+            /* .deviceid */
+            .sourceid = 0,
+            .barrierid = c->id,
+            .window = c->window->drawable.id,
+            .root = screen->root->drawable.id,
+            .dx = 0,
+            .dy = 0,
+            /* .root_x */
+            /* .root_y */
+            .dt = ms - c->last_timestamp,
+            .event_id = c->barrier_event_id,
+            .flags = XIBarrierPointerReleased,
+        };
+
+        for (dev = inputInfo.devices; dev; dev = dev->next) {
+            int root_x, root_y;
+
+            if (dev->type != MASTER_POINTER)
+                continue;
+
+            if (!barrier_blocks_device(c, dev))
+                continue;
+
+            ev.deviceid = dev->id;
+
+            GetSpritePosition(dev, &root_x, &root_y);
+            ev.root_x = root_x;
+            ev.root_y = root_y;
+
+            mieqEnqueue(dev, (InternalEvent *) &ev);
+        }
+    }
+
     xorg_list_del(&c->entry);
 
     free(c);
-- 
1.8.0.1



More information about the xorg-devel mailing list