[PATCH 1/2] Treat all touch event valuators as absolute

Chase Douglas chase.douglas at canonical.com
Thu Jan 19 20:51:33 PST 2012


On 01/20/2012 05:28 AM, Peter Hutterer wrote:
> On Wed, Jan 18, 2012 at 07:09:20PM -0800, Chase Douglas wrote:
>> An indirect touch device, such as a multitouch touchpad, has relative X
>> and Y axes internally. These axes are in screen coordinates. However,
>> the cooresponding axes for touch events are in absolute device
>> coordinates.
>>
>> Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
>> ---
>>  dix/getevents.c |   12 +++++++++---
>>  1 files changed, 9 insertions(+), 3 deletions(-)
>>
>> diff --git a/dix/getevents.c b/dix/getevents.c
>> index 1547059..3e37910 100644
>> --- a/dix/getevents.c
>> +++ b/dix/getevents.c
>> @@ -222,17 +222,23 @@ set_valuators(DeviceIntPtr dev, DeviceEvent* event, ValuatorMask *mask)
>>      int i;
>>  
>>      /* Set the data to the previous value for unset absolute axes. The values
>> -     * may be used when sent as part of an XI 1.x valuator event. */
>> +     * may be used when sent as part of an XI 1.x valuator event.
>> +     *
>> +     * All touch event valuators are absolute, even if the corresponding pointer
>> +     * valuator is relative. This is the case for indirect touch devices for the
>> +     * X and Y axes. */
>>      for (i = 0; i < valuator_mask_size(mask); i++)
>>      {
>>          if (valuator_mask_isset(mask, i))
>>          {
>>              SetBit(event->valuators.mask, i);
>> -            if (valuator_get_mode(dev, i) == Absolute)
>> +            if (IsTouchEvent((InternalEvent *)event) ||
>> +                valuator_get_mode(dev, i) == Absolute)
>>                  SetBit(event->valuators.mode, i);
>>              event->valuators.data[i] = valuator_mask_get_double(mask, i);
>>          }
>> -        else if (valuator_get_mode(dev, i) == Absolute)
>> +        else if (IsTouchEvent((InternalEvent *)event) ||
>> +                 valuator_get_mode(dev, i) == Absolute)
>>              event->valuators.data[i] = dev->valuator->axisVal[i];
>>      }
>>  }
>> -- 
>> 1.7.8.3
> 
> can we reshape this to pass in what the mode is for the valuators
> instead of guessing based on the event type?

The purpose is to force absolute for all valuators if it's a touch
event. We can add a parameter "Bool force_absolute", but that doesn't
feel any less hackish to me. It also hides the details through a level
of indirection, making us put a comment at the call into set_valuators
instead of inside set_valuators. I understand what you see as being a
bit obtuse in this implementation, but I'm not sure the alternative is
better.

-- Chase


More information about the xorg-devel mailing list