[PATCH libinput 4/5] touchpad: improve trackpoint palm detection responsiveness
Peter Hutterer
peter.hutterer at who-t.net
Sun Jun 28 20:49:24 PDT 2015
The touchpad is disabled for 500ms after a trackpoint event to avoid
erroneous palm touches. This is currently refreshed on every trackpoint event
and thus forces a delay of 500ms when switching between the two.
Instead, reduce the timeout to 300ms but ignore any touches started while the
trackpoint was active (i.e. before the last trackpoint event). A touch started
after the last event is released once the timeout expires.
This is the same logic used for disable-while-typing.
https://bugzilla.redhat.com/show_bug.cgi?id=1233844
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
src/evdev-mt-touchpad.c | 34 ++++++++++++++++++++++++++++++++--
src/evdev-mt-touchpad.h | 2 ++
2 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
index 792184c..538c2d7 100644
--- a/src/evdev-mt-touchpad.c
+++ b/src/evdev-mt-touchpad.c
@@ -34,7 +34,7 @@
* TP_MAGIC_SLOWDOWN in filter.c */
#define DEFAULT_ACCEL_NUMERATOR 3000.0
#define DEFAULT_HYSTERESIS_MARGIN_DENOMINATOR 700.0
-#define DEFAULT_TRACKPOINT_ACTIVITY_TIMEOUT 500 /* ms */
+#define DEFAULT_TRACKPOINT_ACTIVITY_TIMEOUT 300 /* ms */
#define DEFAULT_KEYBOARD_ACTIVITY_TIMEOUT_1 200 /* ms */
#define DEFAULT_KEYBOARD_ACTIVITY_TIMEOUT_2 500 /* ms */
#define FAKE_FINGER_OVERFLOW (1 << 7)
@@ -515,6 +515,31 @@ tp_palm_detect_dwt(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
return 0;
}
+static int
+tp_palm_detect_trackpoint(struct tp_dispatch *tp,
+ struct tp_touch *t,
+ uint64_t time)
+{
+ if (t->palm.state == PALM_NONE &&
+ t->state == TOUCH_BEGIN &&
+ tp->palm.trackpoint_active) {
+ t->palm.state = PALM_TRACKPOINT;
+ return 1;
+ } else if (t->palm.state == PALM_TRACKPOINT &&
+ t->state == TOUCH_UPDATE &&
+ !tp->palm.trackpoint_active) {
+
+ if (t->palm.time == 0 ||
+ t->palm.time > tp->palm.trackpoint_last_event_time) {
+ t->palm.state = PALM_NONE;
+ log_debug(tp_libinput_context(tp),
+ "palm: touch released, timeout after trackpoint\n");
+ }
+ }
+
+ return 0;
+}
+
static void
tp_palm_detect(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
{
@@ -526,6 +551,9 @@ tp_palm_detect(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
if (tp_palm_detect_dwt(tp, t, time))
goto out;
+ if (tp_palm_detect_trackpoint(tp, t, time))
+ goto out;
+
/* If labelled a touch as palm, we unlabel as palm when
we move out of the palm edge zone within the timeout, provided
the direction is within 45 degrees of the horizontal.
@@ -568,7 +596,8 @@ tp_palm_detect(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
out:
log_debug(tp_libinput_context(tp),
"palm: palm detected (%s)\n",
- t->palm.state == PALM_EDGE ? "edge" : "typing");
+ t->palm.state == PALM_EDGE ? "edge" :
+ t->palm.state == PALM_TYPING ? "typing" : "trackpoint");
}
static void
@@ -948,6 +977,7 @@ 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 d4a57a8..f3c2bf7 100644
--- a/src/evdev-mt-touchpad.h
+++ b/src/evdev-mt-touchpad.h
@@ -64,6 +64,7 @@ enum touch_palm_state {
PALM_NONE = 0,
PALM_EDGE,
PALM_TYPING,
+ PALM_TRACKPOINT,
};
enum button_event {
@@ -281,6 +282,7 @@ struct tp_dispatch {
bool trackpoint_active;
struct libinput_event_listener trackpoint_listener;
struct libinput_timer trackpoint_timer;
+ uint64_t trackpoint_last_event_time;
} palm;
struct {
--
2.4.3
More information about the wayland-devel
mailing list