touchpad: don't disable the hysteresis unless a finger is down

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.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2018-01-08 10:39:48 +10:00
parent 932911d229
commit f5a9e38c90
2 changed files with 6 additions and 1 deletions

View file

@ -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;

View file

@ -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);