From 9ddff3b1ac385593b8bafabc7e7871ef4d3b6e6f Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 8 Sep 2016 10:29:00 +1000 Subject: [PATCH] Avoid spurious trackpoint events halting the touchpad (related #1364850) --- ...-at-least-3-events-before-enabling-t.patch | 113 ++++++++++++++++++ libinput.spec | 6 +- 2 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 0001-touchpad-require-at-least-3-events-before-enabling-t.patch diff --git a/0001-touchpad-require-at-least-3-events-before-enabling-t.patch b/0001-touchpad-require-at-least-3-events-before-enabling-t.patch new file mode 100644 index 0000000..00247ed --- /dev/null +++ b/0001-touchpad-require-at-least-3-events-before-enabling-t.patch @@ -0,0 +1,113 @@ +From d725d39ddd56166d1f6c24094b493777831a36c1 Mon Sep 17 00:00:00 2001 +From: Peter Hutterer +Date: Wed, 7 Sep 2016 08:18:33 +1000 +Subject: [PATCH libinput] touchpad: require at least 3 events before enabling + trackpoint palm detection + +Some trackpoints, notably the one on the Lenovo T460s have a tendency to send +the odd event even when they're not actually used. Trackpoint events trigger +palm detection (see 0210f1fee193) and thus effectively disable the touchpad, +causing the touchpad to appear nonresponsive. + +Fix this by requiring at least 3 events from a trackpoint before palm +detection is enabled. For normal use it's hard enough to trigger a single +event anyway so this should not affect the normal use-case. + +Signed-off-by: Peter Hutterer +--- + src/evdev-mt-touchpad.c | 9 ++++++++- + src/evdev-mt-touchpad.h | 1 + + test/trackpoint.c | 26 ++++++++++++++++++++++++++ + 3 files changed, 35 insertions(+), 1 deletion(-) + +diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c +index 2354061..38b638b 100644 +--- a/src/evdev-mt-touchpad.c ++++ b/src/evdev-mt-touchpad.c +@@ -1305,6 +1305,7 @@ tp_trackpoint_timeout(uint64_t now, void *data) + + tp_tap_resume(tp, now); + tp->palm.trackpoint_active = false; ++ tp->palm.trackpoint_event_count = 0; + } + + static void +@@ -1317,6 +1318,13 @@ tp_trackpoint_event(uint64_t time, struct libinput_event *event, void *data) + if (event->type == LIBINPUT_EVENT_POINTER_BUTTON) + return; + ++ 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) ++ return; ++ + if (!tp->palm.trackpoint_active) { + tp_edge_scroll_stop_events(tp, time); + tp_gesture_cancel(tp, time); +@@ -1324,7 +1332,6 @@ tp_trackpoint_event(uint64_t time, struct libinput_event *event, void *data) + tp->palm.trackpoint_active = true; + } + +- tp->palm.trackpoint_last_event_time = time; + libinput_timer_set(&tp->palm.trackpoint_timer, + time + DEFAULT_TRACKPOINT_ACTIVITY_TIMEOUT); + } +diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h +index de9bdb5..f4ad090 100644 +--- a/src/evdev-mt-touchpad.h ++++ b/src/evdev-mt-touchpad.h +@@ -341,6 +341,7 @@ struct tp_dispatch { + struct libinput_event_listener trackpoint_listener; + struct libinput_timer trackpoint_timer; + uint64_t trackpoint_last_event_time; ++ uint32_t trackpoint_event_count; + bool monitor_trackpoint; + } palm; + +diff --git a/test/trackpoint.c b/test/trackpoint.c +index b92b994..e9ba027 100644 +--- a/test/trackpoint.c ++++ b/test/trackpoint.c +@@ -349,6 +349,31 @@ START_TEST(trackpoint_palmdetect_resume_touch) + } + END_TEST + ++START_TEST(trackpoint_palmdetect_require_min_events) ++{ ++ 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); ++ ++ /* 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_delete_device(touchpad); ++} ++END_TEST ++ + void + litest_setup_tests_trackpoint(void) + { +@@ -362,4 +387,5 @@ litest_setup_tests_trackpoint(void) + + 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); + } +-- +2.7.4 + diff --git a/libinput.spec b/libinput.spec index 8649362..7c31c73 100644 --- a/libinput.spec +++ b/libinput.spec @@ -5,7 +5,7 @@ Name: libinput Version: 1.4.901 -Release: 1%{?gitdate:.%{gitdate}git%{gitversion}}%{?dist} +Release: 2%{?gitdate:.%{gitdate}git%{gitversion}}%{?dist} Summary: Input device library License: MIT @@ -20,6 +20,7 @@ Source0: http://www.freedesktop.org/software/libinput/libinput-%{version} # Not upstream, keep until kernel 4.2 or 4.1.x with dbf3c37086 Patch01: 0001-touchpad-serial-synaptics-need-to-fake-new-touches-o.patch +Patch02: 0001-touchpad-require-at-least-3-events-before-enabling-t.patch BuildRequires: git BuildRequires: autoconf automake libtool pkgconfig @@ -97,6 +98,9 @@ find $RPM_BUILD_ROOT -name '*.la' -delete %changelog +* Thu Sep 08 2016 Peter Hutterer 1.4.901-2 +- Avoid spurious trackpoint events halting the touchpad (related #1364850) + * Wed Sep 07 2016 Peter Hutterer 1.4.901-1 - libinput 1.5rc1