evdev: use filter_dispatch_constant() for button scrolling
authorPeter Hutterer <peter.hutterer@who-t.net>
Sun, 4 Sep 2022 23:26:21 +0000 (09:26 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Wed, 7 Sep 2022 23:03:15 +0000 (09:03 +1000)
Our pointer filter code has two functions - one for accelerated movement
and one for "constant" movement (i.e. no accel factor provided but same
conversions). Let's use that instead of a manual normalization.

This fixes an issue with button scrolling on high-dpi mice in the flat
pointer acceleration: normal pointer motion in the flat profile isn't
normalized but the button scrolling was - resulting in e.g. 5 times
slower motion for button scrolling on a 5000dpi mouse.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
src/evdev-fallback.c

index 5dc1ce4..bd5a458 100644 (file)
@@ -101,7 +101,7 @@ fallback_normalize_delta(struct evdev_device *device,
 
 static inline bool
 post_button_scroll(struct evdev_device *device,
-                  struct normalized_coords unaccel,
+                  struct device_float_coords raw,
                   uint64_t time)
 {
        if (device->scroll.method != LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN)
@@ -120,9 +120,16 @@ post_button_scroll(struct evdev_device *device,
                device->scroll.button_scroll_state = BUTTONSCROLL_SCROLLING;
                _fallthrough_;
        case BUTTONSCROLL_SCROLLING:
+               {
+               const struct normalized_coords normalized =
+                               filter_dispatch_constant(device->pointer.filter,
+                                                        &raw,
+                                                        device,
+                                                        time);
                evdev_post_scroll(device, time,
                                  LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS,
-                                 &unaccel);
+                                 &normalized);
+               }
                return true;
        }
 
@@ -175,7 +182,7 @@ fallback_flush_relative_motion(struct fallback_dispatch *dispatch,
                               uint64_t time)
 {
        struct libinput_device *base = &device->base;
-       struct normalized_coords accel, unaccel;
+       struct normalized_coords accel;
        struct device_float_coords raw;
 
        if (!(device->seat_caps & EVDEV_DEVICE_POINTER))
@@ -183,14 +190,13 @@ fallback_flush_relative_motion(struct fallback_dispatch *dispatch,
 
        fallback_rotate_relative(dispatch, device);
 
-       fallback_normalize_delta(device, &dispatch->rel, &unaccel);
        raw.x = dispatch->rel.x;
        raw.y = dispatch->rel.y;
        dispatch->rel.x = 0;
        dispatch->rel.y = 0;
 
        /* Use unaccelerated deltas for pointing stick scroll */
-       if (post_button_scroll(device, unaccel, time))
+       if (post_button_scroll(device, raw, time))
                return;
 
        if (device->pointer.filter) {
@@ -202,10 +208,10 @@ fallback_flush_relative_motion(struct fallback_dispatch *dispatch,
        } else {
                evdev_log_bug_libinput(device,
                                       "accel filter missing\n");
-               accel = unaccel;
+               accel.x = accel.y = 0;
        }
 
-       if (normalized_is_zero(accel) && normalized_is_zero(unaccel))
+       if (normalized_is_zero(accel))
                return;
 
        pointer_notify_motion(base, time, &accel, &raw);