gestures: Filter unaccelerated deltas for gestures
authorAlexander Mikhaylenko <exalm7659@gmail.com>
Mon, 1 Mar 2021 16:09:37 +0000 (21:09 +0500)
committerPeter Hutterer <peter.hutterer@who-t.net>
Tue, 16 Mar 2021 21:29:56 +0000 (21:29 +0000)
Make sure the unaccelerated deltas are comparable to scroll deltas.

edit by whot:
The original intention of the unaccelerated motion data here was to provide
both accelerated and unaccelerated motion for gestures so it was possible to
have 1:1 mapping from gesture motion to screen activity.

Normalizing to 1000dpi this way would've worked for mice but touchpad
acceleration also includes the TP_MAGIC_SLOWDOWN (amongst other tricks) which
slows down motion to around 27% *before* applying the acceleration function.
On a 1000dpi touchpad (~40 units/mm) simply normalizing touchpad motion to
1000dpi results in pointer motion that is way too fast, it's lacking that
slowdown to 27% of original speed.

This results in the accelerated and unaccelerated gesture data being in
effectively two different coordinate systems with the caller having no ability
to relate the two.

Switching to the special constant acceleration applies that slowdown and
matches the data to the part of the acceleration curve where no (additional)
acceleration is applied.

It makes the gesture unaccelerated data comparable to the accelerated data
and to scroll data which uses the same process.

Fixes #582

Signed-off-by: Alexander Mikhaylenko <alexm@gnome.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
src/evdev-mt-touchpad-gestures.c

index 22392f7..c50fa96 100644 (file)
@@ -636,7 +636,7 @@ tp_gesture_handle_state_swipe(struct tp_dispatch *tp, uint64_t time)
        delta = tp_filter_motion(tp, &raw, time);
 
        if (!normalized_is_zero(delta) || !device_float_is_zero(raw)) {
-               unaccel = tp_normalize_delta(tp, raw);
+               unaccel = tp_filter_motion_unaccelerated(tp, &raw, time);
                tp_gesture_start(tp, time);
                gesture_notify_swipe(&tp->device->base, time,
                                     LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE,
@@ -674,7 +674,7 @@ tp_gesture_handle_state_pinch(struct tp_dispatch *tp, uint64_t time)
            scale == tp->gesture.prev_scale && angle_delta == 0.0)
                return GESTURE_STATE_PINCH;
 
-       unaccel = tp_normalize_delta(tp, fdelta);
+       unaccel = tp_filter_motion_unaccelerated(tp, &fdelta, time);
        tp_gesture_start(tp, time);
        gesture_notify_pinch(&tp->device->base, time,
                             LIBINPUT_EVENT_GESTURE_PINCH_UPDATE,