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

Peter Hutterer peter.hutterer at who-t.net
Wed Jun 1 20:50:31 PDT 2011


On Wed, Jun 01, 2011 at 03:01:27PM +0200, Philipp Reh wrote:
> 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>

merged, thanks.

as I asked on IRC, it seems like a good choice to get confine_to into
passive grabs at the same time.

Cheers,
  Peter

> ---
>  Xi/xigrabdev.c              |   24 +++++++++++++++++++++++-
>  include/protocol-versions.h |    2 +-
>  2 files changed, 24 insertions(+), 2 deletions(-)
> 
> diff --git a/Xi/xigrabdev.c b/Xi/xigrabdev.c
> index 0adc878..5c9847d 100644
> --- a/Xi/xigrabdev.c
> +++ b/Xi/xigrabdev.c
> @@ -42,6 +42,16 @@
>  #include "exevents.h"
>  #include "xigrabdev.h"
>  
> +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 +64,10 @@ SProcXIGrabDevice(ClientPtr client)
>      swapl(&stuff->grab_window, n);
>      swapl(&stuff->cursor, n);
>      swapl(&stuff->time, n);
> +
> +    if(HasConfineTo(client) == TRUE)
> +        swapl(&stuff[1] + stuff->mask_len * 4, n);
> +
>      swaps(&stuff->mask_len, n);
>  
>      return ProcXIGrabDevice(client);
> @@ -68,6 +82,7 @@ ProcXIGrabDevice(ClientPtr client)
>      uint8_t status;
>      GrabMask mask;
>      int mask_len;
> +    Window confine_to;
>  
>      REQUEST(xXIGrabDeviceReq);
>      REQUEST_AT_LEAST_SIZE(xXIGrabDeviceReq);
> @@ -87,6 +102,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(HasConfineTo(client) == TRUE)
> +        memcpy((unsigned char *)&confine_to, (char*)&stuff[1] + stuff->mask_len * 4, 4);
> +
>      ret = GrabDevice(client, dev, stuff->grab_mode,
>                       stuff->paired_device_mode,
>                       stuff->grab_window,
> @@ -95,7 +117,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.3
> 


More information about the xorg-devel mailing list