[PATCH RFC v3 inputproto] Move scroll information into a new class.

Peter Hutterer peter.hutterer at who-t.net
Tue Aug 16 23:56:23 PDT 2011


Scrolling information cannot be handled by a simple flag alone, it requires
more information to cover all (current) use-cases.
One of these ScrollClass may exist for each ValuatorClass if that valuator
is a scrolling valuator.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
Goes on top of the current stack so this needs to be squashed together but I
think the changes are fairly clear anyway.

- Axis flags stays around, but only for the wraparound hint
- new ScrollClass that includes the increment and the scroll type for an
  axis. The XIScrollFlagPreferred sorts out the ambiguity

I've got the stack working with this here and ran out of corner cases
that aren't covered. One ambiguity left is if an event includes scrolling
information on two equal-type valuators at once - that can be 
handled with Preferred. Axis inversion (needed for Wacom) can be handled
with a negative increment.

One final issue: this is read-only and the increment cannot be changed by
clients as of yet. Not sure how to do this other than mirroring some of this
in properties which is not quite optimal.

 XI2.h              |   13 +++++++--
 XI2proto.h         |   16 ++++++++++++
 specs/XI2proto.txt |   69 ++++++++++++++++++++++++++++++++++++++++------------
 3 files changed, 79 insertions(+), 19 deletions(-)

diff --git a/XI2.h b/XI2.h
index 93a691f..121684c 100644
--- a/XI2.h
+++ b/XI2.h
@@ -141,11 +141,18 @@
 #define XIKeyClass                              0
 #define XIButtonClass                           1
 #define XIValuatorClass                         2
+#define XIScrollClass                           3
 
 /* Axis flags */
-#define XIAxisVertScroll                        (1 << 0)
-#define XIAxisHorizScroll                       (1 << 1)
-#define XIAxisWrapAround                        (1 << 2)
+#define XIAxisFlagWrapAround                    (1 << 0)
+
+/* Scroll class types */
+#define XIScrollTypeVertical                    1
+#define XIScrollTypeHorizontal                  2
+
+/* Scroll class flags */
+#define XIScrollFlagEmulate                     (1 << 0)
+#define XIScrollFlagPreferred                   (1 << 1)
 
 /* Device event flags (common) */
 /* Device event flags (key events only) */
diff --git a/XI2proto.h b/XI2proto.h
index 03ead01..63bef0d 100644
--- a/XI2proto.h
+++ b/XI2proto.h
@@ -191,6 +191,22 @@ typedef struct {
  */
 } xXIValuatorInfo;
 
+/***
+ * Denotes a scroll valuator on a device.
+ * One XIScrollInfo describes exactly one scroll valuator that must have a
+ * XIValuatorInfo struct.
+ */
+typedef struct {
+    uint16_t    type;           /**< Always ValuatorClass         */
+    uint16_t    length;         /**< Length in 4 byte units       */
+    uint16_t    sourceid;       /**< source device for this class */
+    uint16_t    number;         /**< Valuator number              */
+    uint16_t    scroll_type;    /**< ::XIScrollTypeVertical, ::XIScrollTypeHorizontal */
+    uint16_t    pad0;
+    uint32_t    flags;          /**< ::XIScrollFlagEmulate, ::XIScrollFlagPreferred   */
+    FP3232      increment;      /**< Increment for one unit of scrolling              */
+} xXIScrollInfo;
+
 /**
  * Used to select for events on a given window.
  * Struct is followed by (mask_len * CARD8), with each bit set representing
diff --git a/specs/XI2proto.txt b/specs/XI2proto.txt
index 6d76405..7c00eb6 100644
--- a/specs/XI2proto.txt
+++ b/specs/XI2proto.txt
@@ -126,20 +126,19 @@ are able to provide scrolling events through multi-finger drag gestures, or
 simply dragging your finger along a designated strip along the side of the
 touchpad.
 
-Newer X servers may provide scrolling information through specific
-valuators to provide scroll events with more precision than the button
-events. Valuators for axes sending scrolling information should have the
-VertScroll or HorizScroll axis flag set.
+Newer X servers may provide scrolling information through valuators to
+provide scroll events with more precision than the button events. Valuators
+for axes sending scrolling information must have one ScrollClass for each
+scrolling axis.
 
 If scrolling valuators are present on a device, the server must provide
 two-way emulation between these valuators and the legacy button events for
-each delta unit of scrolling. The delta value of one unit is
-device-dependent.
+each delta unit of scrolling.
 
 One unit of scrolling in either direction is considered to be equivalent to
-one button event for the legacy events, e.g. for an unit size of 1.0, -2.0 on an axis marked with
-VertScroll sends two button press/release events for button 4. Likewise, a
-button press event for button 7 generates an event on the HorizScroll
+one button event, e.g. for a unit size of 1.0, -2.0 on an valuator type
+Vertical sends two button press/release events for button 4. Likewise, a
+button press event for button 7 generates an event on the Horizontal
 valuator with a value of +1.0. The server may accumulate deltas of less than
 one unit of scrolling.
 
@@ -151,9 +150,11 @@ If an axis is flagged as WrapAround, the server attempts wrap-around
 detection and generates the scroll events taking a potential wrap-around
 into account.
 
-The behavior of scroll button emulation if there is more than one VertScroll
-or more than one HorizScroll axes on the same device is implementation-
-dependent.
+If more than one scroll valuator of the same type is present on a device,
+the valuator marked with Preferred is used to convert legacy button events
+into scroll valuator events. If no valuator is marked Preferred or more than
+one valuator is marked with Preferred, this should be considered a driver
+bug and the behaviour is implementation-dependent.
 
 4. The Master/Slave device hierarchy
 ------------------------------------
@@ -343,7 +344,7 @@ If major_version is less than 2, a BadValue error occurs.
                  name:                  LISTofCHAR8
                  classes:               LISTofCLASS }
 
-    CLASS { BUTTONCLASS, KEYCLASS, AXISCLASS }
+    CLASS { BUTTONCLASS, KEYCLASS, AXISCLASS, SCROLLCLASS }
 
     BUTTONCLASS { type:                 ButtonClass
                   length:               CARD16
@@ -370,9 +371,21 @@ If major_version is less than 2, a BadValue error occurs.
                   mode:                 CARD8
                   flags*:               SETofAXISFLAGS }
 
+    SCROLLCLASS* {type:                 ScrollClass
+                  length:               CARD16
+                  sourceid:             CARD16
+                  axisnumber:           CARD16
+                  scroll_type:          SCROLLTYPE
+                  flags:                SETofSCROLLFLAGS
+                  increment:            FP3232 }
+
     * since XI 2.1
 
-    AXISFLAGS { VertScroll, HorizScroll, WrapAround }
+    AXISFLAGS { WrapAround }
+
+    SCROLLTYPE { Vertical, Horizontal }
+
+    SCROLLFLAGS { Emulate, Preferred }
 
 XIQueryDevice details information about the requested input devices.
 
@@ -474,14 +487,38 @@ The following classes may occur only once: ButtonClass, KeyClass
         Last published axis value (if mode is absolute).
     flags
         A set of flags describing additional axis information
-        VertScroll: This axis is a vertical scrolling axis
-        HorizScroll: This axis is a horizontal scrolling axis
         WrapAround: This axis is a ring and wraps from max to min or
                     min to max.
 
 An axis in Relative mode may specify min and max as a hint to the
 client. If no min and max information is available, both must be 0.
 
+    ScrollClass:
+    type
+        Always ScrollClass.
+    length
+        Length in 4 byte units.
+    sourceid
+        The device this class originates from.
+    axisnumber
+        Axis number that is referred to. This axis number must be listed in
+        the ValuatorClassInfo.
+    scroll_type:
+        Vertical for a vertical scrolling axis, Horizontal for a horizontal
+        scrolling axis
+    flags:
+        A set of flags that apply to this scroll axis.
+        Emulate: legacy scroll button events are generated for each unit of
+                 scrolling on this axis (see Section 3.4)
+        Preferred: This axis is the preferred axis for emulating valuator
+                 events from legacy scroll button events.
+    increment:
+        The valuator delta equivalent to one positive unit of scrolling.
+
+A ScrollClass may only exist if the device has at least one ValuatorClass
+and each axisnumber listed in any ScrollClass. Only one ScrollClass may
+exist per ValuatorClass.
+
     ┌───
         XISelectEvents
             window:         Window
-- 
1.7.6



More information about the xorg-devel mailing list