[PATCH v2 02/12] Added processing of XI grabs with confine.
Peter Hutterer
peter.hutterer at who-t.net
Thu Jun 2 19:48:50 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>
Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>
---
Changes to v1:
- add get_confine_to instead of local offset calculation wherever we need
the confine_to
Xi/xigrabdev.c | 43 ++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 42 insertions(+), 1 deletions(-)
diff --git a/Xi/xigrabdev.c b/Xi/xigrabdev.c
index 0adc878..ca72026 100644
--- a/Xi/xigrabdev.c
+++ b/Xi/xigrabdev.c
@@ -42,6 +42,32 @@
#include "exevents.h"
#include "xigrabdev.h"
+/**
+ * The confine_to window in XI2.1 trails the request. It is the first 4
+ * bytes after the fixed request + the mask bytes.
+ * Mask is in 4-byte units.
+ *
+ * @return A pointer to the 4 bytes that represent the confine_to on the
+ * wire.
+ */
+static Window*
+get_confine_to(xXIGrabDeviceReq *req)
+{
+ char *data = (char*)&req[1] + req->mask_len * 4;
+
+ return (Window*)data;
+}
+
+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 +80,10 @@ SProcXIGrabDevice(ClientPtr client)
swapl(&stuff->grab_window, n);
swapl(&stuff->cursor, n);
swapl(&stuff->time, n);
+
+ if(HasConfineTo(client) == TRUE)
+ swapl(get_confine_to(stuff), n);
+
swaps(&stuff->mask_len, n);
return ProcXIGrabDevice(client);
@@ -68,6 +98,7 @@ ProcXIGrabDevice(ClientPtr client)
uint8_t status;
GrabMask mask;
int mask_len;
+ Window confine_to;
REQUEST(xXIGrabDeviceReq);
REQUEST_AT_LEAST_SIZE(xXIGrabDeviceReq);
@@ -87,6 +118,16 @@ 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)
+ {
+ Window *wire_confine_to = get_confine_to(stuff);
+ confine_to = *wire_confine_to;
+ }
+
ret = GrabDevice(client, dev, stuff->grab_mode,
stuff->paired_device_mode,
stuff->grab_window,
@@ -95,7 +136,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