[PATCH 1/2] Treat all touch event valuators as absolute
Peter Hutterer
peter.hutterer at who-t.net
Mon Jan 23 19:30:28 PST 2012
On Fri, Jan 20, 2012 at 05:51:33AM +0100, Chase Douglas wrote:
> 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.
the current input API requires us to submit all valuators in one mode anyway
. xf86PostMotionEvent takes only a single Relative/Absolute argument, so we
can carry that through. For touch events, we know that the values are always
absolute, so we can assume mode = Absolute in GetTouchEvents() and pass that
to set_valuators, no?
Cheers,
Peter
More information about the xorg-devel
mailing list