Commit 2b33445b authored by Peter Hutterer's avatar Peter Hutterer

touchpad: use the same speed for scrolling as the baseline of the accel curve

Scrolling and gestures use unaccelerated motion. The idea behind it was that
at least for the default speed setting of 0, the accelerated speed and
unaccelerated speed are identical where meaningful.

The touchpad speed curve has a plateau for 'normal' speeds (i.e. not very slow
and not very fast) where the acceleration factor is constant. This is the
reference factor that the unaccelerated motion should use as well.

Since the touchpad acceleration rework in d6e53134 the reference factor is
0.9 * TP_MAGIC_SLOWDOWN (previously the factor was 1.0 * TP_MAGIC_SLOWDOWN)
and scroll motion is thus 10% faster than the pointer movement at the default
speeds. Let's fix this and let the two match up.
Signed-off-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
parent c20d08ac
Pipeline #70254 passed with stages
in 22 minutes and 19 seconds
......@@ -187,10 +187,19 @@ touchpad_constant_filter(struct motion_filter *filter,
struct touchpad_accelerator *accel =
(struct touchpad_accelerator *)filter;
struct normalized_coords normalized;
/* We need to use the same baseline here as the accelerated code,
* otherwise our unaccelerated speed is different to the accelerated
* speed on the plateau.
*
* This is a hack, the baseline should be incorporated into the
* TP_MAGIC_SLOWDOWN so we only have one number here but meanwhile
* this will do.
*/
const double baseline = 0.9;
normalized = normalize_for_dpi(unaccelerated, accel->dpi);
normalized.x = TP_MAGIC_SLOWDOWN * normalized.x;
normalized.y = TP_MAGIC_SLOWDOWN * normalized.y;
normalized.x = baseline * TP_MAGIC_SLOWDOWN * normalized.x;
normalized.y = baseline * TP_MAGIC_SLOWDOWN * normalized.y;
return normalized;
}
......
......@@ -150,13 +150,13 @@ START_TEST(touchpad_2fg_scroll)
litest_drain_events(li);
test_2fg_scroll(dev, 0.1, 40, false);
litest_assert_scroll(li, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL, 10);
litest_assert_scroll(li, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL, 9);
test_2fg_scroll(dev, 0.1, -40, false);
litest_assert_scroll(li, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL, -10);
litest_assert_scroll(li, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL, -9);
test_2fg_scroll(dev, 40, 0.1, false);
litest_assert_scroll(li, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL, 10);
litest_assert_scroll(li, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL, 9);
test_2fg_scroll(dev, -40, 0.1, false);
litest_assert_scroll(li, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL, -10);
litest_assert_scroll(li, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL, -9);
/* 2fg scroll smaller than the threshold should not generate events */
test_2fg_scroll(dev, 0.1, 0.1, true);
......@@ -602,13 +602,13 @@ START_TEST(touchpad_scroll_natural_2fg)
libinput_device_config_scroll_set_natural_scroll_enabled(dev->libinput_device, 1);
test_2fg_scroll(dev, 0.1, 40, false);
litest_assert_scroll(li, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL, -10);
litest_assert_scroll(li, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL, -9);
test_2fg_scroll(dev, 0.1, -40, false);
litest_assert_scroll(li, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL, 10);
litest_assert_scroll(li, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL, 9);
test_2fg_scroll(dev, 40, 0.1, false);
litest_assert_scroll(li, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL, -10);
litest_assert_scroll(li, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL, -9);
test_2fg_scroll(dev, -40, 0.1, false);
litest_assert_scroll(li, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL, 10);
litest_assert_scroll(li, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL, 9);
}
END_TEST
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment