[PATCH libinput 1/3] touchpad: switch from is_palm to an enum

Peter Hutterer peter.hutterer at who-t.net
Wed May 6 23:53:25 PDT 2015


Preparation to add different palm detection types. Not all of them need to be
un-done when leaving the edge area so a boolean is not enough.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/evdev-mt-touchpad.c | 10 +++++-----
 src/evdev-mt-touchpad.h |  7 ++++++-
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
index 79177fb..d8b44fa 100644
--- a/src/evdev-mt-touchpad.c
+++ b/src/evdev-mt-touchpad.c
@@ -231,7 +231,7 @@ tp_end_touch(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
 	}
 
 	t->dirty = true;
-	t->palm.is_palm = false;
+	t->palm.state = PALM_NONE;
 	t->state = TOUCH_END;
 	t->pinned.is_pinned = false;
 	t->millis = time;
@@ -455,7 +455,7 @@ int
 tp_touch_active(struct tp_dispatch *tp, struct tp_touch *t)
 {
 	return (t->state == TOUCH_BEGIN || t->state == TOUCH_UPDATE) &&
-		!t->palm.is_palm &&
+		t->palm.state == PALM_NONE &&
 		!t->pinned.is_pinned &&
 		tp_button_touch_active(tp, t) &&
 		tp_edge_scroll_touch_active(tp, t);
@@ -491,14 +491,14 @@ tp_palm_detect(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
 	   we move out of the palm edge zone within the timeout, provided
 	   the direction is within 45 degrees of the horizontal.
 	 */
-	if (t->palm.is_palm) {
+	if (t->palm.state == PALM_EDGE) {
 		if (time < t->palm.time + PALM_TIMEOUT &&
 		    (t->point.x > tp->palm.left_edge && t->point.x < tp->palm.right_edge)) {
 			delta = device_delta(t->point, t->palm.first);
 			dirs = normalized_get_direction(
 						tp_normalize_delta(tp, delta));
 			if ((dirs & DIRECTIONS) && !(dirs & ~DIRECTIONS)) {
-				t->palm.is_palm = false;
+				t->palm.state = PALM_NONE;
 			}
 		}
 		return;
@@ -517,7 +517,7 @@ tp_palm_detect(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
 	    tp_button_is_inside_softbutton_area(tp, t))
 		return;
 
-	t->palm.is_palm = true;
+	t->palm.state = PALM_EDGE;
 	t->palm.time = time;
 	t->palm.first = t->point;
 }
diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h
index 3711375..ebfc79c 100644
--- a/src/evdev-mt-touchpad.h
+++ b/src/evdev-mt-touchpad.h
@@ -61,6 +61,11 @@ enum touch_state {
 	TOUCH_END
 };
 
+enum touch_palm_state {
+	PALM_NONE = 0,
+	PALM_EDGE,
+};
+
 enum button_event {
 	BUTTON_EVENT_IN_BOTTOM_R = 30,
 	BUTTON_EVENT_IN_BOTTOM_L,
@@ -170,7 +175,7 @@ struct tp_touch {
 	} scroll;
 
 	struct {
-		bool is_palm;
+		enum touch_palm_state state;
 		struct device_coords first; /* first coordinates if is_palm == true */
 		uint32_t time; /* first timestamp if is_palm == true */
 	} palm;
-- 
2.3.5



More information about the wayland-devel mailing list