[PATCH 06/42] tests: update for touch support

Peter Hutterer peter.hutterer at who-t.net
Fri Dec 16 03:12:05 PST 2011


On 16/12/11 20:56 , walter harms wrote:
>
>
> Am 15.12.2011 04:01, schrieb Peter Hutterer:
>> Touch event mask must be set for all three event types.
>>
>> Signed-off-by: Peter Hutterer<peter.hutterer at who-t.net>
>> ---
>>   test/xi2/protocol-xipassivegrabdevice.c |    2 +-
>>   test/xi2/protocol-xiselectevents.c      |   38 ++++++++++++++++++++++++------
>>   2 files changed, 31 insertions(+), 9 deletions(-)
>>
>> diff --git a/test/xi2/protocol-xipassivegrabdevice.c b/test/xi2/protocol-xipassivegrabdevice.c
>> index 89ffc3d..b405556 100644
>> --- a/test/xi2/protocol-xipassivegrabdevice.c
>> +++ b/test/xi2/protocol-xipassivegrabdevice.c
>> @@ -180,7 +180,7 @@ static void test_XIPassiveGrabDevice(void)
>>       request->deviceid = XIAllMasterDevices;
>>
>>       printf("Testing invalid grab types\n");
>> -    for (i = XIGrabtypeFocusIn + 1; i<  0xFF; i++)
>> +    for (i = XIGrabtypeTouchBegin + 1; i<  0xFF; i++)
>>       {
>>           request->grab_type = i;
>>           request_XIPassiveGrabDevice(&client_request, request, BadValue, request->grab_type);
>> diff --git a/test/xi2/protocol-xiselectevents.c b/test/xi2/protocol-xiselectevents.c
>> index 4eaf839..0390858 100644
>> --- a/test/xi2/protocol-xiselectevents.c
>> +++ b/test/xi2/protocol-xiselectevents.c
>> @@ -125,6 +125,28 @@ static void request_XISelectEvent(xXISelectEventsReq *req, int error)
>>       assert(rc == error);
>>   }
>>
>> +static void _set_bit(unsigned char *bits, int bit)
>> +{
>> +    SetBit(bits, bit);
>> +    if (bit>= XI_TouchBegin&&  bit<= XI_TouchOwnership)
>> +    {
>> +        SetBit(bits, XI_TouchBegin);
>> +        SetBit(bits, XI_TouchUpdate);
>> +        SetBit(bits, XI_TouchEnd);
>> +    }
>> +}
>
> So far i understand you want to avoid setting already set bits.
> Would it hurt to set them again ?

if any of the four XI_Touch* is set, begin/update/end must be set. 
setting them twice doesn't hurt, especially not in a test. And we have a 
test in input.c that makes sure that SetBit on masks works as expected, 
iirc.


>> +static void _clear_bit(unsigned char *bits, int bit)
>> +{
>> +    ClearBit(bits, bit);
>> +    if (bit>= XI_TouchBegin&&  bit<= XI_TouchOwnership)
>> +    {
>> +        ClearBit(bits, XI_TouchBegin);
>> +        ClearBit(bits, XI_TouchUpdate);
>> +        ClearBit(bits, XI_TouchEnd);
>> +    }
>> +}
>> +
>
> The naming is unfortunate.

huh?


>>   static void request_XISelectEvents_masks(xXISelectEventsReq *req)
>>   {
>>       int i, j;
>> @@ -157,9 +179,9 @@ static void request_XISelectEvents_masks(xXISelectEventsReq *req)
>>           memset(bits, 0, mask->mask_len * 4);
>>           for (j = 0; j<= XI2LASTEVENT; j++)
>>           {
>> -            SetBit(bits, j);
>> +            _set_bit(bits, j);
>>               request_XISelectEvent(req, Success);
>> -            ClearBit(bits, j);
>> +            _clear_bit(bits, j);
>>           }
>>
>>           /* Test 2:
>> @@ -173,7 +195,7 @@ static void request_XISelectEvents_masks(xXISelectEventsReq *req)
>>
>>           for (j = 0; j<= XI2LASTEVENT; j++)
>>           {
>> -            SetBit(bits, j);
>> +            _set_bit(bits, j);
>>               request_XISelectEvent(req, Success);
>>           }
>>
>> @@ -187,9 +209,9 @@ static void request_XISelectEvents_masks(xXISelectEventsReq *req)
>>
>>           for (j = XI2LASTEVENT + 1; j<  mask->mask_len * 4; j++)
>>           {
>> -            SetBit(bits, j);
>> +            _set_bit(bits, j);
>>               request_XISelectEvent(req, BadValue);
>> -            ClearBit(bits, j);
>> +            _clear_bit(bits, j);
>>           }
>>
>>           /* Test 4:
>> @@ -200,7 +222,7 @@ static void request_XISelectEvents_masks(xXISelectEventsReq *req)
>>           memset(bits, 0, mask->mask_len * 4);
>>           for (j = 0; j<= XI2LASTEVENT; j++)
>>           {
>> -            SetBit(bits, j);
>> +            _set_bit(bits, j);
>>               request_XISelectEvent(req, Success);
>>           }
>>
>> @@ -227,8 +249,8 @@ static void request_XISelectEvents_masks(xXISelectEventsReq *req)
>>           mask->mask_len = (nmasks + 3)/4;
>>           memset(bits, 0, mask->mask_len * 4);
>>           for (j = 0; j<= XI2LASTEVENT; j++)
>> -            SetBit(bits, j);
>> -        ClearBit(bits, XI_HierarchyChanged);
>> +            _set_bit(bits, j);
>> +        _clear_bit(bits, XI_HierarchyChanged);
>>           for (j = 1; j<  6; j++)
>>           {
>>               mask->deviceid = j;



More information about the xorg-devel mailing list