touchpad: switch from is_palm to an enum
authorPeter Hutterer <peter.hutterer@who-t.net>
Mon, 20 Apr 2015 06:09:31 +0000 (16:09 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Mon, 18 May 2015 04:39:21 +0000 (14:39 +1000)
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@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
src/evdev-mt-touchpad.c
src/evdev-mt-touchpad.h

index 79177fb0cb535a9363be57146dc7b0821d8dfa16..d8b44fa6c633ebbb8849295b5f9f4ba0da6da5eb 100644 (file)
@@ -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;
 }
index f602359f0791166adfa6a553647bbc9a66b02872..ba65e413f9d09c36debe15f44b73bf27a57419f9 100644 (file)
@@ -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,
@@ -171,7 +176,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;