On the very first event, the last_motion_time set by tp_begin_touch is not yet
set because we are called before the pressure-based touch detection takes
effect. And any event timestamp is more than 80ms after a zero timestamp,
causing the hysteresis to always be disabled.

https://bugs.freedesktop.org/show_bug.cgi?id=98839#c74

Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net>
---
 src/evdev-mt-touchpad.c | 3 ++-
 test/test-touchpad.c    | 4 ++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
index 52df8fd2..df0b0633 100644
--- a/src/evdev-mt-touchpad.c
+++ b/src/evdev-mt-touchpad.c
@@ -136,7 +136,8 @@ tp_maybe_disable_hysteresis(struct tp_dispatch *tp, 
uint64_t time)
 {
        /* If the finger is down for 80ms without seeing motion events,
           the firmware filters and we don't need a software hysteresis */
-       if (time - tp->hysteresis.last_motion_time > ms2us(80)) {
+       if (tp->nfingers_down >= 1 &&
+           time - tp->hysteresis.last_motion_time > ms2us(80)) {
                tp->hysteresis.enabled = false;
                evdev_log_debug(tp->device, "hysteresis disabled\n");
                return;
diff --git a/test/test-touchpad.c b/test/test-touchpad.c
index 808c0639..836640b7 100644
--- a/test/test-touchpad.c
+++ b/test/test-touchpad.c
@@ -642,6 +642,10 @@ START_TEST(touchpad_edge_scroll_timeout)
        /* move 0.5mm, enough to load up the motion history, but less than
         * the scroll threshold of 2mm */
        litest_touch_down(dev, 0, 99, 20);
+       libinput_dispatch(li);
+       litest_timeout_hysteresis();
+       libinput_dispatch(li);
+
        litest_touch_move_to(dev, 0, 99, 20, 99, 20 + mm/2, 8, 0);
        libinput_dispatch(li);
        litest_assert_empty_queue(li);
-- 
2.13.6

_______________________________________________
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to