[PATCH] dix: undo transformation for missing valuators (#49347)

Chase Douglas chase.douglas at canonical.com
Mon May 14 17:25:41 PDT 2012


On 05/14/2012 05:21 PM, Chase Douglas wrote:
> On 05/14/2012 04:52 PM, Peter Hutterer wrote:
>> last.valuators contains the transformed valuators of the device. If the
>> device submits events with x/y missing, we need to get that from
>> last.valuators and undo the transformation to that axis.
>>
>> X.Org Bug 49347 <http://bugs.freedesktop.org/show_bug.cgi?id=49347>
>>
>> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
>> ---
>>  dix/getevents.c |   18 ++++++++++++++----
>>  1 file changed, 14 insertions(+), 4 deletions(-)
>>
>> diff --git a/dix/getevents.c b/dix/getevents.c
>> index c960d44..d466ebb 100644
>> --- a/dix/getevents.c
>> +++ b/dix/getevents.c
>> @@ -1167,15 +1167,25 @@ transformAbsolute(DeviceIntPtr dev, ValuatorMask *mask)
>>  {
>>      double x, y, ox, oy;
>>  
>> +    if (!valuator_mask_isset(mask, 0) || !valuator_mask_isset(mask, 1)) {
>> +        struct pixman_f_transform invert;
>> +
>> +        /* undo transformation from last event */
>> +        ox = dev->last.valuators[0];
>> +        oy = dev->last.valuators[1];
>> +
>> +        pixman_f_transform_invert(&invert, &dev->transform);
>> +        transform(&invert, &ox, &oy);
>> +
>> +        x = ox;
>> +        y = oy;
>> +    }
>> +
>>      if (valuator_mask_isset(mask, 0))
>>          ox = x = valuator_mask_get_double(mask, 0);
>> -    else
>> -        ox = x = dev->last.valuators[0];
>>  
>>      if (valuator_mask_isset(mask, 1))
>>          oy = y = valuator_mask_get_double(mask, 1);
>> -    else
>> -        oy = y = dev->last.valuators[1];
>>  
>>      transform(&dev->transform, &x, &y);
>>  
> 
> This all looks like a no-op if neither X nor Y are set in the passed-in
> mask. Why not just return early? I suppose ox != x and/or oy != y after
> the transformation, so we'll always be setting the values in the mask,
> but is that necessary since they haven't changed?

I realized my mistake in the review is when only one of the X and Y axis
values is set. Why don't we combine both by adding the following to the
top of the function:

if (!valuator_mask_isset(mask, 0) && !valuator_mask_isset(mask, 1))
    return;

It simply makes an optimized path when neither the X nor Y valuators are
set.

-- Chase


More information about the xorg-devel mailing list