summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2014-09-16 15:13:00 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2016-04-28 10:01:20 +1000
commit6a22eed4efa2a18664d62c6d8131c05258f869ab (patch)
treea4313b12701bd522fa5f6acb10443246f30536ca /src
parent774be50e68b2d62d9dfbfa3bfffd59be7e89bf3c (diff)
touchpad: detect and warn about kernel tracking pointer jumps
If a touch moves by more than 20mm within a single frame, reset the motion history, effectively discarding the movement. This is a relatively common bug and almost always needs a kernel fix, so add an explanatory page to the docs. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'src')
-rw-r--r--src/evdev-mt-touchpad.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
index 1974e2a0..4c8c3a3a 100644
--- a/src/evdev-mt-touchpad.c
+++ b/src/evdev-mt-touchpad.c
@@ -906,6 +906,25 @@ tp_need_motion_history_reset(struct tp_dispatch *tp)
return rc;
}
+static bool
+tp_detect_jumps(const struct tp_dispatch *tp, struct tp_touch *t)
+{
+ struct device_coords *last;
+ double dx, dy;
+ const int JUMP_THRESHOLD_MM = 20;
+
+ if (t->history.count == 0)
+ return false;
+
+ /* called before tp_motion_history_push, so offset 0 is the most
+ * recent coordinate */
+ last = tp_motion_history_offset(t, 0);
+ dx = fabs(t->point.x - last->x) / tp->device->abs.absinfo_x->resolution;
+ dy = fabs(t->point.y - last->y) / tp->device->abs.absinfo_y->resolution;
+
+ return hypot(dx, dy) > JUMP_THRESHOLD_MM;
+}
+
static void
tp_process_state(struct tp_dispatch *tp, uint64_t time)
{
@@ -937,6 +956,14 @@ tp_process_state(struct tp_dispatch *tp, uint64_t time)
if (t->pressure_delta < -7)
tp_motion_history_reset(t);
+ if (tp_detect_jumps(tp, t)) {
+ log_bug_kernel(tp_libinput_context(tp),
+ "Touch jump detected and discarded.\n"
+ "See %stouchpad_jumping_cursor for details\n",
+ HTTP_DOC_LINK);
+ tp_motion_history_reset(t);
+ }
+
tp_thumb_detect(tp, t, time);
tp_palm_detect(tp, t, time);