summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2010-08-19 22:15:55 +0200
committerHenrik Rydberg <rydberg@euromail.se>2010-08-19 22:15:55 +0200
commit76f51a7675801acfe8e58c6a21192668d23d3320 (patch)
tree73109e613e93fbb8f20fabdbec9f7e0d5356f4dd /src
parent8331322a0fec7277366a29a970eafbb795c08432 (diff)
Add contact information to the property list
Add the five first contacts to the property list, and unify the handling of all gesture types in this regard. To avoid duplication, move the scaling of properties closer to the gesture recognizer. Move all gesture event handling code to grail-event.c, simplifying the structure somewhat. Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'src')
-rw-r--r--src/gestures-drag.c29
-rw-r--r--src/gestures-pinch.c23
-rw-r--r--src/gestures-rotate.c17
-rw-r--r--src/gestures-tapping.c17
-rw-r--r--src/grail-event.c93
-rw-r--r--src/grail-gestures.c25
-rw-r--r--src/grail-gestures.h2
-rw-r--r--src/grail-inserter.c124
-rw-r--r--src/grail-inserter.h12
9 files changed, 151 insertions, 191 deletions
diff --git a/src/gestures-drag.c b/src/gestures-drag.c
index 253bc9d..8b57b99 100644
--- a/src/gestures-drag.c
+++ b/src/gestures-drag.c
@@ -33,20 +33,27 @@ static const int getype[DIM_TOUCH + 1] = {
33 GRAIL_TYPE_DRAG5, 33 GRAIL_TYPE_DRAG5,
34}; 34};
35 35
36static void set_props(struct combo_model *s, const struct move_model *m) 36static void set_props(const struct gesture_inserter *gin,
37 struct combo_model *s, const struct move_model *m,
38 const struct touch_frame *frame)
37{ 39{
38 if (m->single) { 40 if (m->single) {
39 s->prop[GRAIL_PROP_DRAG_DX] = m->fm[FM_X].raw_delta; 41 s->prop[GRAIL_PROP_DRAG_DX] =
40 s->prop[GRAIL_PROP_DRAG_DY] = m->fm[FM_Y].raw_delta; 42 gin->scale_x * m->fm[FM_X].raw_delta;
43 s->prop[GRAIL_PROP_DRAG_DY] =
44 gin->scale_y * m->fm[FM_Y].raw_delta;
41 } else { 45 } else {
42 s->prop[GRAIL_PROP_DRAG_DX] = m->fm[FM_X].action_delta; 46 s->prop[GRAIL_PROP_DRAG_DX] =
43 s->prop[GRAIL_PROP_DRAG_DY] = m->fm[FM_Y].action_delta; 47 gin->scale_x * m->fm[FM_X].action_delta;
48 s->prop[GRAIL_PROP_DRAG_DY] =
49 gin->scale_y * m->fm[FM_Y].action_delta;
44 } 50 }
45 s->prop[GRAIL_PROP_DRAG_VX] = m->fm[FM_X].velocity; 51 s->prop[GRAIL_PROP_DRAG_VX] = gin->scale_x * m->fm[FM_X].velocity;
46 s->prop[GRAIL_PROP_DRAG_VY] = m->fm[FM_Y].velocity; 52 s->prop[GRAIL_PROP_DRAG_VY] = gin->scale_y * m->fm[FM_Y].velocity;
47 s->prop[GRAIL_PROP_DRAG_X] = m->fm[FM_X].value; 53 s->prop[GRAIL_PROP_DRAG_X] = gin_prop_x(gin, m->fm[FM_X].value);
48 s->prop[GRAIL_PROP_DRAG_Y] = m->fm[FM_Y].value; 54 s->prop[GRAIL_PROP_DRAG_Y] = gin_prop_y(gin, m->fm[FM_Y].value);
49 s->nprop = 6; 55 s->nprop = 6;
56 s->nprop += gin_add_contact_props(gin, s->prop + s->nprop, frame);
50} 57}
51 58
52static const int fm_mask = 0x03; 59static const int fm_mask = 0x03;
@@ -77,7 +84,7 @@ int gru_drag(struct grail *ge,
77 } 84 }
78 if (!move->single && !(move->active & fm_mask)) 85 if (!move->single && !(move->active & fm_mask))
79 return 0; 86 return 0;
80 set_props(state, move); 87 set_props(ge->gin, state, move, frame);
81 gru_event(ge, state->gid, move, state->prop, state->nprop); 88 gru_event(ge, state->gid, move, state->prop, state->nprop);
82 return 1; 89 return 1;
83} 90}
@@ -118,7 +125,7 @@ int gru_windrag(struct grail *ge,
118 } 125 }
119 if (!move->single && !(move->active & fm_mask)) 126 if (!move->single && !(move->active & fm_mask))
120 return 0; 127 return 0;
121 set_props(state, move); 128 set_props(ge->gin, state, move, frame);
122 gru_event(ge, state->gid, move, state->prop, state->nprop); 129 gru_event(ge, state->gid, move, state->prop, state->nprop);
123 return 1; 130 return 1;
124} 131}
diff --git a/src/gestures-pinch.c b/src/gestures-pinch.c
index d05b06f..45f1cb3 100644
--- a/src/gestures-pinch.c
+++ b/src/gestures-pinch.c
@@ -35,23 +35,16 @@ static const int getype[DIM_TOUCH + 1] = {
35 35
36static const int fm_mask = 0x04; 36static const int fm_mask = 0x04;
37 37
38static void set_props(struct combo_model *s, 38static void set_props(const struct gesture_inserter *gin,
39 struct combo_model *s,
39 const struct move_model *m, 40 const struct move_model *m,
40 const struct touch_frame *frame) 41 const struct touch_frame *frame)
41{ 42{
42 struct grail_coord min, max; 43 s->prop[GRAIL_PROP_PINCH_DR] = gin->scale_r * m->fm[FM_R].action_delta;
43 s->prop[GRAIL_PROP_PINCH_DR] = m->fm[FM_R].action_delta; 44 s->prop[GRAIL_PROP_PINCH_VR] = gin->scale_r * m->fm[FM_R].velocity;
44 s->prop[GRAIL_PROP_PINCH_VR] = m->fm[FM_R].velocity; 45 s->prop[GRAIL_PROP_PINCH_R] = gin->scale_r * m->fm[FM_R].value;
45 s->prop[GRAIL_PROP_PINCH_R] = m->fm[FM_R].value;
46 s->nprop = 3; 46 s->nprop = 3;
47 if (!frame->nactive) 47 s->nprop += gin_add_contact_props(gin, s->prop + s->nprop, frame);
48 return;
49 gru_compute_bbox(&min, &max, frame);
50 s->prop[GRAIL_PROP_PINCH_X1] = min.x;
51 s->prop[GRAIL_PROP_PINCH_Y1] = min.y;
52 s->prop[GRAIL_PROP_PINCH_X2] = max.x;
53 s->prop[GRAIL_PROP_PINCH_Y2] = max.y;
54 s->nprop = 7;
55} 48}
56 49
57int gru_pinch(struct grail *ge, 50int gru_pinch(struct grail *ge,
@@ -80,7 +73,7 @@ int gru_pinch(struct grail *ge,
80 } 73 }
81 if (!(move->active & fm_mask)) 74 if (!(move->active & fm_mask))
82 return 0; 75 return 0;
83 set_props(state, move, frame); 76 set_props(ge->gin, state, move, frame);
84 gru_event(ge, state->gid, move, state->prop, state->nprop); 77 gru_event(ge, state->gid, move, state->prop, state->nprop);
85 return 1; 78 return 1;
86} 79}
@@ -121,7 +114,7 @@ int gru_winpinch(struct grail *ge,
121 } 114 }
122 if (!(move->active & fm_mask)) 115 if (!(move->active & fm_mask))
123 return 0; 116 return 0;
124 set_props(state, move, frame); 117 set_props(ge->gin, state, move, frame);
125 gru_event(ge, state->gid, move, state->prop, state->nprop); 118 gru_event(ge, state->gid, move, state->prop, state->nprop);
126 return 1; 119 return 1;
127} 120}
diff --git a/src/gestures-rotate.c b/src/gestures-rotate.c
index 23bbfd6..8985257 100644
--- a/src/gestures-rotate.c
+++ b/src/gestures-rotate.c
@@ -35,22 +35,15 @@ static const int getype[DIM_TOUCH + 1] = {
35 35
36static const int fm_mask = 0x08; 36static const int fm_mask = 0x08;
37 37
38static void set_props(struct combo_model *s, const struct move_model *m, 38static void set_props(const struct gesture_inserter *gin,
39 struct combo_model *s, const struct move_model *m,
39 const struct touch_frame *frame) 40 const struct touch_frame *frame)
40{ 41{
41 struct grail_coord min, max;
42 s->prop[GRAIL_PROP_ROTATE_DA] = m->fm[FM_A].action_delta; 42 s->prop[GRAIL_PROP_ROTATE_DA] = m->fm[FM_A].action_delta;
43 s->prop[GRAIL_PROP_ROTATE_VA] = m->fm[FM_A].velocity; 43 s->prop[GRAIL_PROP_ROTATE_VA] = m->fm[FM_A].velocity;
44 s->prop[GRAIL_PROP_ROTATE_A] = m->fm[FM_A].value; 44 s->prop[GRAIL_PROP_ROTATE_A] = m->fm[FM_A].value;
45 s->nprop = 3; 45 s->nprop = 3;
46 if (!frame->nactive) 46 s->nprop += gin_add_contact_props(gin, s->prop + s->nprop, frame);
47 return;
48 gru_compute_bbox(&min, &max, frame);
49 s->prop[GRAIL_PROP_ROTATE_X1] = min.x;
50 s->prop[GRAIL_PROP_ROTATE_Y1] = min.y;
51 s->prop[GRAIL_PROP_ROTATE_X2] = max.x;
52 s->prop[GRAIL_PROP_ROTATE_Y2] = max.y;
53 s->nprop = 7;
54} 47}
55 48
56int gru_rotate(struct grail *ge, 49int gru_rotate(struct grail *ge,
@@ -79,7 +72,7 @@ int gru_rotate(struct grail *ge,
79 } 72 }
80 if (!(move->active & fm_mask)) 73 if (!(move->active & fm_mask))
81 return 0; 74 return 0;
82 set_props(state, move, frame); 75 set_props(ge->gin, state, move, frame);
83 gru_event(ge, state->gid, move, state->prop, state->nprop); 76 gru_event(ge, state->gid, move, state->prop, state->nprop);
84 return 1; 77 return 1;
85} 78}
@@ -120,7 +113,7 @@ int gru_winrotate(struct grail *ge,
120 } 113 }
121 if (!(move->active & fm_mask)) 114 if (!(move->active & fm_mask))
122 return 0; 115 return 0;
123 set_props(state, move, frame); 116 set_props(ge->gin, state, move, frame);
124 gru_event(ge, state->gid, move, state->prop, state->nprop); 117 gru_event(ge, state->gid, move, state->prop, state->nprop);
125 return 1; 118 return 1;
126} 119}
diff --git a/src/gestures-tapping.c b/src/gestures-tapping.c
index 52c5fdb..371dbde 100644
--- a/src/gestures-tapping.c
+++ b/src/gestures-tapping.c
@@ -31,6 +31,17 @@ static const int TAP_MIN_GAP_MS = 25;
31 31
32static const int fm_mask = 0x03; 32static const int fm_mask = 0x03;
33 33
34static void set_props(const struct gesture_inserter *gin,
35 struct tapping_model *s, const struct move_model *m,
36 const struct touch_frame *frame)
37{
38 s->prop[GRAIL_PROP_TAP_DT] = m->time - s->start;
39 s->prop[GRAIL_PROP_TAP_X] = gin_prop_x(gin, m->fm[FM_X].value);
40 s->prop[GRAIL_PROP_TAP_Y] = gin_prop_y(gin, m->fm[FM_Y].value);
41 s->nprop = 3;
42 s->nprop += gin_add_contact_props(gin, s->prop + s->nprop, frame);
43}
44
34int gru_tapping(struct grail *ge, 45int gru_tapping(struct grail *ge,
35 const struct touch_frame *frame) 46 const struct touch_frame *frame)
36{ 47{
@@ -44,11 +55,7 @@ int gru_tapping(struct grail *ge,
44 if (!state->ntouch) 55 if (!state->ntouch)
45 state->start = move->time; 56 state->start = move->time;
46 if (move->ntouch >= state->ntouch) { 57 if (move->ntouch >= state->ntouch) {
47 state->prop[GRAIL_PROP_TAP_DT] = 58 set_props(ge->gin, state, move, frame);
48 move->time - state->start;
49 state->prop[GRAIL_PROP_TAP_X] = move->fm[FM_X].value;
50 state->prop[GRAIL_PROP_TAP_Y] = move->fm[FM_Y].value;
51 state->nprop = 3;
52 } 59 }
53 if (move->ntouch > state->ntouch) { 60 if (move->ntouch > state->ntouch) {
54 state->ntouch = move->ntouch; 61 state->ntouch = move->ntouch;
diff --git a/src/grail-event.c b/src/grail-event.c
index 6479cc0..2cf8209 100644
--- a/src/grail-event.c
+++ b/src/grail-event.c
@@ -22,8 +22,101 @@
22 22
23#include "grail-inserter.h" 23#include "grail-inserter.h"
24#include "grail-impl.h" 24#include "grail-impl.h"
25#include <malloc.h>
26#include <string.h>
27#include <errno.h>
25#include <math.h> 28#include <math.h>
26 29
30static void compute_bbox(struct grail_coord *min, struct grail_coord *max,
31 const struct touch_frame *frame)
32{
33 float x, y;
34 int i;
35 if (frame->nactive < 1)
36 return;
37 x = frame->active[0]->x;
38 y = frame->active[0]->y;
39 min->x = max->x = x;
40 min->y = max->y = y;
41 for (i = 1; i < frame->nactive; i++) {
42 x = frame->active[i]->x;
43 y = frame->active[i]->y;
44 if (x < min->x)
45 min->x = x;
46 if (y < min->y)
47 min->y = y;
48 if (x > max->x)
49 max->x = x;
50 if (y > max->y)
51 max->y = y;
52 }
53}
54
55int gin_add_contact_props(const struct gesture_inserter *gin,
56 grail_prop_t *prop, const struct touch_frame *frame)
57{
58 struct grail_coord min, max;
59 int i, n = 0, ntouch = frame->nactive;
60 if (!ntouch)
61 return n;
62 if (ntouch > 5)
63 ntouch = 5;
64 compute_bbox(&min, &max, frame);
65 prop[n++] = gin_prop_x(gin, min.x);
66 prop[n++] = gin_prop_y(gin, min.y);
67 prop[n++] = gin_prop_x(gin, max.x);
68 prop[n++] = gin_prop_y(gin, max.y);
69 for (i = 0; i < ntouch; i++) {
70 const struct touch *ct = frame->active[i];
71 prop[n++] = ct->id;
72 prop[n++] = gin_prop_x(gin, ct->x);
73 prop[n++] = gin_prop_y(gin, ct->y);
74 }
75 return n;
76}
77
78int gin_get_clients(struct grail *ge,
79 struct grail_client_info *info, int maxinfo,
80 const grail_mask_t* types, int btypes,
81 const grail_mask_t* span, int bspan,
82 const struct touch_frame *frame)
83{
84 struct grail_coord pos[DIM_TOUCH];
85 int i, npos = 0;
86 if (!ge->get_clients)
87 return 0;
88 grail_mask_foreach(i, span, bspan) {
89 pos[npos].x = gin_prop_x(ge->gin, frame->touch[i].x);
90 pos[npos].y = gin_prop_y(ge->gin, frame->touch[i].y);
91 npos++;
92 }
93 return ge->get_clients(ge, info, maxinfo, pos, npos, types, btypes);
94}
95
96void gin_send_event(struct grail *ge, struct slot_state *s,
97 const struct gesture_event *ev,
98 const struct touch_frame *frame)
99{
100 const struct gesture_inserter *gin = ge->gin;
101 struct grail_event gev;
102 int i;
103 if (!ge->gesture)
104 return;
105 gev.type = s->type;
106 gev.id = s->id;
107 gev.status = ev->status;
108 gev.ntouch = ev->ntouch;
109 gev.nprop = ev->nprop;
110 gev.time = ev->time;
111 gev.pos.x = gin_prop_x(gin, ev->pos.x);
112 gev.pos.y = gin_prop_y(gin, ev->pos.y);
113 memcpy(gev.prop, ev->prop, ev->nprop * sizeof(grail_prop_t));
114 for (i = 0; i < s->nclient; i++) {
115 gev.client_id = s->client_id[i];
116 ge->gesture(ge, &gev);
117 }
118}
119
27int grail_get_contacts(const struct grail *ge, 120int grail_get_contacts(const struct grail *ge,
28 struct grail_contact *touch, int max_touch) 121 struct grail_contact *touch, int max_touch)
29{ 122{
diff --git a/src/grail-gestures.c b/src/grail-gestures.c
index 1e89074..4262af7 100644
--- a/src/grail-gestures.c
+++ b/src/grail-gestures.c
@@ -217,28 +217,3 @@ void gru_end(struct grail *ge, int gid, const struct move_model *m,
217 gin_gid_end(ge, gid, m->fm[FM_X].value, m->fm[FM_Y].value, m->ntouch, 217 gin_gid_end(ge, gid, m->fm[FM_X].value, m->fm[FM_Y].value, m->ntouch,
218 prop, nprop); 218 prop, nprop);
219} 219}
220
221void gru_compute_bbox(struct grail_coord *min, struct grail_coord *max,
222 const struct touch_frame *frame)
223{
224 float x, y;
225 int i;
226 if (frame->nactive < 1)
227 return;
228 x = frame->active[0]->x;
229 y = frame->active[0]->y;
230 min->x = max->x = x;
231 min->y = max->y = y;
232 for (i = 1; i < frame->nactive; i++) {
233 x = frame->active[i]->x;
234 y = frame->active[i]->y;
235 if (x < min->x)
236 min->x = x;
237 if (y < min->y)
238 min->y = y;
239 if (x > max->x)
240 max->x = x;
241 if (y > max->y)
242 max->y = y;
243 }
244}
diff --git a/src/grail-gestures.h b/src/grail-gestures.h
index edd641b..e716757 100644
--- a/src/grail-gestures.h
+++ b/src/grail-gestures.h
@@ -68,8 +68,6 @@ void gru_event(struct grail *ge, int gid,
68void gru_end(struct grail *ge, int gid, 68void gru_end(struct grail *ge, int gid,
69 const struct move_model *move, 69 const struct move_model *move,
70 const grail_prop_t *prop, int nprop); 70 const grail_prop_t *prop, int nprop);
71void gru_compute_bbox(struct grail_coord *min, struct grail_coord *max,
72 const struct touch_frame *frame);
73 71
74struct combo_model { 72struct combo_model {
75 int active, gid; 73 int active, gid;
diff --git a/src/grail-inserter.c b/src/grail-inserter.c
index 2e5e7af..d77da79 100644
--- a/src/grail-inserter.c
+++ b/src/grail-inserter.c
@@ -29,90 +29,6 @@
29 29
30static const int MAX_GESTURE_ID = 0xfff; 30static const int MAX_GESTURE_ID = 0xfff;
31 31
32static const int grail_main_type[DIM_GRAIL_TYPE] = {
33 GRAIL_MAIN_DRAG,
34 GRAIL_MAIN_PINCH,
35 GRAIL_MAIN_ROTATE,
36 GRAIL_MAIN_DRAG,
37 GRAIL_MAIN_PINCH,
38 GRAIL_MAIN_ROTATE,
39 GRAIL_MAIN_DRAG,
40 GRAIL_MAIN_PINCH,
41 GRAIL_MAIN_ROTATE,
42 GRAIL_MAIN_DRAG,
43 GRAIL_MAIN_PINCH,
44 GRAIL_MAIN_ROTATE,
45 GRAIL_MAIN_DRAG,
46 GRAIL_MAIN_PINCH,
47 GRAIL_MAIN_ROTATE,
48 GRAIL_MAIN_TAP,
49 GRAIL_MAIN_TAP,
50 GRAIL_MAIN_TAP,
51 GRAIL_MAIN_TAP,
52 GRAIL_MAIN_TAP,
53 GRAIL_MAIN_DRAG,
54 GRAIL_MAIN_PINCH,
55 GRAIL_MAIN_ROTATE,
56 GRAIL_MAIN_DRAG,
57 GRAIL_MAIN_PINCH,
58 GRAIL_MAIN_ROTATE,
59};
60
61static void transform_pos(const struct gesture_inserter *gin,
62 struct grail_coord *pos)
63{
64 pos->x *= gin->scale_x;
65 pos->x += gin->trans_x;
66 pos->y *= gin->scale_y;
67 pos->y += gin->trans_y;
68}
69
70static void transform_prop(const struct gesture_inserter *gin, int type,
71 grail_prop_t *prop, int nprop)
72{
73 switch (grail_main_type[type]) {
74 case GRAIL_MAIN_DRAG:
75 prop[GRAIL_PROP_DRAG_DX] *= gin->scale_x;
76 prop[GRAIL_PROP_DRAG_DY] *= gin->scale_y;
77 prop[GRAIL_PROP_DRAG_VX] *= gin->scale_x;
78 prop[GRAIL_PROP_DRAG_VY] *= gin->scale_y;
79 prop[GRAIL_PROP_DRAG_X] *= gin->scale_x;
80 prop[GRAIL_PROP_DRAG_X] += gin->trans_x;
81 prop[GRAIL_PROP_DRAG_Y] *= gin->scale_y;
82 prop[GRAIL_PROP_DRAG_Y] += gin->trans_y;
83 break;
84 case GRAIL_MAIN_PINCH:
85 prop[GRAIL_PROP_PINCH_DR] *= gin->scale_r;
86 prop[GRAIL_PROP_PINCH_VR] *= gin->scale_r;
87 prop[GRAIL_PROP_PINCH_R] *= gin->scale_r;
88 prop[GRAIL_PROP_PINCH_X1] *= gin->scale_x;
89 prop[GRAIL_PROP_PINCH_X1] += gin->trans_x;
90 prop[GRAIL_PROP_PINCH_Y1] *= gin->scale_y;
91 prop[GRAIL_PROP_PINCH_Y1] += gin->trans_y;
92 prop[GRAIL_PROP_PINCH_X2] *= gin->scale_x;
93 prop[GRAIL_PROP_PINCH_X2] += gin->trans_x;
94 prop[GRAIL_PROP_PINCH_Y2] *= gin->scale_y;
95 prop[GRAIL_PROP_PINCH_Y2] += gin->trans_y;
96 break;
97 case GRAIL_MAIN_ROTATE:
98 prop[GRAIL_PROP_ROTATE_X1] *= gin->scale_x;
99 prop[GRAIL_PROP_ROTATE_X1] += gin->trans_x;
100 prop[GRAIL_PROP_ROTATE_Y1] *= gin->scale_y;
101 prop[GRAIL_PROP_ROTATE_Y1] += gin->trans_y;
102 prop[GRAIL_PROP_ROTATE_X2] *= gin->scale_x;
103 prop[GRAIL_PROP_ROTATE_X2] += gin->trans_x;
104 prop[GRAIL_PROP_ROTATE_Y2] *= gin->scale_y;
105 prop[GRAIL_PROP_ROTATE_Y2] += gin->trans_y;
106 break;
107 case GRAIL_MAIN_TAP:
108 prop[GRAIL_PROP_TAP_X] *= gin->scale_x;
109 prop[GRAIL_PROP_TAP_X] += gin->trans_x;
110 prop[GRAIL_PROP_TAP_Y] *= gin->scale_y;
111 prop[GRAIL_PROP_TAP_Y] += gin->trans_y;
112 break;
113 };
114}
115
116static int find_gslot(const struct gesture_inserter *gin, int gid) 32static int find_gslot(const struct gesture_inserter *gin, int gid)
117{ 33{
118 int i; 34 int i;
@@ -122,29 +38,6 @@ static int find_gslot(const struct gesture_inserter *gin, int gid)
122 return -1; 38 return -1;
123} 39}
124 40
125static void send_event(struct grail *ge, struct slot_state *s,
126 const struct gesture_event *ev)
127{
128 struct grail_event gev;
129 int i;
130 if (!ge->gesture)
131 return;
132 gev.type = s->type;
133 gev.id = s->id;
134 gev.status = ev->status;
135 gev.ntouch = ev->ntouch;
136 gev.nprop = ev->nprop;
137 gev.time = ev->time;
138 gev.pos = ev->pos;
139 transform_pos(ge->gin, &gev.pos);
140 memcpy(gev.prop, ev->prop, ev->nprop * sizeof(grail_prop_t));
141 transform_prop(ge->gin, gev.type, gev.prop, gev.nprop);
142 for (i = 0; i < s->nclient; i++) {
143 gev.client_id = s->client_id[i];
144 ge->gesture(ge, &gev);
145 }
146}
147
148// todo: spanning tree for multi-user case 41// todo: spanning tree for multi-user case
149static void setup_new_gestures(struct grail *ge, 42static void setup_new_gestures(struct grail *ge,
150 const struct touch_frame *frame) 43 const struct touch_frame *frame)
@@ -167,19 +60,8 @@ static void setup_new_gestures(struct grail *ge,
167 grail_mask_set_mask(span, s->span, sizeof(span)); 60 grail_mask_set_mask(span, s->span, sizeof(span));
168 } 61 }
169 62
170 if (ge->get_clients) { 63 nclient = gin_get_clients(ge, info, DIM_CLIENT, types, sizeof(types),
171 struct grail_coord coord[DIM_CLIENT]; 64 span, sizeof(span), frame);
172 int ncoord = 0;
173 grail_mask_foreach(i, span, sizeof(span)) {
174 const struct touch *t = &frame->touch[i];
175 coord[ncoord].x = t->x;
176 coord[ncoord].y = t->y;
177 transform_pos(gin, &coord[ncoord]);
178 ncoord++;
179 }
180 nclient = ge->get_clients(ge, info, DIM_CLIENT,
181 coord, ncoord, types, sizeof(types));
182 }
183 65
184 grail_mask_foreach(i, gin->fresh, sizeof(gin->fresh)) { 66 grail_mask_foreach(i, gin->fresh, sizeof(gin->fresh)) {
185 struct slot_state *s = &gin->state[i]; 67 struct slot_state *s = &gin->state[i];
@@ -263,7 +145,7 @@ void gin_frame_end(struct grail *ge,
263 continue; 145 continue;
264 while (!gebuf_empty(&s->buf)) { 146 while (!gebuf_empty(&s->buf)) {
265 gebuf_get(&s->buf, &ev); 147 gebuf_get(&s->buf, &ev);
266 send_event(ge, s, &ev); 148 gin_send_event(ge, s, &ev, frame);
267 } 149 }
268 } 150 }
269 151
diff --git a/src/grail-inserter.h b/src/grail-inserter.h
index f8ec5ca..c5a865a 100644
--- a/src/grail-inserter.h
+++ b/src/grail-inserter.h
@@ -67,6 +67,18 @@ static inline float gin_prop_y(const struct gesture_inserter *gin, float y)
67 return gin->scale_y * y + gin->trans_y; 67 return gin->scale_y * y + gin->trans_y;
68} 68}
69 69
70int gin_add_contact_props(const struct gesture_inserter *gin,
71 grail_prop_t *prop, const struct touch_frame *frame);
72
73int gin_get_clients(struct grail *ge,
74 struct grail_client_info *info, int maxinfo,
75 const grail_mask_t* types, int btypes,
76 const grail_mask_t* span, int bspan,
77 const struct touch_frame *frame);
78void gin_send_event(struct grail *ge, struct slot_state *s,
79 const struct gesture_event *ev,
80 const struct touch_frame *frame);
81
70int gin_init(struct grail *ge); 82int gin_init(struct grail *ge);
71void gin_destroy(struct grail *ge); 83void gin_destroy(struct grail *ge);
72 84