@@ -58,7 +58,7 @@ get_confine_to(xXIGrabDeviceReq *req)
return (Window*)data;
}
-static Bool
+Bool
XI2ClientSendsConfineTo(ClientPtr client)
{
XIClientPtr pXIClient;
@@ -38,4 +38,6 @@ int SProcXIUngrabDevice(ClientPtr client);
void SRepXIGrabDevice(ClientPtr client, int size, xXIGrabDeviceReply * rep);
+Bool XI2ClientSendsConfineTo(ClientPtr client);
+
#endif /* XIGRABDEV_H */
@@ -45,6 +45,23 @@
#include "dixgrabs.h"
#include "misc.h"
+#include "xigrabdev.h" /* HasConfineTo */
+
+/**
+ * The confine_to window in XI2.1 trails the request. It is the first 4
+ * bytes after the fixed request + the mask bytes + modifier bytes.
+ * Mask and modifiers are both in 4-byte units.
+ *
+ * @return A pointer to the 4 bytes that represent the confine_to on the
+ * wire.
+ */
+static Window*
+get_confine_to(const xXIPassiveGrabDeviceReq *req)
+{
+ char *data = (char*)&req[1] + req->mask_len * 4 + req->num_modifiers * 4;
+ return (Window*)data;
+}
+
int
SProcXIPassiveGrabDevice(ClientPtr client)
{
@@ -60,6 +77,10 @@ SProcXIPassiveGrabDevice(ClientPtr client)
swapl(&stuff->cursor, n);
swapl(&stuff->time, n);
swapl(&stuff->detail, n);
+
+ if(XI2ClientSendsConfineTo(client) == TRUE)
+ swapl(get_confine_to(stuff), n);
+
swaps(&stuff->mask_len, n);
swaps(&stuff->num_modifiers, n);
@@ -89,6 +110,7 @@ ProcXIPassiveGrabDevice(ClientPtr client)
void *tmp;
int mask_len;
int n;
+ Window confine_to;
REQUEST(xXIPassiveGrabDeviceReq);
REQUEST_AT_LEAST_SIZE(xXIPassiveGrabDeviceReq);
@@ -160,6 +182,24 @@ ProcXIPassiveGrabDevice(ClientPtr client)
if (status != Success)
return status;
+ /* If the client has version 2_1 or higher, it will send the confine_to window
+ * at the end of the request */
+ confine_to = None;
+
+ if(XI2ClientSendsConfineTo(client) == TRUE) {
+ Window *wire_confine_to = get_confine_to(stuff);
+ confine_to = *wire_confine_to;
+ }
+
+ if (confine_to != None)
+ {
+ status = dixLookupWindow((WindowPtr*)&tmp, confine_to, client, DixSetAttrAccess);
+ if (status != Success)
+ return status;
+ }
+
+ param.confineTo = confine_to;
+
status = CheckGrabValues(client, ¶m);
if (status != Success)
return status;