From 2c07d7aa94c9f2f40d72875cf19a9c6a7b3a2c69 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Fri, 10 Sep 2010 13:08:22 +0200 Subject: Inhibit taps immediately after a finger is lifted The intentional tap starts with a finger in the air. This patch treats the sequence up-down-up as unintentional, unless performed with a single finger. Fixes the problem with accidental taps during multi-finger gestures. Signed-off-by: Henrik Rydberg --- src/gestures-tapping.c | 7 ++++++- src/grail-gestures.h | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gestures-tapping.c b/src/gestures-tapping.c index 8727639..5474731 100644 --- a/src/gestures-tapping.c +++ b/src/gestures-tapping.c @@ -24,6 +24,7 @@ #include static const int TAP_MIN_GAP_MS = 25; +static const int TAP_MIN_UP_MS = 200; static const int fm_mask = 0x07; @@ -44,6 +45,9 @@ int gru_tapping(struct grail *ge, struct gesture_recognizer *gru = ge->gru; struct tapping_model *state = &gru->tapping; struct move_model *move = &gru->move; + grail_time_t up = move->time - state->end; + if (move->ntouch && move->ntouch < state->ntouch) + state->end = move->time; if (move->ntouch > state->ntouch) { if (state->active) { gin_gid_discard(ge, state->gid); @@ -67,7 +71,8 @@ int gru_tapping(struct grail *ge, int x = state->prop[GRAIL_PROP_TAP_X]; int y = state->prop[GRAIL_PROP_TAP_Y]; int t = move->time - state->start; - if (t < TAP_MIN_GAP_MS || t > move->fm[FM_X].bar_ms) { + if (t < TAP_MIN_GAP_MS || t > move->fm[FM_X].bar_ms || + up < TAP_MIN_UP_MS) { gin_gid_discard(ge, state->gid); state->ntouch = move->ntouch; state->active = 0; diff --git a/src/grail-gestures.h b/src/grail-gestures.h index 5a242d9..247acf9 100644 --- a/src/grail-gestures.h +++ b/src/grail-gestures.h @@ -97,7 +97,7 @@ int gru_winrotate(struct grail *ge, const struct touch_frame *frame); struct tapping_model { - grail_time_t start; + grail_time_t start, end; int ntouch; int active, gid; int nprop; -- cgit v1.2.3