summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2010-08-07 19:16:00 +0200
committerHenrik Rydberg <rydberg@euromail.se>2010-08-07 19:16:00 +0200
commitf6e65676026fa9f3f2664100b68ba2c6da376a24 (patch)
treed6a08fca5394c1cd75013a05aafd4af7943298cf
parentee4a0c6821a1b79c3d18c6ef6d7ed6d37df74755 (diff)
Add configurable pointer gesture
In some applications, it is desirable to treat pointer movements as a gesture. This patch adds a gru configuration parameter which, then true, makes grail emit pointer gesture events. Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
-rw-r--r--include/grail.h2
-rw-r--r--src/gestures-pan.c8
-rw-r--r--src/grail-recognizer.c5
-rw-r--r--src/grail-recognizer.h1
4 files changed, 12 insertions, 4 deletions
diff --git a/include/grail.h b/include/grail.h
index e608b05..a778618 100644
--- a/include/grail.h
+++ b/include/grail.h
@@ -89,4 +89,6 @@ void grail_close(struct grail *ge, int fd);
89void grail_get_units(struct grail_coord *min, struct grail_coord *max, 89void grail_get_units(struct grail_coord *min, struct grail_coord *max,
90 const struct grail *ge); 90 const struct grail *ge);
91 91
92int gru_use_pointer_gesture(struct grail *ge, int usage);
93
92#endif 94#endif
diff --git a/src/gestures-pan.c b/src/gestures-pan.c
index a023122..b8e1751 100644
--- a/src/gestures-pan.c
+++ b/src/gestures-pan.c
@@ -25,8 +25,8 @@
25#include <stdio.h> 25#include <stdio.h>
26 26
27static const int getype[DIM_TOUCH + 1] = { 27static const int getype[DIM_TOUCH + 1] = {
28 0, 28 -1,
29 0, 29 GRAIL_TYPE_POINTER,
30 GRAIL_TYPE_PAN, 30 GRAIL_TYPE_PAN,
31 GRAIL_TYPE_SWIPE, 31 GRAIL_TYPE_SWIPE,
32 GRAIL_TYPE_BRUSH, 32 GRAIL_TYPE_BRUSH,
@@ -43,7 +43,7 @@ int gru_pan(struct grail *ge,
43 struct move_model *move = &gru->move; 43 struct move_model *move = &gru->move;
44 grail_prop_t prop[DIM_GRAIL_PROP]; 44 grail_prop_t prop[DIM_GRAIL_PROP];
45 int mask = state->active ? (move->active & fm_mask) : fm_mask; 45 int mask = state->active ? (move->active & fm_mask) : fm_mask;
46 if (!move->multi) { 46 if (!move->multi && (!gru->pointer_gesture || !move->single)) {
47 if (state->active) { 47 if (state->active) {
48 gru_end(ge, state->gid, move); 48 gru_end(ge, state->gid, move);
49 state->active = 0; 49 state->active = 0;
@@ -54,7 +54,7 @@ int gru_pan(struct grail *ge,
54 return 0; 54 return 0;
55 if (!state->active) { 55 if (!state->active) {
56 int type = getype[move->ntouch]; 56 int type = getype[move->ntouch];
57 if (!type) 57 if (type < 0)
58 return 0; 58 return 0;
59 state->gid = gin_gid_begin(ge, type, PRIO_GESTURE, frame); 59 state->gid = gin_gid_begin(ge, type, PRIO_GESTURE, frame);
60 state->active = 1; 60 state->active = 1;
diff --git a/src/grail-recognizer.c b/src/grail-recognizer.c
index c4c6812..bcfbc2c 100644
--- a/src/grail-recognizer.c
+++ b/src/grail-recognizer.c
@@ -54,3 +54,8 @@ void gru_recognize(struct grail *ge, const struct touch_frame *frame)
54 gru_tapping(ge, frame); 54 gru_tapping(ge, frame);
55 ge->gru->frame = *frame; 55 ge->gru->frame = *frame;
56} 56}
57
58int gru_use_pointer_gesture(struct grail *ge, int usage)
59{
60 ge->gru->pointer_gesture = usage;
61}
diff --git a/src/grail-recognizer.h b/src/grail-recognizer.h
index 212ac7d..11b44ce 100644
--- a/src/grail-recognizer.h
+++ b/src/grail-recognizer.h
@@ -33,6 +33,7 @@ struct gesture_recognizer {
33 struct combo_model rotate; 33 struct combo_model rotate;
34 struct combo_model combo; 34 struct combo_model combo;
35 struct tapping_model tapping; 35 struct tapping_model tapping;
36 int pointer_gesture;
36}; 37};
37 38
38int gru_init(struct grail *ge); 39int gru_init(struct grail *ge);