mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-25 00:00:14 +01:00
touchpad: fix the trackpoint event counter for the T460s
Introduced in 416fa44d80 but there was a logic
error: we claimed to require 3 events from a trackpoint before stopping the
touchpad but the timer was only set when we actually stopped the touchpad. So
if a trackpoint sends a single event every second, we'd disable the touchpad
after 3 seconds for the duration of the timeout, then again 3 seconds later,
etc.
Fix this by always setting the timeout and resetting the event counter if no
activity happened.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
7d06ccc061
commit
c0fd857def
2 changed files with 40 additions and 3 deletions
|
|
@ -31,6 +31,7 @@
|
|||
#include "evdev-mt-touchpad.h"
|
||||
|
||||
#define DEFAULT_TRACKPOINT_ACTIVITY_TIMEOUT ms2us(300)
|
||||
#define DEFAULT_TRACKPOINT_EVENT_TIMEOUT ms2us(40)
|
||||
#define DEFAULT_KEYBOARD_ACTIVITY_TIMEOUT_1 ms2us(200)
|
||||
#define DEFAULT_KEYBOARD_ACTIVITY_TIMEOUT_2 ms2us(500)
|
||||
#define THUMB_MOVE_TIMEOUT ms2us(300)
|
||||
|
|
@ -1945,8 +1946,10 @@ tp_trackpoint_timeout(uint64_t now, void *data)
|
|||
{
|
||||
struct tp_dispatch *tp = data;
|
||||
|
||||
tp_tap_resume(tp, now);
|
||||
tp->palm.trackpoint_active = false;
|
||||
if (tp->palm.trackpoint_active) {
|
||||
tp_tap_resume(tp, now);
|
||||
tp->palm.trackpoint_active = false;
|
||||
}
|
||||
tp->palm.trackpoint_event_count = 0;
|
||||
}
|
||||
|
||||
|
|
@ -1963,9 +1966,13 @@ tp_trackpoint_event(uint64_t time, struct libinput_event *event, void *data)
|
|||
tp->palm.trackpoint_last_event_time = time;
|
||||
tp->palm.trackpoint_event_count++;
|
||||
|
||||
|
||||
/* Require at least three events before enabling palm detection */
|
||||
if (tp->palm.trackpoint_event_count < 3)
|
||||
if (tp->palm.trackpoint_event_count < 3) {
|
||||
libinput_timer_set(&tp->palm.trackpoint_timer,
|
||||
time + DEFAULT_TRACKPOINT_EVENT_TIMEOUT);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!tp->palm.trackpoint_active) {
|
||||
tp_stop_actions(tp, time);
|
||||
|
|
|
|||
|
|
@ -379,6 +379,35 @@ START_TEST(trackpoint_palmdetect_require_min_events)
|
|||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(trackpoint_palmdetect_require_min_events_timeout)
|
||||
{
|
||||
struct litest_device *trackpoint = litest_current_device();
|
||||
struct litest_device *touchpad;
|
||||
struct libinput *li = trackpoint->libinput;
|
||||
|
||||
touchpad = litest_add_device(li, LITEST_SYNAPTICS_I2C);
|
||||
litest_drain_events(li);
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
/* A single event does not trigger palm detection */
|
||||
litest_event(trackpoint, EV_REL, REL_X, 1);
|
||||
litest_event(trackpoint, EV_REL, REL_Y, 1);
|
||||
litest_event(trackpoint, EV_SYN, SYN_REPORT, 0);
|
||||
libinput_dispatch(li);
|
||||
litest_drain_events(li);
|
||||
|
||||
litest_touch_down(touchpad, 0, 30, 30);
|
||||
litest_touch_move_to(touchpad, 0, 30, 30, 80, 80, 10, 1);
|
||||
litest_touch_up(touchpad, 0);
|
||||
litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION);
|
||||
|
||||
litest_timeout_trackpoint();
|
||||
}
|
||||
|
||||
litest_delete_device(touchpad);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
TEST_COLLECTION(trackpoint)
|
||||
{
|
||||
litest_add("trackpoint:middlebutton", trackpoint_middlebutton, LITEST_POINTINGSTICK, LITEST_ANY);
|
||||
|
|
@ -392,4 +421,5 @@ TEST_COLLECTION(trackpoint)
|
|||
litest_add("trackpoint:palmdetect", trackpoint_palmdetect, LITEST_POINTINGSTICK, LITEST_ANY);
|
||||
litest_add("trackpoint:palmdetect", trackpoint_palmdetect_resume_touch, LITEST_POINTINGSTICK, LITEST_ANY);
|
||||
litest_add("trackpoint:palmdetect", trackpoint_palmdetect_require_min_events, LITEST_POINTINGSTICK, LITEST_ANY);
|
||||
litest_add("trackpoint:palmdetect", trackpoint_palmdetect_require_min_events_timeout, LITEST_POINTINGSTICK, LITEST_ANY);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue