From d7d89e2afae9151f4d16aa71a99eedbf920ecc1a Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Wed, 4 Aug 2010 22:25:32 +0200 Subject: tapping: Cancel early in case of one-finger movement Signed-off-by: Henrik Rydberg --- src/gestures-tapping.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/gestures-tapping.c') diff --git a/src/gestures-tapping.c b/src/gestures-tapping.c index 1c07b6c..763bc43 100644 --- a/src/gestures-tapping.c +++ b/src/gestures-tapping.c @@ -33,7 +33,7 @@ static const int TAP_MIN_GAP_MS = 25; static const int TAP_MAX_GAP_MS = 300; int gru_tapping(struct grail *ge, - const struct touch_frame *frame) + const struct touch_frame *frame) { struct gesture_recognizer *gru = ge->gru; struct tapping_model *state = &gru->tapping; @@ -44,13 +44,19 @@ int gru_tapping(struct grail *ge, return 0; state->status = TAP_BEGIN; if (!state->ntouch) - state->start = frame->time; + state->start = move->time; if (move->ntouch > state->ntouch) { state->ntouch = move->ntouch; if (state->active) { gin_gid_discard(ge, state->gid); state->active = 0; } + state->x = move->x.val; + state->y = move->y.val; + } else if (state->ntouch == 1) { + if (fabs(move->x.val - state->x) > move->y.bar || + fabs(move->y.val - state->y) > move->y.bar) + state->status = TAP_CANCEL; } if (!state->active) { int type = GRAIL_TYPE_TAP1 + state->ntouch - 1; @@ -66,10 +72,10 @@ int gru_tapping(struct grail *ge, } if (state->ntouch < 1 || state->ntouch > 5) state->status = TAP_CANCEL; - if (frame->time - state->start > TAP_MAX_GAP_MS) + if (move->time - state->start > TAP_MAX_GAP_MS) state->status = TAP_CANCEL; if (state->status == TAP_END && - frame->time - state->start < TAP_MIN_GAP_MS) + move->time - state->start < TAP_MIN_GAP_MS) state->status = TAP_CANCEL; if (state->status == TAP_CANCEL) { if (state->active) { @@ -80,9 +86,9 @@ int gru_tapping(struct grail *ge, return 0; } if (state->status != TAP_END || - frame->time - state->start < TAP_MIN_GAP_MS) + move->time - state->start < TAP_MIN_GAP_MS) return 0; - prop[0] = frame->time - state->start; + prop[0] = move->time - state->start; gin_gid_event(ge, state->gid, move->x.val, move->y.val, state->ntouch, prop, 1, GRAIL_STATUS_END); -- cgit v1.2.3