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

Philipp Reh sefi at s-e-f-i.de
Wed May 18 09:30:06 PDT 2011


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.
---
 Xi/xigrabdev.c              |   28 +++++++++++++++++++++++++++-
 include/protocol-versions.h |    2 +-
 2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/Xi/xigrabdev.c b/Xi/xigrabdev.c
index 0adc878..48fb6cc 100644
--- a/Xi/xigrabdev.c
+++ b/Xi/xigrabdev.c
@@ -42,10 +42,21 @@
 #include "exevents.h"
 #include "xigrabdev.h"
 
+static Bool
+ConfineSent(ClientPtr client)
+{
+    XIClientPtr pXIClient;
+    pXIClient = dixLookupPrivate(&client->devPrivates, XIClientPrivateKey);
+
+    return (pXIClient->major_version * 1000 + pXIClient->minor_version) >= 2001 ? TRUE : FALSE;
+}
+
 int
 SProcXIGrabDevice(ClientPtr client)
 {
     char n;
+    int mask_len;
+    GrabMask mask;
 
     REQUEST(xXIGrabDeviceReq);
 
@@ -54,6 +65,13 @@ SProcXIGrabDevice(ClientPtr client)
     swapl(&stuff->grab_window, n);
     swapl(&stuff->cursor, n);
     swapl(&stuff->time, n);
+
+    if(ConfineSent(client) == TRUE)
+    {
+        mask_len = min(sizeof(mask.xi2mask[0]), stuff->mask_len * 4);
+        swapl(&stuff[1] + mask_len, n);
+    }
+
     swaps(&stuff->mask_len, n);
 
     return ProcXIGrabDevice(client);
@@ -68,6 +86,7 @@ ProcXIGrabDevice(ClientPtr client)
     uint8_t status;
     GrabMask mask;
     int mask_len;
+    Window confine_to;
 
     REQUEST(xXIGrabDeviceReq);
     REQUEST_AT_LEAST_SIZE(xXIGrabDeviceReq);
@@ -87,6 +106,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(ConfineSent(client) == TRUE)
+        memcpy((unsigned char *)&confine_to, (char*)&stuff[1] + mask_len, 4);
+
     ret = GrabDevice(client, dev, stuff->grab_mode,
                      stuff->paired_device_mode,
                      stuff->grab_window,
@@ -95,7 +121,7 @@ ProcXIGrabDevice(ClientPtr client)
                      &mask,
                      GRABTYPE_XI2,
                      stuff->cursor,
-                     None /* confineTo */,
+                     confine_to,
                      &status);
 
     if (ret != Success)
diff --git a/include/protocol-versions.h b/include/protocol-versions.h
index 8692ded..f53399a 100644
--- a/include/protocol-versions.h
+++ b/include/protocol-versions.h
@@ -127,7 +127,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
-- 
1.7.5.rc3



More information about the xorg-devel mailing list