From aaf4d6a32d68c8e73253632ee8ab606cb40e6e81 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 4 Mar 2015 08:24:36 +1000 Subject: [PATCH libinput] touchpad: change tap motion threshold to 3 mm Previous code used a device coordinate threshold of 300 which won't work on Elantech touchpads (1280 vs the ~4000 that synaptics has). Convert to physical coordinates first and reduce the threshold to 3mm. https://bugs.freedesktop.org/show_bug.cgi?id=89206 Signed-off-by: Peter Hutterer --- src/evdev-mt-touchpad-tap.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/evdev-mt-touchpad-tap.c b/src/evdev-mt-touchpad-tap.c index 33c6da6..d2b2989 100644 --- a/src/evdev-mt-touchpad-tap.c +++ b/src/evdev-mt-touchpad-tap.c @@ -37,7 +37,8 @@ #define CASE_RETURN_STRING(a) case a: return #a; #define DEFAULT_TAP_TIMEOUT_PERIOD 180 -#define DEFAULT_TAP_MOVE_THRESHOLD 30 +/* in mm for touchpads with resolution, see tp_init_accel() */ +#define DEFAULT_TAP_MOVE_THRESHOLD 3 enum tap_event { TAP_EVENT_TOUCH = 12, @@ -527,12 +528,15 @@ tp_tap_handle_event(struct tp_dispatch *tp, } static bool -tp_tap_exceeds_motion_threshold(struct tp_dispatch *tp, struct tp_touch *t) +tp_tap_exceeds_motion_threshold(struct tp_dispatch *tp, + struct tp_touch *t, + uint64_t time) { int threshold = DEFAULT_TAP_MOVE_THRESHOLD; double dx, dy; tp_get_delta(t, &dx, &dy); + tp_filter_motion(tp, &dx, &dx, NULL, NULL, time); return dx * dx + dy * dy > threshold * threshold; } @@ -573,7 +577,7 @@ tp_tap_handle_state(struct tp_dispatch *tp, uint64_t time) tp_tap_handle_event(tp, t, TAP_EVENT_RELEASE, time); t->tap.state = TAP_TOUCH_STATE_IDLE; } else if (tp->tap.state != TAP_STATE_IDLE && - tp_tap_exceeds_motion_threshold(tp, t)) { + tp_tap_exceeds_motion_threshold(tp, t, time)) { struct tp_touch *tmp; /* Any touch exceeding the threshold turns all -- 2.1.0