File add-evdev-prop-scroll-distance-definition.diff of Package xf86-input-evdev.461

From 4b2855cb0c8e81ab5250cbf1c454626863499dbc Mon Sep 17 00:00:00 2001
From: Peter De Wachter <pdewacht@gmail.com>
Date: Wed, 3 Oct 2012 22:08:12 +0200
Subject: [PATCH 2/2] Export smooth scroll settings as an XInput property.

A new property "Evdev Scrolling Distance" is created that holds three values
(vertical, horizontal and dial).

Signed-off-by: Peter De Wachter <pdewacht@gmail.com>
---
 include/evdev-properties.h |  4 +++
 man/evdev.man              |  8 +++--
 src/evdev.c                | 80 ++++++++++++++++++++++++++++++++++++++--------
 3 files changed, 76 insertions(+), 16 deletions(-)

diff --git a/include/evdev-properties.h b/include/evdev-properties.h
index 745a1ba..83f7e00 100644
--- a/include/evdev-properties.h
+++ b/include/evdev-properties.h
@@ -87,4 +87,8 @@
 */
 #define EVDEV_PROP_FUNCTION_KEYS "Evdev Function Keys"
 
+/* Smooth scroll */
+/* CARD32, 3 values (vertical, horizontal, dial) */
+#define EVDEV_PROP_SCROLL_DISTANCE "Evdev Scrolling Distance"
+
 #endif
diff --git a/man/evdev.man b/man/evdev.man
index 85cea10..72f3dd8 100644
--- a/man/evdev.man
+++ b/man/evdev.man
@@ -229,14 +229,15 @@ need quirks.
 .TP 7
 .BI "Option \*qVertScrollDelta\*q \*q" integer \*q
 The amount of motion considered one unit of scrolling vertically.
-Default: "1".
+Default: "1".  Property: "Evdev Scrolling Distance".
 .TP 7
 .BI "Option \*qHorizScrollDelta\*q \*q" integer \*q
 The amount of motion considered one unit of scrolling horizontally.
-Default: "1".
+Default: "1".  Proprety: "Evdev Scrolling Distance".
 .TP 7
 .BI "Option \*qDialDelta\*q \*q" integer \*q
 The amount of motion considered one unit of turning the dial.  Default: "1".
+Property: "Evdev Scrolling Distance".
 
 .SH SUPPORTED PROPERTIES
 The following properties are provided by the
@@ -277,6 +278,9 @@ value.
 .TP 7
 .BI "Evdev Wheel Emulation Timeout"
 1 16-bit positive value.
+.TP 7
+.BI "Evdev Scrolling Distance"
+3 32-bit values: vertical, horizontal and dial.
 
 .SH AUTHORS
 Kristian Høgsberg, Peter Hutterer
diff --git a/src/evdev.c b/src/evdev.c
index dc7a0db..50341a1 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -137,6 +137,7 @@ static Atom prop_axis_label;
 static Atom prop_btn_label;
 static Atom prop_device;
 static Atom prop_virtual;
+static Atom prop_scroll_dist;
 
 /* All devices the evdev driver has allocated and knows about.
  * MAXDEVICES is safe as null-terminated array, as two devices (VCP and VCK)
@@ -1606,6 +1607,41 @@ out:
 }
 
 static int
+EvdevSetScrollValuators(DeviceIntPtr device)
+{
+    InputInfoPtr pInfo;
+    EvdevPtr pEvdev;
+    int axis;
+
+    pInfo = device->public.devicePrivate;
+    pEvdev = pInfo->private;
+
+    for (axis = REL_X; axis <= REL_MAX; axis++)
+    {
+        int axnum = pEvdev->rel_axis_map[axis];
+        if (axnum == -1)
+            continue;
+        
+#ifdef HAVE_SMOOTH_SCROLLING
+        if (axis == REL_WHEEL)
+            SetScrollValuator(device, axnum, SCROLL_TYPE_VERTICAL,
+                              -pEvdev->smoothScroll.vert_delta,
+                              SCROLL_FLAG_PREFERRED);
+        else if (axis == REL_DIAL)
+            SetScrollValuator(device, axnum, SCROLL_TYPE_VERTICAL,
+                              -pEvdev->smoothScroll.dial_delta,
+                              SCROLL_FLAG_NONE);
+        else if (axis == REL_HWHEEL)
+            SetScrollValuator(device, axnum, SCROLL_TYPE_HORIZONTAL,
+                              pEvdev->smoothScroll.horiz_delta,
+                              SCROLL_FLAG_NONE);
+#endif
+    }
+
+    return Success;
+}
+
+static int
 EvdevAddRelValuatorClass(DeviceIntPtr device)
 {
     InputInfoPtr pInfo;
@@ -1687,22 +1723,10 @@ EvdevAddRelValuatorClass(DeviceIntPtr device)
         xf86InitValuatorAxisStruct(device, axnum, atoms[axnum], -1, -1, 1, 0, 1,
                                    Relative);
         xf86InitValuatorDefaults(device, axnum);
-#ifdef HAVE_SMOOTH_SCROLLING
-        if (axis == REL_WHEEL)
-            SetScrollValuator(device, axnum, SCROLL_TYPE_VERTICAL,
-                              -pEvdev->smoothScroll.vert_delta,
-                              SCROLL_FLAG_PREFERRED);
-        else if (axis == REL_DIAL)
-            SetScrollValuator(device, axnum, SCROLL_TYPE_VERTICAL,
-                              -pEvdev->smoothScroll.dial_delta,
-                              SCROLL_FLAG_NONE);
-        else if (axis == REL_HWHEEL)
-            SetScrollValuator(device, axnum, SCROLL_TYPE_HORIZONTAL,
-                              pEvdev->smoothScroll.horiz_delta,
-                              SCROLL_FLAG_NONE);
-#endif
     }
 
+    EvdevSetScrollValuators(device);
+
     free(atoms);
 
     return Success;
@@ -2944,6 +2968,22 @@ EvdevInitProperty(DeviceIntPtr dev)
                                    PropModeReplace, pEvdev->num_buttons, atoms, FALSE);
             XISetDevicePropertyDeletable(dev, prop_btn_label, FALSE);
         }
+
+#ifdef HAVE_SMOOTH_SCROLLING
+        {
+            int smooth_scroll_values[3] = {
+                pEvdev->smoothScroll.vert_delta,
+                pEvdev->smoothScroll.horiz_delta,
+                pEvdev->smoothScroll.dial_delta
+            };
+            prop_scroll_dist = MakeAtom(EVDEV_PROP_SCROLL_DISTANCE,
+                                        strlen(EVDEV_PROP_SCROLL_DISTANCE), TRUE);
+            XIChangeDeviceProperty(dev, prop_scroll_dist, XA_INTEGER, 32,
+                                   PropModeReplace, 3, smooth_scroll_values, FALSE);
+            XISetDevicePropertyDeletable(dev, prop_scroll_dist, FALSE);
+        }
+#endif
+
     }
 
 }
@@ -2983,6 +3023,18 @@ EvdevSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
 
         if (!checkonly)
             pEvdev->swap_axes = *((BOOL*)val->data);
+    } else if (atom == prop_scroll_dist)
+    {
+        if (val->format != 32 || val->type != XA_INTEGER || val->size != 3)
+            return BadMatch;
+
+        if (!checkonly) {
+            int* data = (int *)val->data;
+            pEvdev->smoothScroll.vert_delta = data[0];
+            pEvdev->smoothScroll.horiz_delta = data[1];
+            pEvdev->smoothScroll.dial_delta = data[2];
+            EvdevSetScrollValuators(dev);
+        }
     } else if (atom == prop_axis_label || atom == prop_btn_label ||
                atom == prop_product_id || atom == prop_device ||
                atom == prop_virtual)
-- 
1.8.4.rc3

openSUSE Build Service is sponsored by