[PATCH 3/5] Check for proper window ID when processing touch allow requests

walter harms wharms at bfs.de
Fri Feb 3 00:54:38 PST 2012



Am 03.02.2012 01:57, schrieb Chase Douglas:
> From: Chase Douglas <chase.douglas at ubuntu.com>
> 
> Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
> ---
>  Xi/xiallowev.c  |    2 +-
>  dix/touch.c     |   18 ++++++++++++------
>  include/input.h |    2 +-
>  3 files changed, 14 insertions(+), 8 deletions(-)
> 
> diff --git a/Xi/xiallowev.c b/Xi/xiallowev.c
> index a722c1d..c95dcc6 100644
> --- a/Xi/xiallowev.c
> +++ b/Xi/xiallowev.c
> @@ -98,7 +98,7 @@ ProcXIAllowEvents(ClientPtr client)
>      case XIRejectTouch:
>      case XIAcceptTouch:
>          ret = AllowTouch(client, dev,
> -                         stuff->mode, stuff->touchid,
> +                         stuff->mode, stuff->touchid, stuff->grab_window,
>                           &client->errorValue);
>          break;
>      default:
> diff --git a/dix/touch.c b/dix/touch.c
> index 6113371..e24d9ac 100644
> --- a/dix/touch.c
> +++ b/dix/touch.c
> @@ -988,7 +988,7 @@ TouchListenerGone(XID resource)
>  
>  int
>  AllowTouch(ClientPtr client, DeviceIntPtr dev, int mode, uint32_t touchid,
> -           XID *error)
> +           Window grab_window, XID *error)
>  {
>      TouchPointInfoPtr ti;
>      int nev, i;
> @@ -1003,8 +1003,6 @@ AllowTouch(ClientPtr client, DeviceIntPtr dev, int mode, uint32_t touchid,
>          return BadDevice;
>      }
>  
> -    /* FIXME window is unhandled */
> -
>      ti = TouchFindByClientID(dev, touchid);
>      if (!ti)
>      {
> @@ -1012,9 +1010,17 @@ AllowTouch(ClientPtr client, DeviceIntPtr dev, int mode, uint32_t touchid,
>          return BadValue;
>      }
>  
> -    /* FIXME: Allow for early accept */
> -    if (ti->num_listeners == 0 ||
> -        CLIENT_ID(ti->listeners[0].listener) != client->index)
> +    for (i = 0; i < ti->num_listeners; i++)
> +    {
> +        if (CLIENT_ID(ti->listeners[i].listener) == client->index &&
> +            ti->listeners[i].window->drawable.id == grab_window)
> +            break;
> +    }
> +    if (i < ti->num_listeners)
> +        return BadAccess;
> +
> +    /* FIXME: Implement early accept/reject */
> +    if (i > 0)
>          return BadAccess;
>  
I am not sure that i understand this.
i<ti->num_listeners  means the if was triggert
i>0    is always true execpt on integer overflow
did i miss something ?

Would it be complicated to make that a function ?

re,
 wh


>      nev = GetTouchOwnershipEvents(events, dev, ti, mode,
> diff --git a/include/input.h b/include/input.h
> index 9ec4dd1..18119bc 100644
> --- a/include/input.h
> +++ b/include/input.h
> @@ -626,7 +626,7 @@ extern int TouchGetPointerEventType(const InternalEvent *ev);
>  extern void TouchRemovePointerGrab(DeviceIntPtr dev);
>  extern void TouchListenerGone(XID resource);
>  extern int AllowTouch(ClientPtr client, DeviceIntPtr dev, int mode,
> -                      uint32_t touchid, XID *error);
> +                      uint32_t touchid, Window grab_window, XID *error);
>  
>  /* misc event helpers */
>  extern Mask GetEventMask(DeviceIntPtr dev, xEvent* ev, InputClientsPtr clients);


More information about the xorg-devel mailing list