Input: Add smooth-scrolling support to GetPointerEvents

For scroll wheel support, we used to send buttons 4/5 and 6/7 for
horizontal/vertical positive/negative scroll events.  For touchpads, we
really want more fine-grained scroll values.  GetPointerEvents now
accepts both old-school scroll button presses, and new-style scroll axis
events, while emitting both types of events to support both old and new
clients.

This works with the new XIScrollClass to mark axes as scrolling axes.
Drivers mark any valuators that send scroll events with SetScrollValuator.
(Currently missing: the XIDeviceChangeEvent being sent when a driver changes
a scroll axis at run-time. This can be added later.)

Note: the SCROLL_TYPE enums are intentionally different values to the XI2
proto values to avoid copy/overlapping range bugs.

Co-authored-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
This commit is contained in:
Peter Hutterer 2011-02-15 18:49:58 +00:00
commit 3304bbff9b
10 changed files with 506 additions and 11 deletions

View file

@ -1091,6 +1091,55 @@ InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, Atom label, int minval, int
if (mode & OutOfProximity)
dev->proximity->in_proximity = FALSE;
return SetScrollValuator(dev, axnum, SCROLL_TYPE_NONE, 0, SCROLL_FLAG_NONE);
}
/**
* Set the given axis number as a scrolling valuator.
*/
Bool
SetScrollValuator(DeviceIntPtr dev, int axnum, enum ScrollType type, double increment, int flags)
{
AxisInfoPtr ax;
int *current_ax;
if (!dev || !dev->valuator || axnum >= dev->valuator->numAxes)
return FALSE;
switch (type)
{
case SCROLL_TYPE_VERTICAL:
current_ax = &dev->valuator->v_scroll_axis;
break;
case SCROLL_TYPE_HORIZONTAL:
current_ax = &dev->valuator->h_scroll_axis;
break;
case SCROLL_TYPE_NONE:
ax = &dev->valuator->axes[axnum];
ax->scroll.type = type;
return TRUE;
default:
return FALSE;
}
if (increment == 0.0)
return FALSE;
if (*current_ax != -1 && axnum != *current_ax)
{
ax = &dev->valuator->axes[*current_ax];
if (ax->scroll.type == type &&
(flags & SCROLL_FLAG_PREFERRED) && (ax->scroll.flags & SCROLL_FLAG_PREFERRED))
return FALSE;
}
*current_ax = axnum;
ax = &dev->valuator->axes[axnum];
ax->scroll.type = type;
ax->scroll.increment = increment;
ax->scroll.flags = flags;
/* FIXME: generate DeviceChanged Events */
return TRUE;
}