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

@ -74,6 +74,16 @@ extern _X_EXPORT int CountBits(const uint8_t *mask, int len);
#define XI2LASTEVENT 17 /* XI_RawMotion */
#define XI2MASKSIZE ((XI2LASTEVENT + 7)/8) /* no of bits for masks */
/**
* Scroll types for ::SetScrollValuator and the scroll type in the
* ::ScrollInfoPtr.
*/
enum ScrollType {
SCROLL_TYPE_NONE = 0, /**< Not a scrolling valuator */
SCROLL_TYPE_VERTICAL = 8,
SCROLL_TYPE_HORIZONTAL = 9,
};
/**
* This struct stores the core event mask for each client except the client
* that created the window.
@ -252,6 +262,12 @@ typedef struct _KeyClassRec {
struct _XkbSrvInfo *xkbInfo;
} KeyClassRec, *KeyClassPtr;
typedef struct _ScrollInfo {
enum ScrollType type;
double increment;
int flags;
} ScrollInfo, *ScrollInfoPtr;
typedef struct _AxisInfo {
int resolution;
int min_resolution;
@ -260,6 +276,7 @@ typedef struct _AxisInfo {
int max_value;
Atom label;
CARD8 mode;
ScrollInfo scroll;
} AxisInfo, *AxisInfoPtr;
typedef struct _ValuatorAccelerationRec {
@ -283,6 +300,8 @@ typedef struct _ValuatorClassRec {
unsigned short numAxes;
double *axisVal; /* always absolute, but device-coord system */
ValuatorAccelerationRec accelScheme;
int h_scroll_axis; /* horiz smooth-scrolling axis */
int v_scroll_axis; /* vert smooth-scrolling axis */
} ValuatorClassRec;
typedef struct _ButtonClassRec {
@ -524,6 +543,7 @@ typedef struct _DeviceIntRec {
double valuators[MAX_VALUATORS];
int numValuators;
DeviceIntPtr slave;
ValuatorMask *scroll;
} last;
/* Input device property handling. */