[PATCH v3 3/12] Xi: Add support for confine_to on XI 2.1 XIPassiveGrab requests.
Peter Hutterer
peter.hutterer at who-t.net
Mon Jun 6 16:13:21 PDT 2011
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>
---
Changes to v2:
- rename HasConfineTo to XI2ClientSendsConfineTo() to avoid too much
ambiguity. this also required the obvious fix to 2/12.
- extra space removed from get_confine_to
On Mon, Jun 06, 2011 at 02:34:20PM +0100, Daniel Stone wrote:
> >
> > +get_confine_to(const xXIPassiveGrabDeviceReq *req)
>
> Disambiguating this name would be pretty keen as well, since we now have
> two get_confine_tos. Also, there's an extraneous space in the return
> statement.
I think we should be fine here. both get_confine_to are static and local to
the file and take a typed request pointer that should make it obvious which
request to pass in.
Xi/xigrabdev.c | 2 +-
Xi/xigrabdev.h | 2 ++
Xi/xipassivegrab.c | 40 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 43 insertions(+), 1 deletions(-)
diff --git a/Xi/xigrabdev.c b/Xi/xigrabdev.c
index 8b394c9..4bf68f2 100644
--- a/Xi/xigrabdev.c
+++ b/Xi/xigrabdev.c
@@ -58,7 +58,7 @@ get_confine_to(xXIGrabDeviceReq *req)
return (Window*)data;
}
-static Bool
+Bool
XI2ClientSendsConfineTo(ClientPtr client)
{
XIClientPtr pXIClient;
diff --git a/Xi/xigrabdev.h b/Xi/xigrabdev.h
index 08309c9..d4eb9cf 100644
--- a/Xi/xigrabdev.h
+++ b/Xi/xigrabdev.h
@@ -38,4 +38,6 @@ int SProcXIUngrabDevice(ClientPtr client);
void SRepXIGrabDevice(ClientPtr client, int size, xXIGrabDeviceReply * rep);
+Bool XI2ClientSendsConfineTo(ClientPtr client);
+
#endif /* XIGRABDEV_H */
diff --git a/Xi/xipassivegrab.c b/Xi/xipassivegrab.c
index ae43433..a18a169 100644
--- a/Xi/xipassivegrab.c
+++ b/Xi/xipassivegrab.c
@@ -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;
--
1.7.5.1
More information about the xorg-devel
mailing list