[PATCH xserver 02/12] Added processing of XI grabs with confine.

Peter Hutterer peter.hutterer at who-t.net
Thu Jun 2 00:13:36 PDT 2011


From: Philipp Reh <sefi at s-e-f-i.de>

Version 2.1 of XI sends a confine_to parameter
right after the mask. The server checks if the client
has version 2.1 or later to see if it has to read the
additional value.

Signed-off-by: Philipp Reh <sefi at s-e-f-i.de>
Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 Xi/xigrabdev.c |   24 +++++++++++++++++++++++-
 1 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/Xi/xigrabdev.c b/Xi/xigrabdev.c
index 0adc878..5c9847d 100644
--- a/Xi/xigrabdev.c
+++ b/Xi/xigrabdev.c
@@ -42,6 +42,16 @@
 #include "exevents.h"
 #include "xigrabdev.h"
 
+static Bool
+HasConfineTo(ClientPtr client)
+{
+    XIClientPtr pXIClient;
+    pXIClient = dixLookupPrivate(&client->devPrivates, XIClientPrivateKey);
+
+    return version_compare(pXIClient->major_version, pXIClient->minor_version,
+                           2, 1) >= 0 ? TRUE : FALSE;
+}
+
 int
 SProcXIGrabDevice(ClientPtr client)
 {
@@ -54,6 +64,10 @@ SProcXIGrabDevice(ClientPtr client)
     swapl(&stuff->grab_window, n);
     swapl(&stuff->cursor, n);
     swapl(&stuff->time, n);
+
+    if(HasConfineTo(client) == TRUE)
+        swapl(&stuff[1] + stuff->mask_len * 4, n);
+
     swaps(&stuff->mask_len, n);
 
     return ProcXIGrabDevice(client);
@@ -68,6 +82,7 @@ ProcXIGrabDevice(ClientPtr client)
     uint8_t status;
     GrabMask mask;
     int mask_len;
+    Window confine_to;
 
     REQUEST(xXIGrabDeviceReq);
     REQUEST_AT_LEAST_SIZE(xXIGrabDeviceReq);
@@ -87,6 +102,13 @@ ProcXIGrabDevice(ClientPtr client)
     memset(mask.xi2mask, 0, sizeof(mask.xi2mask));
     memcpy(mask.xi2mask, (char*)&stuff[1], mask_len);
 
+    /* If the client has version 2_1 or higher, it will send the confine_to window
+     * at the end of the request (after the mask).*/
+    confine_to = None;
+
+    if(HasConfineTo(client) == TRUE)
+        memcpy((unsigned char *)&confine_to, (char*)&stuff[1] + stuff->mask_len * 4, 4);
+
     ret = GrabDevice(client, dev, stuff->grab_mode,
                      stuff->paired_device_mode,
                      stuff->grab_window,
@@ -95,7 +117,7 @@ ProcXIGrabDevice(ClientPtr client)
                      &mask,
                      GRABTYPE_XI2,
                      stuff->cursor,
-                     None /* confineTo */,
+                     confine_to,
                      &status);
 
     if (ret != Success)
-- 
1.7.5.1



More information about the xorg-devel mailing list