[PATCH xserver 03/12] Xi: Add support for confine_to on XI 2.1 XIPassiveGrab requests.

Jeremy Huddleston jeremyhu at apple.com
Thu Jun 2 10:07:59 PDT 2011


"&stuff[1] + stuff->mask_len * 4 + stuff->num_modifiers * 4" is rather grotesque, IMO ... can that be cleaned up a bit?  Even having an extra variable properly named with a comment explaining that it's referencing the XI2 confine window would be better than just dropping that bomb in place.

On Jun 2, 2011, at 12:13 AM, Peter Hutterer wrote:

> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
> Xi/xigrabdev.c     |    2 +-
> Xi/xigrabdev.h     |    2 ++
> Xi/xipassivegrab.c |   21 +++++++++++++++++++++
> 3 files changed, 24 insertions(+), 1 deletions(-)
> 
> diff --git a/Xi/xigrabdev.c b/Xi/xigrabdev.c
> index 5c9847d..1056073 100644
> --- a/Xi/xigrabdev.c
> +++ b/Xi/xigrabdev.c
> @@ -42,7 +42,7 @@
> #include "exevents.h"
> #include "xigrabdev.h"
> 
> -static Bool
> +Bool
> HasConfineTo(ClientPtr client)
> {
>     XIClientPtr pXIClient;
> diff --git a/Xi/xigrabdev.h b/Xi/xigrabdev.h
> index 08309c9..2f74788 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 HasConfineTo(ClientPtr client);
> +
> #endif /* XIGRABDEV_H */
> diff --git a/Xi/xipassivegrab.c b/Xi/xipassivegrab.c
> index ae43433..d64b5fb 100644
> --- a/Xi/xipassivegrab.c
> +++ b/Xi/xipassivegrab.c
> @@ -45,6 +45,8 @@
> #include "dixgrabs.h"
> #include "misc.h"
> 
> +#include "xigrabdev.h" /* HasConfineTo */
> +
> int
> SProcXIPassiveGrabDevice(ClientPtr client)
> {
> @@ -60,6 +62,10 @@ SProcXIPassiveGrabDevice(ClientPtr client)
>     swapl(&stuff->cursor, n);
>     swapl(&stuff->time, n);
>     swapl(&stuff->detail, n);
> +
> +    if(HasConfineTo(client) == TRUE)
> +        swapl(&stuff[1] + stuff->mask_len * 4 + stuff->num_modifiers * 4, n);
> +
>     swaps(&stuff->mask_len, n);
>     swaps(&stuff->num_modifiers, n);
> 
> @@ -89,6 +95,7 @@ ProcXIPassiveGrabDevice(ClientPtr client)
>     void *tmp;
>     int mask_len;
>     int n;
> +    Window confine_to;
> 
>     REQUEST(xXIPassiveGrabDeviceReq);
>     REQUEST_AT_LEAST_SIZE(xXIPassiveGrabDeviceReq);
> @@ -160,6 +167,20 @@ 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(HasConfineTo(client) == TRUE)
> +        memcpy((unsigned char *)&confine_to, (char*)&stuff[1] +
> +                stuff->mask_len * 4 + stuff->num_modifiers * 4, 4);
> +
> +    status = dixLookupWindow((WindowPtr*)&tmp, confine_to, client, DixSetAttrAccess);
> +    if (status != Success)
> +	return status;
> +
> +    param.confineTo = confine_to;
> +
>     status = CheckGrabValues(client, &param);
>     if (status != Success)
>         return status;
> -- 
> 1.7.5.1
> 
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
> 



More information about the xorg-devel mailing list