touchpad: drop the tap finger count
authorPeter Hutterer <peter.hutterer@who-t.net>
Mon, 4 May 2015 06:22:36 +0000 (16:22 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Mon, 4 May 2015 21:44:18 +0000 (07:44 +1000)
Use tp->nfingers_down as trigger when we have no fingers left on the touchpad
and when we should return to idle. If all touchpoints end in the same frame
tp->nfingers is 0. Thus when we handle the first tap release we transition to
IDLE which now needs to handle (and discard) any touch release events.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
src/evdev-mt-touchpad-tap.c
src/evdev-mt-touchpad.h

index 70c45ff..61f94e5 100644 (file)
@@ -154,6 +154,7 @@ tp_tap_idle_handle_event(struct tp_dispatch *tp,
                tp_tap_set_timer(tp, time);
                break;
        case TAP_EVENT_RELEASE:
+               break;
        case TAP_EVENT_MOTION:
                log_bug_libinput(libinput,
                                 "invalid tap event, no fingers are down\n");
@@ -531,7 +532,7 @@ tp_tap_dead_handle_event(struct tp_dispatch *tp,
 
        switch (event) {
        case TAP_EVENT_RELEASE:
-               if (tp->tap.tap_finger_count == 0)
+               if (tp->nfingers_down == 0)
                        tp->tap.state = TAP_STATE_IDLE;
                break;
        case TAP_EVENT_TOUCH:
@@ -652,7 +653,6 @@ tp_tap_handle_state(struct tp_dispatch *tp, uint64_t time)
                        t->tap.state = TAP_TOUCH_STATE_DEAD;
 
                if (t->state == TOUCH_BEGIN) {
-                       tp->tap.tap_finger_count++;
                        t->tap.state = TAP_TOUCH_STATE_TOUCH;
                        t->tap.initial = t->point;
                        tp_tap_handle_event(tp, t, TAP_EVENT_TOUCH, time);
@@ -665,7 +665,6 @@ tp_tap_handle_state(struct tp_dispatch *tp, uint64_t time)
                                tp_tap_handle_event(tp, t, TAP_EVENT_MOTION, time);
 
                } else if (t->state == TOUCH_END) {
-                       tp->tap.tap_finger_count--;
                        tp_tap_handle_event(tp, t, TAP_EVENT_RELEASE, time);
                        t->tap.state = TAP_TOUCH_STATE_IDLE;
                } else if (tp->tap.state != TAP_STATE_IDLE &&
@@ -850,7 +849,6 @@ tp_release_all_taps(struct tp_dispatch *tp, uint64_t now)
        }
 
        tp->tap.state = tp->nfingers_down ? TAP_STATE_DEAD : TAP_STATE_IDLE;
-       tp->tap.tap_finger_count = 0;
 }
 
 void
index 97b17cd..d4f5874 100644 (file)
@@ -257,7 +257,6 @@ struct tp_dispatch {
                struct libinput_timer timer;
                enum tp_tap_state state;
                uint32_t buttons_pressed;
-               unsigned int tap_finger_count;
                uint64_t multitap_last_time;
        } tap;