summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@bitmath.org>2010-08-04 22:25:32 +0200
committerHenrik Rydberg <rydberg@euromail.se>2010-08-05 22:48:38 +0200
commitd7d89e2afae9151f4d16aa71a99eedbf920ecc1a (patch)
tree39e64ea84e9884918b385d62bebc3773da58e53a /src
parent88dada465e0fad35b5a535a042e0a93046ffff7c (diff)
tapping: Cancel early in case of one-finger movement
Signed-off-by: Henrik Rydberg <rydberg@bitmath.org>
Diffstat (limited to 'src')
-rw-r--r--src/gestures-tapping.c18
-rw-r--r--src/grail-gestures.h1
2 files changed, 13 insertions, 6 deletions
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;
33static const int TAP_MAX_GAP_MS = 300; 33static const int TAP_MAX_GAP_MS = 300;
34 34
35int gru_tapping(struct grail *ge, 35int gru_tapping(struct grail *ge,
36 const struct touch_frame *frame) 36 const struct touch_frame *frame)
37{ 37{
38 struct gesture_recognizer *gru = ge->gru; 38 struct gesture_recognizer *gru = ge->gru;
39 struct tapping_model *state = &gru->tapping; 39 struct tapping_model *state = &gru->tapping;
@@ -44,13 +44,19 @@ int gru_tapping(struct grail *ge,
44 return 0; 44 return 0;
45 state->status = TAP_BEGIN; 45 state->status = TAP_BEGIN;
46 if (!state->ntouch) 46 if (!state->ntouch)
47 state->start = frame->time; 47 state->start = move->time;
48 if (move->ntouch > state->ntouch) { 48 if (move->ntouch > state->ntouch) {
49 state->ntouch = move->ntouch; 49 state->ntouch = move->ntouch;
50 if (state->active) { 50 if (state->active) {
51 gin_gid_discard(ge, state->gid); 51 gin_gid_discard(ge, state->gid);
52 state->active = 0; 52 state->active = 0;
53 } 53 }
54 state->x = move->x.val;
55 state->y = move->y.val;
56 } else if (state->ntouch == 1) {
57 if (fabs(move->x.val - state->x) > move->y.bar ||
58 fabs(move->y.val - state->y) > move->y.bar)
59 state->status = TAP_CANCEL;
54 } 60 }
55 if (!state->active) { 61 if (!state->active) {
56 int type = GRAIL_TYPE_TAP1 + state->ntouch - 1; 62 int type = GRAIL_TYPE_TAP1 + state->ntouch - 1;
@@ -66,10 +72,10 @@ int gru_tapping(struct grail *ge,
66 } 72 }
67 if (state->ntouch < 1 || state->ntouch > 5) 73 if (state->ntouch < 1 || state->ntouch > 5)
68 state->status = TAP_CANCEL; 74 state->status = TAP_CANCEL;
69 if (frame->time - state->start > TAP_MAX_GAP_MS) 75 if (move->time - state->start > TAP_MAX_GAP_MS)
70 state->status = TAP_CANCEL; 76 state->status = TAP_CANCEL;
71 if (state->status == TAP_END && 77 if (state->status == TAP_END &&
72 frame->time - state->start < TAP_MIN_GAP_MS) 78 move->time - state->start < TAP_MIN_GAP_MS)
73 state->status = TAP_CANCEL; 79 state->status = TAP_CANCEL;
74 if (state->status == TAP_CANCEL) { 80 if (state->status == TAP_CANCEL) {
75 if (state->active) { 81 if (state->active) {
@@ -80,9 +86,9 @@ int gru_tapping(struct grail *ge,
80 return 0; 86 return 0;
81 } 87 }
82 if (state->status != TAP_END || 88 if (state->status != TAP_END ||
83 frame->time - state->start < TAP_MIN_GAP_MS) 89 move->time - state->start < TAP_MIN_GAP_MS)
84 return 0; 90 return 0;
85 prop[0] = frame->time - state->start; 91 prop[0] = move->time - state->start;
86 gin_gid_event(ge, state->gid, 92 gin_gid_event(ge, state->gid,
87 move->x.val, move->y.val, state->ntouch, 93 move->x.val, move->y.val, state->ntouch,
88 prop, 1, GRAIL_STATUS_END); 94 prop, 1, GRAIL_STATUS_END);
diff --git a/src/grail-gestures.h b/src/grail-gestures.h
index 9da2693..57204ad 100644
--- a/src/grail-gestures.h
+++ b/src/grail-gestures.h
@@ -66,6 +66,7 @@ int gru_combo(struct grail *ge,
66 66
67struct tapping_model { 67struct tapping_model {
68 grail_time_t start; 68 grail_time_t start;
69 float x, y;
69 int status, ntouch; 70 int status, ntouch;
70 int active, gid; 71 int active, gid;
71}; 72};