[PATCH libinput 11/19] touchpad: Filter motion in a certain number of tap states
Peter Hutterer
peter.hutterer at who-t.net
Sun Feb 16 22:48:30 PST 2014
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
src/evdev-mt-touchpad-tap.c | 23 ++++++++++++++++++++++-
src/evdev-mt-touchpad.c | 22 +++++++++++-----------
src/evdev-mt-touchpad.h | 1 +
3 files changed, 34 insertions(+), 12 deletions(-)
diff --git a/src/evdev-mt-touchpad-tap.c b/src/evdev-mt-touchpad-tap.c
index 7ac592b..bc7acbd 100644
--- a/src/evdev-mt-touchpad-tap.c
+++ b/src/evdev-mt-touchpad-tap.c
@@ -504,6 +504,7 @@ int
tp_tap_handle_state(struct tp_dispatch *tp, uint32_t time)
{
struct tp_touch *t;
+ int filter_motion = 0;
if (tp->queued & TOUCHPAD_EVENT_BUTTON_PRESS)
tp_tap_handle_event(tp, TAP_EVENT_BUTTON, time);
@@ -521,7 +522,27 @@ tp_tap_handle_state(struct tp_dispatch *tp, uint32_t time)
tp_tap_handle_event(tp, TAP_EVENT_MOTION, time);
}
- return 0;
+ /**
+ * In any state where motion exceeding the move threshold would
+ * move to the next state, filter that motion until we actually
+ * exceed it. This prevents small motion events while we're waiting
+ * on a decision if a tap is a tap.
+ */
+ switch (tp->tap.state) {
+ case TAP_STATE_TOUCH:
+ case TAP_STATE_TAPPED:
+ case TAP_STATE_DRAGGING_OR_DOUBLETAP:
+ case TAP_STATE_TOUCH_2:
+ case TAP_STATE_TOUCH_3:
+ filter_motion = 1;
+ break;
+
+ default:
+ break;
+
+ }
+
+ return filter_motion;
}
static void
diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
index d1268f6..873ddf0 100644
--- a/src/evdev-mt-touchpad.c
+++ b/src/evdev-mt-touchpad.c
@@ -369,20 +369,20 @@ tp_post_events(struct tp_dispatch *tp, uint32_t time)
return;
}
- tp_tap_handle_state(tp, time);
-
- if (t->history.count < 4)
+ if (tp_tap_handle_state(tp, time) != 0)
return;
- tp_get_delta(t, &dx, &dy);
- tp_filter_motion(tp, &dx, &dy, time);
+ if (t->history.count >= TOUCHPAD_MIN_SAMPLES) {
+ tp_get_delta(t, &dx, &dy);
+ tp_filter_motion(tp, &dx, &dy, time);
- if (dx != 0 || dy != 0)
- pointer_notify_motion(
- &tp->device->base,
- time,
- li_fixed_from_double(dx),
- li_fixed_from_double(dy));
+ if (dx != 0 || dy != 0)
+ pointer_notify_motion(
+ &tp->device->base,
+ time,
+ li_fixed_from_double(dx),
+ li_fixed_from_double(dy));
+ }
tp_post_button_events(tp, time);
}
diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h
index 973b478..a5cfaa6 100644
--- a/src/evdev-mt-touchpad.h
+++ b/src/evdev-mt-touchpad.h
@@ -30,6 +30,7 @@
#include "filter.h"
#define TOUCHPAD_HISTORY_LENGTH 4
+#define TOUCHPAD_MIN_SAMPLES 4
enum touchpad_event {
TOUCHPAD_EVENT_NONE = 0,
--
1.8.4.2
More information about the wayland-devel
mailing list