[PATCH libinput 2/4] touchpad: change the stylus palm arbitration to process touches

Peter Hutterer peter.hutterer at who-t.net
Wed Feb 21 06:22:30 UTC 2018


Previously, on touch toggle (invoked by the tablet when a pen goes in
proximity) the touchpad cleared the state and ignored any events. Since we
ignore touches that we didn't see the touch begin for, this handled the cases
of a touch remaining after proximity out.

This code pre-dates palm detection, so let's take the bluetack off and instead
integrate it with proper palm detectino.
---
 src/evdev-mt-touchpad.c | 30 +++++++++++++++++++++++-------
 src/evdev-mt-touchpad.h |  5 ++---
 2 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
index fdb7b452..dfc975e7 100644
--- a/src/evdev-mt-touchpad.c
+++ b/src/evdev-mt-touchpad.c
@@ -907,6 +907,19 @@ tp_palm_detect_pressure_triggered(struct tp_dispatch *tp,
 	return t->palm.state == PALM_PRESSURE;
 }
 
+static bool
+tp_palm_detect_arbitration_triggered(struct tp_dispatch *tp,
+				     struct tp_touch *t,
+				     uint64_t time)
+{
+	if (!tp->in_arbitration)
+		return false;
+
+	t->palm.state = PALM_ARBITRATION;
+
+	return true;
+}
+
 static void
 tp_palm_detect(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
 {
@@ -916,6 +929,9 @@ tp_palm_detect(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
 	if (tp_palm_detect_pressure_triggered(tp, t, time))
 		goto out;
 
+	if (tp_palm_detect_arbitration_triggered(tp, t, time))
+		goto out;
+
 	if (tp_palm_detect_dwt_triggered(tp, t, time))
 		goto out;
 
@@ -965,6 +981,9 @@ out:
 	case PALM_TOUCH_SIZE:
 		palm_state = "touch size";
 		break;
+	case PALM_ARBITRATION:
+		palm_state = "arbitration";
+		break;
 	case PALM_NONE:
 	default:
 		abort();
@@ -1600,9 +1619,6 @@ tp_interface_process(struct evdev_dispatch *dispatch,
 {
 	struct tp_dispatch *tp = tp_dispatch(dispatch);
 
-	if (tp->ignore_events)
-		return;
-
 	switch (e->type) {
 	case EV_ABS:
 		if (tp->has_mt)
@@ -2291,15 +2307,15 @@ tp_interface_toggle_touch(struct evdev_dispatch *dispatch,
 			  bool enable)
 {
 	struct tp_dispatch *tp = tp_dispatch(dispatch);
-	bool ignore_events = !enable;
+	bool arbitrate = !enable;
 
-	if (ignore_events == tp->ignore_events)
+	if (arbitrate == tp->in_arbitration)
 		return;
 
-	if (ignore_events)
+	if (arbitrate)
 		tp_clear_state(tp);
 
-	tp->ignore_events = ignore_events;
+	tp->in_arbitration = arbitrate;
 }
 
 static struct evdev_dispatch_interface tp_interface = {
diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h
index 8f35ef0a..55244064 100644
--- a/src/evdev-mt-touchpad.h
+++ b/src/evdev-mt-touchpad.h
@@ -60,6 +60,7 @@ enum touch_palm_state {
 	PALM_TOOL_PALM,
 	PALM_PRESSURE,
 	PALM_TOUCH_SIZE,
+	PALM_ARBITRATION,
 };
 
 enum button_event {
@@ -239,9 +240,7 @@ struct tp_dispatch {
 	bool has_mt;
 	bool semi_mt;
 
-	/* true if we're reading events (i.e. not suspended) but we're
-	 * ignoring them */
-	bool ignore_events;
+	bool in_arbitration; /* pen/touch arbitration */
 
 	unsigned int num_slots;			/* number of slots */
 	unsigned int ntouches;			/* no slots inc. fakes */
-- 
2.14.3



More information about the wayland-devel mailing list