summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYinon Burgansky <yinonburgansky@gmail.com>2023-02-18 21:22:15 +0200
committerYinon Burgansky <yinonburgansky@gmail.com>2023-02-18 21:22:15 +0200
commit484b6a7f3ffb2641c8c35043145be4e5eca26112 (patch)
treedf8d66644b9becc8d23df0cf81d6778e321535f9
parente87c7bfcc2b7e7148554467c6eff8ec28aabe0c2 (diff)
downloadxorg-driver-xf86-input-libinput-484b6a7f3ffb2641c8c35043145be4e5eca26112.tar.gz
Add support for the scroll movement type of the custom acceleration profile
Adds new properties and xorg.conf entries for setting the scroll acceleration function's points and step. The new xorg.conf entries are AccelPointsScroll, AccelStepScroll.
-rw-r--r--include/libinput-properties.h6
-rw-r--r--man/libinput.man4
-rw-r--r--src/xf86libinput.c68
3 files changed, 69 insertions, 9 deletions
diff --git a/include/libinput-properties.h b/include/libinput-properties.h
index 004dac9..71e6208 100644
--- a/include/libinput-properties.h
+++ b/include/libinput-properties.h
@@ -87,6 +87,12 @@
/* Steps for the custom accel profile: FLOAT, 1 value */
#define LIBINPUT_PROP_ACCEL_CUSTOM_STEP_MOTION "libinput Accel Custom Motion Step"
+/* Points for the custom accel profile: FLOAT, N values */
+#define LIBINPUT_PROP_ACCEL_CUSTOM_POINTS_SCROLL "libinput Accel Custom Scroll Points"
+
+/* Steps for the custom accel profile: FLOAT, 1 value */
+#define LIBINPUT_PROP_ACCEL_CUSTOM_STEP_SCROLL "libinput Accel Custom Scroll Step"
+
/* Natural scrolling: BOOL, 1 value */
#define LIBINPUT_PROP_NATURAL_SCROLL "libinput Natural Scrolling Enabled"
diff --git a/man/libinput.man b/man/libinput.man
index 689afa4..7c83ccb 100644
--- a/man/libinput.man
+++ b/man/libinput.man
@@ -67,6 +67,10 @@ This only applies to the custom profile.
Equivalent to AccelPointsFallback but applies to the Motion acceleration function.
.BI "Option \*AccelStepMotion\*q \*q" float \*q
Equivalent to AccelStepFallback but applies to the Motion acceleration function.
+.BI "Option \*AccelPointsScroll\*q \*q" string \*q
+Equivalent to AccelPointsFallback but applies to the Scroll acceleration function.
+.BI "Option \*AccelStepScroll\*q \*q" float \*q
+Equivalent to AccelStepFallback but applies to the Scroll acceleration function.
.TP 7
.BI "Option \*qButtonMapping\*q \*q" string \*q
Sets the logical button mapping for this device, see
diff --git a/src/xf86libinput.c b/src/xf86libinput.c
index a465475..642f95f 100644
--- a/src/xf86libinput.c
+++ b/src/xf86libinput.c
@@ -181,6 +181,7 @@ struct xf86libinput {
#if HAVE_LIBINPUT_CUSTOM_ACCEL
struct accel_points accel_points_fallback;
struct accel_points accel_points_motion;
+ struct accel_points accel_points_scroll;
#endif
unsigned char btnmap[MAX_BUTTONS + 1];
@@ -572,6 +573,17 @@ LibinputApplyConfigAccelCustom(struct xf86libinput *driver_data,
goto out;
}
+ if (driver_data->options.accel_points_scroll.step > 0 &&
+ driver_data->options.accel_points_scroll.npoints >= 2) {
+ status = libinput_config_accel_set_points(accel,
+ LIBINPUT_ACCEL_TYPE_SCROLL,
+ driver_data->options.accel_points_scroll.step,
+ driver_data->options.accel_points_scroll.npoints,
+ driver_data->options.accel_points_scroll.points);
+ if (status != LIBINPUT_CONFIG_STATUS_SUCCESS)
+ goto out;
+ }
+
status = libinput_device_config_accel_apply(device, accel);
success = status == LIBINPUT_CONFIG_STATUS_SUCCESS;
out:
@@ -2987,6 +2999,13 @@ xf86libinput_parse_accel_points_motion_option(InputInfoPtr pInfo, struct libinpu
return xf86libinput_parse_accel_points_option(pInfo, device, "AccelPointsMotion");
}
+static inline struct accel_points
+xf86libinput_parse_accel_points_scroll_option(InputInfoPtr pInfo, struct libinput_device *device)
+{
+ return xf86libinput_parse_accel_points_option(pInfo, device, "AccelPointsScroll");
+}
+
+
static inline double
xf86libinput_parse_accel_step_option(InputInfoPtr pInfo, struct libinput_device *device, const char *name)
{
@@ -3021,6 +3040,12 @@ xf86libinput_parse_accel_step_motion_option(InputInfoPtr pInfo, struct libinput_
{
return xf86libinput_parse_accel_step_option(pInfo, device, "AccelStepMotion");
}
+
+static inline double
+xf86libinput_parse_accel_step_scroll_option(InputInfoPtr pInfo, struct libinput_device *device)
+{
+ return xf86libinput_parse_accel_step_option(pInfo, device, "AccelStepScroll");
+}
#endif
static inline BOOL
@@ -3559,9 +3584,11 @@ xf86libinput_parse_options(InputInfoPtr pInfo,
options->accel_profile = xf86libinput_parse_accel_profile_option(pInfo, device);
#if HAVE_LIBINPUT_CUSTOM_ACCEL
options->accel_points_fallback = xf86libinput_parse_accel_points_fallback_option(pInfo, device);
- options->accel_points_motion = xf86libinput_parse_accel_points_motion_option(pInfo, device);
options->accel_points_fallback.step = xf86libinput_parse_accel_step_fallback_option(pInfo, device);
+ options->accel_points_motion = xf86libinput_parse_accel_points_motion_option(pInfo, device);
options->accel_points_motion.step = xf86libinput_parse_accel_step_motion_option(pInfo, device);
+ options->accel_points_scroll = xf86libinput_parse_accel_points_scroll_option(pInfo, device);
+ options->accel_points_scroll.step = xf86libinput_parse_accel_step_scroll_option(pInfo, device);
#endif
options->natural_scrolling = xf86libinput_parse_natscroll_option(pInfo, device);
options->sendevents = xf86libinput_parse_sendevents_option(pInfo, device);
@@ -4024,10 +4051,12 @@ static Atom prop_accel;
static Atom prop_accel_default;
static Atom prop_accel_profile_enabled;
#if HAVE_LIBINPUT_CUSTOM_ACCEL
-static Atom prop_accel_points_motion;
static Atom prop_accel_points_fallback;
-static Atom prop_accel_step_motion;
static Atom prop_accel_step_fallback;
+static Atom prop_accel_points_motion;
+static Atom prop_accel_step_motion;
+static Atom prop_accel_points_scroll;
+static Atom prop_accel_step_scroll;
#endif
static Atom prop_accel_profile_default;
static Atom prop_accel_profiles_available;
@@ -4469,6 +4498,8 @@ LibinputSetPropertyAccelPoints(DeviceIntPtr dev,
accel_points = &driver_data->options.accel_points_fallback;
else if (atom == prop_accel_points_motion)
accel_points = &driver_data->options.accel_points_motion;
+ else if (atom == prop_accel_points_scroll)
+ accel_points = &driver_data->options.accel_points_scroll;
for (size_t idx = 0; idx < val->size; idx++)
accel_points->points[idx] = data[idx];
@@ -4511,6 +4542,8 @@ LibinputSetPropertyAccelStep(DeviceIntPtr dev,
driver_data->options.accel_points_fallback.step = *data;
else if (atom == prop_accel_step_motion)
driver_data->options.accel_points_motion.step = *data;
+ else if (atom == prop_accel_step_scroll)
+ driver_data->options.accel_points_scroll.step = *data;
}
return Success;
@@ -5166,9 +5199,13 @@ LibinputSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
else if (atom == prop_accel_profile_enabled)
rc = LibinputSetPropertyAccelProfile(dev, atom, val, checkonly);
#if HAVE_LIBINPUT_CUSTOM_ACCEL
- else if (atom == prop_accel_points_fallback || atom == prop_accel_points_motion)
+ else if (atom == prop_accel_points_fallback ||
+ atom == prop_accel_points_motion ||
+ atom == prop_accel_points_scroll)
rc = LibinputSetPropertyAccelPoints(dev, atom, val, checkonly);
- else if (atom == prop_accel_step_fallback || atom == prop_accel_step_motion)
+ else if (atom == prop_accel_step_fallback ||
+ atom == prop_accel_step_motion ||
+ atom == prop_accel_step_scroll)
rc = LibinputSetPropertyAccelStep(dev, atom, val, checkonly);
#endif
else if (atom == prop_natural_scroll)
@@ -5456,14 +5493,18 @@ LibinputInitAccelProperty(DeviceIntPtr dev,
#if HAVE_LIBINPUT_CUSTOM_ACCEL
float custom_points_fallback[CUSTOM_ACCEL_NPOINTS_MAX] = {0};
float custom_points_motion[CUSTOM_ACCEL_NPOINTS_MAX] = {0};
+ float custom_points_scroll[CUSTOM_ACCEL_NPOINTS_MAX] = {0};
size_t custom_npoints_fallback = driver_data->options.accel_points_fallback.npoints;
size_t custom_npoints_motion = driver_data->options.accel_points_motion.npoints;
+ size_t custom_npoints_scroll = driver_data->options.accel_points_scroll.npoints;
float custom_step_fallback = driver_data->options.accel_points_fallback.step;
float custom_step_motion = driver_data->options.accel_points_motion.step;
+ float custom_step_scroll = driver_data->options.accel_points_scroll.step;
for (size_t idx = 0; idx < CUSTOM_ACCEL_NPOINTS_MAX; idx++) {
custom_points_fallback[idx] = driver_data->options.accel_points_fallback.points[idx];
custom_points_motion[idx] = driver_data->options.accel_points_motion.points[idx];
+ custom_points_scroll[idx] = driver_data->options.accel_points_scroll.points[idx];
}
#endif
@@ -5568,19 +5609,28 @@ LibinputInitAccelProperty(DeviceIntPtr dev,
prop_float, 32,
custom_npoints_fallback,
custom_points_fallback);
+ prop_accel_step_fallback = LibinputMakeProperty(dev,
+ LIBINPUT_PROP_ACCEL_CUSTOM_STEP_FALLBACK,
+ prop_float, 32, 1,
+ &custom_step_fallback);
prop_accel_points_motion = LibinputMakeProperty(dev,
LIBINPUT_PROP_ACCEL_CUSTOM_POINTS_MOTION,
prop_float, 32,
custom_npoints_motion,
custom_points_motion);
- prop_accel_step_fallback = LibinputMakeProperty(dev,
- LIBINPUT_PROP_ACCEL_CUSTOM_STEP_FALLBACK,
- prop_float, 32, 1,
- &custom_step_fallback);
prop_accel_step_motion = LibinputMakeProperty(dev,
LIBINPUT_PROP_ACCEL_CUSTOM_STEP_MOTION,
prop_float, 32, 1,
&custom_step_motion);
+ prop_accel_points_scroll = LibinputMakeProperty(dev,
+ LIBINPUT_PROP_ACCEL_CUSTOM_POINTS_SCROLL,
+ prop_float, 32,
+ custom_npoints_scroll,
+ custom_points_scroll);
+ prop_accel_step_scroll = LibinputMakeProperty(dev,
+ LIBINPUT_PROP_ACCEL_CUSTOM_STEP_SCROLL,
+ prop_float, 32, 1,
+ &custom_step_scroll);
#endif
}