From db77a5229716384a2a0dfc987f18f76f797a4194 Mon Sep 17 00:00:00 2001 From: Peter De Wachter Date: Wed, 3 Oct 2012 20:48:24 +0200 Subject: [PATCH 2/3] Add configuration options for smooth scrolling. This patch creates three new xorg.conf options, VertScrollDelta, HorizScrollDelta and DialDelta, which adjust the sensitivity of smooth scrolling. These options take a positive float, default value is 1. Signed-off-by: Peter De Wachter --- man/evdev.man | 11 +++++++++++ src/evdev.c | 30 ++++++++++++++++++++++++------ src/evdev.h | 5 +++++ 3 files changed, 40 insertions(+), 6 deletions(-) diff --git a/man/evdev.man b/man/evdev.man index 2709d7a..886d0ae 100644 --- a/man/evdev.man +++ b/man/evdev.man @@ -220,6 +220,17 @@ is mapped to the negative Y axis motion and button number .I N2 is mapped to the positive Y axis motion. Default: "4 5". Property: "Evdev Wheel Emulation Axes". +.TP 7 +.BI "Option \*qVertScrollDelta\*q \*q" "float" \*q +The amount of motion considered one unit of scrolling vertically. +Default: "1". +.TP 7 +.BI "Option \*qHorizScrollDelta\*q \*q" "float" \*q +The amount of motion considered one unit of scrolling horizontally. +Default: "1". +.TP 7 +.BI "Option \*qDialDelta\*q \*q" "float" \*q +The amount of motion considered one unit of turning the dial. Default: "1". .SH SUPPORTED PROPERTIES The following properties are provided by the diff --git a/src/evdev.c b/src/evdev.c index 360cf9f..decaee7 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -1506,7 +1506,8 @@ EvdevAddAbsValuatorClass(DeviceIntPtr device, int want_scroll_axes) NO_AXIS_LIMITS, NO_AXIS_LIMITS, 0, 0, 0, Relative); SetScrollValuator(device, pEvdev->rel_axis_map[idx], - SCROLL_TYPE_VERTICAL, -1.0, + SCROLL_TYPE_VERTICAL, + -pEvdev->smoothScroll.vert_delta, SCROLL_FLAG_PREFERRED); } @@ -1519,7 +1520,8 @@ EvdevAddAbsValuatorClass(DeviceIntPtr device, int want_scroll_axes) NO_AXIS_LIMITS, NO_AXIS_LIMITS, 0, 0, 0, Relative); SetScrollValuator(device, pEvdev->rel_axis_map[idx], - SCROLL_TYPE_HORIZONTAL, 1.0, + SCROLL_TYPE_HORIZONTAL, + pEvdev->smoothScroll.horiz_delta, SCROLL_FLAG_NONE); } @@ -1532,7 +1534,8 @@ EvdevAddAbsValuatorClass(DeviceIntPtr device, int want_scroll_axes) NO_AXIS_LIMITS, NO_AXIS_LIMITS, 0, 0, 0, Relative); SetScrollValuator(device, pEvdev->rel_axis_map[idx], - SCROLL_TYPE_VERTICAL, -1.0, + SCROLL_TYPE_VERTICAL, + -pEvdev->smoothScroll.dial_delta, SCROLL_FLAG_NONE); } } @@ -1673,11 +1676,17 @@ EvdevAddRelValuatorClass(DeviceIntPtr device) xf86InitValuatorDefaults(device, axnum); #ifdef HAVE_SMOOTH_SCROLLING if (axis == REL_WHEEL) - SetScrollValuator(device, axnum, SCROLL_TYPE_VERTICAL, -1.0, SCROLL_FLAG_PREFERRED); + SetScrollValuator(device, axnum, SCROLL_TYPE_VERTICAL, + -pEvdev->smoothScroll.vert_delta, + SCROLL_FLAG_PREFERRED); else if (axis == REL_DIAL) - SetScrollValuator(device, axnum, SCROLL_TYPE_VERTICAL, -1.0, SCROLL_FLAG_NONE); + SetScrollValuator(device, axnum, SCROLL_TYPE_VERTICAL, + -pEvdev->smoothScroll.dial_delta, + SCROLL_FLAG_NONE); else if (axis == REL_HWHEEL) - SetScrollValuator(device, axnum, SCROLL_TYPE_HORIZONTAL, 1.0, SCROLL_FLAG_NONE); + SetScrollValuator(device, axnum, SCROLL_TYPE_HORIZONTAL, + pEvdev->smoothScroll.horiz_delta, + SCROLL_FLAG_NONE); #endif } @@ -2377,6 +2386,15 @@ EvdevProbe(InputInfoPtr pInfo) xf86IDrvMsg(pInfo, X_INFO, "Adding scrollwheel support\n"); pEvdev->flags |= EVDEV_BUTTON_EVENTS; pEvdev->flags |= EVDEV_RELATIVE_EVENTS; + +#ifdef HAVE_SMOOTH_SCROLLING + pEvdev->smoothScroll.vert_delta = + xf86SetRealOption(pInfo->options, "VertScrollDelta", 1.0); + pEvdev->smoothScroll.horiz_delta = + xf86SetRealOption(pInfo->options, "HorizScrollDelta", 1.0); + pEvdev->smoothScroll.dial_delta = + xf86SetRealOption(pInfo->options, "DialDelta", 1.0); +#endif } out: diff --git a/src/evdev.h b/src/evdev.h index 63c3bfa..46392d1 100644 --- a/src/evdev.h +++ b/src/evdev.h @@ -220,6 +220,11 @@ typedef struct { Time expires; /* time of expiry */ Time timeout; } emulateWheel; + struct { + float vert_delta; + float horiz_delta; + float dial_delta; + } smoothScroll; /* run-time calibration */ struct { int min_x; -- 1.7.10.4