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

Chase Douglas chase.douglas at canonical.com
Fri Feb 3 16:52:01 PST 2012


On 02/03/2012 09:54 AM, walter harms wrote:
> 
> 
> 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 ?

I think it should be clearer in the second version I just sent out.

-- Chase


More information about the xorg-devel mailing list