Status: | Merged |
---|---|
Merged at revision: | 129 |
Proposed branch: | lp:~bregma/geis/lp-742555 |
Merge into: | lp:geis |
Diff against target: |
499 lines (+229/-56) 9 files modified
ChangeLog (+21/-0) include/geis/geis.h (+10/-0) libutouch-geis/backend/xcb/geis_xcb_backend.c (+10/-7) libutouch-geis/backend/xcb/grail_gestures.c (+102/-49) libutouch-geis/geis_v1.c (+5/-0) testsuite/geis1/Makefile.am (+1/-0) testsuite/geis1/check_geis1_api.c (+2/-0) testsuite/geis1/check_gesture_types.c (+77/-0) testsuite/geistest/geistest.c (+1/-0) |
To merge this branch: | bzr merge lp:~bregma/geis/lp-742555 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Chase Douglas (community) | Approve | ||
Review via email: mp+54920@code.launchpad.net |
Commit message
Description of the change
Adds through support for TOUCH gesture types for direct touch begin/end handling.
- 130. By Stephen M. Webb
-
* Replaced alloca() calls with C99 dynamic arrays.
* Used memset instead of a for-loop for array initialization.
* Removed extraneous commas from s_grail_class_map. - 131. By Stephen M. Webb
-
Properly initialized the grail gesture bitmask in all cases.
Stephen M. Webb (bregma) wrote : | # |
New revision pushed up.
(1) alloca() replaced by C99 dynamic arrays.
(b) used memset() instead of a for-loop to initialize the array.
(3) removed extraneous commas.
(5) initialized all instances of mask_len.
grail_mask_setbit() only concerns itself with the lower 2^5 bits of each uint32_t because there are only 2^5 bits in a uint32_t.
- 132. By Stephen M. Webb
-
Cleared touch count mask.
- 133. By Stephen M. Webb
-
Changed the list of properties received from grail for the Touch gesture.
Chase Douglas (chasedouglas) wrote : | # |
The code looks good now, and geistest is behaving as I expect :).
Preview Diff
1 | === modified file 'ChangeLog' | |||
2 | --- ChangeLog 2011-03-24 19:38:36 +0000 | |||
3 | +++ ChangeLog 2011-03-28 12:59:24 +0000 | |||
4 | @@ -1,3 +1,24 @@ | |||
5 | 1 | 2011-03-28 Stephen M. Webb <stephen.webb@canonical.com> | ||
6 | 2 | |||
7 | 3 | Changes the list of attrs received from grail for the Touch gesture. | ||
8 | 4 | |||
9 | 5 | * libutouch-geis/backend/xcb/grail_gestures.c: change Touch attrs | ||
10 | 6 | |||
11 | 7 | 2011-03-25 Stephen M. Webb <stephen.webb@canonical.com> | ||
12 | 8 | |||
13 | 9 | Added new TOUCH gesture types (LP: #742555). | ||
14 | 10 | |||
15 | 11 | * include/geis/geis.h: added new TOUCH gesture types | ||
16 | 12 | * libutouch-geis/backend/xcb/geis_xcb_backend.c: tweaked gesture mask size | ||
17 | 13 | * libutouch-geis/backend/xcb/grail_gestures.c: added new TOUCH gesture types | ||
18 | 14 | added proper handling of a variable-size gesture mask | ||
19 | 15 | * libutouch-geis/geis_v1.c: mapped new TOUCH gesture types to grail TOUCH | ||
20 | 16 | gesture types | ||
21 | 17 | * testsuite/geis1/check_gesture_types.c: new testsuite | ||
22 | 18 | * testsuite/geis1/Makefile.am: added new testsuite | ||
23 | 19 | * testsuite/geis1/check_geis1_api.c: invoked new testsuite | ||
24 | 20 | * testsuite/geistest/geistest.c: added new gesture types | ||
25 | 21 | |||
26 | 1 | 2011-03-24 Stephen M. Webb <stephen.webb@canonical.com> | 22 | 2011-03-24 Stephen M. Webb <stephen.webb@canonical.com> |
27 | 2 | 23 | ||
28 | 3 | Fixed a bad index when translating grail touches (LP: #742002). | 24 | Fixed a bad index when translating grail touches (LP: #742002). |
29 | 4 | 25 | ||
30 | === modified file 'include/geis/geis.h' | |||
31 | --- include/geis/geis.h 2011-03-17 23:42:48 +0000 | |||
32 | +++ include/geis/geis.h 2011-03-28 12:59:24 +0000 | |||
33 | @@ -107,6 +107,7 @@ | |||
34 | 107 | #define GEIS_GESTURE_PINCH "Pinch" | 107 | #define GEIS_GESTURE_PINCH "Pinch" |
35 | 108 | #define GEIS_GESTURE_ROTATE "Rotate" | 108 | #define GEIS_GESTURE_ROTATE "Rotate" |
36 | 109 | #define GEIS_GESTURE_TAP "Tap" | 109 | #define GEIS_GESTURE_TAP "Tap" |
37 | 110 | #define GEIS_GESTURE_TOUCH "Touch" | ||
38 | 110 | 111 | ||
39 | 111 | /** | 112 | /** |
40 | 112 | * @defgroup geis_v1_gesture_types Gesture Types | 113 | * @defgroup geis_v1_gesture_types Gesture Types |
41 | @@ -143,11 +144,15 @@ | |||
42 | 143 | * | 144 | * |
43 | 144 | * @def GEIS_GESTURE_PRIMITIVE_TAP | 145 | * @def GEIS_GESTURE_PRIMITIVE_TAP |
44 | 145 | * A tap. Touch down, touch up, one or more touches. | 146 | * A tap. Touch down, touch up, one or more touches. |
45 | 147 | * | ||
46 | 148 | * @def GEIS_GESTURE_PRIMITIVE_TOUCH | ||
47 | 149 | * A parenthetical gesture event. Touch down (start) and up (finish). | ||
48 | 146 | */ | 150 | */ |
49 | 147 | #define GEIS_GESTURE_PRIMITIVE_DRAG 0 | 151 | #define GEIS_GESTURE_PRIMITIVE_DRAG 0 |
50 | 148 | #define GEIS_GESTURE_PRIMITIVE_PINCH 1 | 152 | #define GEIS_GESTURE_PRIMITIVE_PINCH 1 |
51 | 149 | #define GEIS_GESTURE_PRIMITIVE_ROTATE 2 | 153 | #define GEIS_GESTURE_PRIMITIVE_ROTATE 2 |
52 | 150 | #define GEIS_GESTURE_PRIMITIVE_TAP 15 | 154 | #define GEIS_GESTURE_PRIMITIVE_TAP 15 |
53 | 155 | #define GEIS_GESTURE_PRIMITIVE_TOUCH 32 | ||
54 | 151 | 156 | ||
55 | 152 | /* @} */ | 157 | /* @} */ |
56 | 153 | 158 | ||
57 | @@ -182,6 +187,11 @@ | |||
58 | 182 | #define GEIS_GESTURE_TYPE_TAP3 "Tap,touch=3" | 187 | #define GEIS_GESTURE_TYPE_TAP3 "Tap,touch=3" |
59 | 183 | #define GEIS_GESTURE_TYPE_TAP4 "Tap,touch=4" | 188 | #define GEIS_GESTURE_TYPE_TAP4 "Tap,touch=4" |
60 | 184 | #define GEIS_GESTURE_TYPE_TAP5 "Tap,touch=5" | 189 | #define GEIS_GESTURE_TYPE_TAP5 "Tap,touch=5" |
61 | 190 | #define GEIS_GESTURE_TYPE_TOUCH1 "Touch,touch=1" | ||
62 | 191 | #define GEIS_GESTURE_TYPE_TOUCH2 "Touch,touch=2" | ||
63 | 192 | #define GEIS_GESTURE_TYPE_TOUCH3 "Touch,touch=3" | ||
64 | 193 | #define GEIS_GESTURE_TYPE_TOUCH4 "Touch,touch=4" | ||
65 | 194 | #define GEIS_GESTURE_TYPE_TOUCH5 "Touch,touch=5" | ||
66 | 185 | 195 | ||
67 | 186 | /* @} */ | 196 | /* @} */ |
68 | 187 | 197 | ||
69 | 188 | 198 | ||
70 | === modified file 'libutouch-geis/backend/xcb/geis_xcb_backend.c' | |||
71 | --- libutouch-geis/backend/xcb/geis_xcb_backend.c 2011-03-24 19:38:36 +0000 | |||
72 | +++ libutouch-geis/backend/xcb/geis_xcb_backend.c 2011-03-28 12:59:24 +0000 | |||
73 | @@ -47,6 +47,8 @@ | |||
74 | 47 | #define MAX_NUM_DEVICES 10 | 47 | #define MAX_NUM_DEVICES 10 |
75 | 48 | #define MAX_NUM_WINDOWS 10 | 48 | #define MAX_NUM_WINDOWS 10 |
76 | 49 | 49 | ||
77 | 50 | #define GRAIL_XCB_BITMASK_LEN 2 | ||
78 | 51 | |||
79 | 50 | 52 | ||
80 | 51 | static inline GeisSize | 53 | static inline GeisSize |
81 | 52 | _min(GeisSize a, GeisSize b) | 54 | _min(GeisSize a, GeisSize b) |
82 | @@ -83,7 +85,7 @@ | |||
83 | 83 | uint16_t devices[MAX_NUM_DEVICES]; | 85 | uint16_t devices[MAX_NUM_DEVICES]; |
84 | 84 | uint16_t device_count; | 86 | uint16_t device_count; |
85 | 85 | int num_class_filters; | 87 | int num_class_filters; |
87 | 86 | uint32_t mask[1]; | 88 | uint32_t mask[GRAIL_XCB_BITMASK_LEN]; |
88 | 87 | uint32_t mask_len; | 89 | uint32_t mask_len; |
89 | 88 | int num_region_filters; | 90 | int num_region_filters; |
90 | 89 | xcb_window_t windows[MAX_NUM_WINDOWS]; | 91 | xcb_window_t windows[MAX_NUM_WINDOWS]; |
91 | @@ -537,8 +539,8 @@ | |||
92 | 537 | GeisString class_name = NULL; | 539 | GeisString class_name = NULL; |
93 | 538 | GeisSize min_touches = MIN_TOUCHES; | 540 | GeisSize min_touches = MIN_TOUCHES; |
94 | 539 | GeisSize max_touches = MAX_TOUCHES; | 541 | GeisSize max_touches = MAX_TOUCHES; |
97 | 540 | uint32_t mask_len; | 542 | uint32_t mask_len = GRAIL_XCB_BITMASK_LEN; |
98 | 541 | uint32_t mask[1]; | 543 | uint32_t mask[mask_len]; |
99 | 542 | 544 | ||
100 | 543 | geis_xcb_backend_gesture_bitmask_init(geis_subscription_flags(sub), | 545 | geis_xcb_backend_gesture_bitmask_init(geis_subscription_flags(sub), |
101 | 544 | &mask_len, mask); | 546 | &mask_len, mask); |
102 | @@ -600,6 +602,7 @@ | |||
103 | 600 | geis_error("error allocating xcb-gesture subscription"); | 602 | geis_error("error allocating xcb-gesture subscription"); |
104 | 601 | goto error_exit; | 603 | goto error_exit; |
105 | 602 | } | 604 | } |
106 | 605 | xsub->mask_len = GRAIL_XCB_BITMASK_LEN; | ||
107 | 603 | 606 | ||
108 | 604 | /* Translate the GEIS v2 subscription into an XCB subscription. */ | 607 | /* Translate the GEIS v2 subscription into an XCB subscription. */ |
109 | 605 | for (i = 0; i < filter_count; ++i) | 608 | for (i = 0; i < filter_count; ++i) |
110 | @@ -652,13 +655,13 @@ | |||
111 | 652 | xcb_generic_error_t *error; | 655 | xcb_generic_error_t *error; |
112 | 653 | xcb_void_cookie_t select_cookie; | 656 | xcb_void_cookie_t select_cookie; |
113 | 654 | 657 | ||
115 | 655 | geis_debug("window_id=0x%08x device_id=%d mask_len=%d mask[0]=0x%08x", | 658 | geis_debug("window_id=0x%08x device_id=%d mask_len=%d mask=0x%08x %08x", |
116 | 656 | xsub->windows[win], xsub->devices[dev], | 659 | xsub->windows[win], xsub->devices[dev], |
118 | 657 | xsub->mask_len, xsub->mask[0]); | 660 | xsub->mask_len, xsub->mask[1], xsub->mask[0]); |
119 | 658 | select_cookie = xcb_gesture_select_events_checked(xcb->xcb_connection, | 661 | select_cookie = xcb_gesture_select_events_checked(xcb->xcb_connection, |
120 | 659 | xsub->windows[win], | 662 | xsub->windows[win], |
123 | 660 | xsub->devices[dev], | 663 | (uint16_t)xsub->devices[dev], |
124 | 661 | xsub->mask_len, | 664 | (uint16_t)xsub->mask_len, |
125 | 662 | xsub->mask); | 665 | xsub->mask); |
126 | 663 | error = xcb_request_check(xcb->xcb_connection, select_cookie); | 666 | error = xcb_request_check(xcb->xcb_connection, select_cookie); |
127 | 664 | if (error) | 667 | if (error) |
128 | 665 | 668 | ||
129 | === modified file 'libutouch-geis/backend/xcb/grail_gestures.c' | |||
130 | --- libutouch-geis/backend/xcb/grail_gestures.c 2011-03-22 16:14:01 +0000 | |||
131 | +++ libutouch-geis/backend/xcb/grail_gestures.c 2011-03-28 12:59:24 +0000 | |||
132 | @@ -38,6 +38,14 @@ | |||
133 | 38 | 38 | ||
134 | 39 | static GeisFloat zero = 0.0f; | 39 | static GeisFloat zero = 0.0f; |
135 | 40 | 40 | ||
136 | 41 | static struct _AttrInitializer s_touch_attrs[] = { | ||
137 | 42 | { GEIS_GESTURE_ATTRIBUTE_BOUNDINGBOX_X1, GEIS_ATTR_TYPE_FLOAT, &zero }, | ||
138 | 43 | { GEIS_GESTURE_ATTRIBUTE_BOUNDINGBOX_Y1, GEIS_ATTR_TYPE_FLOAT, &zero }, | ||
139 | 44 | { GEIS_GESTURE_ATTRIBUTE_BOUNDINGBOX_X2, GEIS_ATTR_TYPE_FLOAT, &zero }, | ||
140 | 45 | { GEIS_GESTURE_ATTRIBUTE_BOUNDINGBOX_Y2, GEIS_ATTR_TYPE_FLOAT, &zero }, | ||
141 | 46 | { NULL, 0, &zero } | ||
142 | 47 | }; | ||
143 | 48 | |||
144 | 41 | static struct _AttrInitializer s_drag_attrs[] = { | 49 | static struct _AttrInitializer s_drag_attrs[] = { |
145 | 42 | { GEIS_GESTURE_ATTRIBUTE_DELTA_X, GEIS_ATTR_TYPE_FLOAT, &zero }, | 50 | { GEIS_GESTURE_ATTRIBUTE_DELTA_X, GEIS_ATTR_TYPE_FLOAT, &zero }, |
146 | 43 | { GEIS_GESTURE_ATTRIBUTE_DELTA_Y, GEIS_ATTR_TYPE_FLOAT, &zero }, | 51 | { GEIS_GESTURE_ATTRIBUTE_DELTA_Y, GEIS_ATTR_TYPE_FLOAT, &zero }, |
147 | @@ -128,19 +136,54 @@ | |||
148 | 128 | { GRAIL_TYPE_TAP3, GEIS_GESTURE_PRIMITIVE_TAP, GEIS_GESTURE_TYPE_TAP3, GEIS_GESTURE_TAP, s_tap_attrs, 3 }, | 136 | { GRAIL_TYPE_TAP3, GEIS_GESTURE_PRIMITIVE_TAP, GEIS_GESTURE_TYPE_TAP3, GEIS_GESTURE_TAP, s_tap_attrs, 3 }, |
149 | 129 | { GRAIL_TYPE_TAP4, GEIS_GESTURE_PRIMITIVE_TAP, GEIS_GESTURE_TYPE_TAP4, GEIS_GESTURE_TAP, s_tap_attrs, 4 }, | 137 | { GRAIL_TYPE_TAP4, GEIS_GESTURE_PRIMITIVE_TAP, GEIS_GESTURE_TYPE_TAP4, GEIS_GESTURE_TAP, s_tap_attrs, 4 }, |
150 | 130 | { GRAIL_TYPE_TAP5, GEIS_GESTURE_PRIMITIVE_TAP, GEIS_GESTURE_TYPE_TAP5, GEIS_GESTURE_TAP, s_tap_attrs, 5 }, | 138 | { GRAIL_TYPE_TAP5, GEIS_GESTURE_PRIMITIVE_TAP, GEIS_GESTURE_TYPE_TAP5, GEIS_GESTURE_TAP, s_tap_attrs, 5 }, |
151 | 139 | { GRAIL_TYPE_TOUCH1, GEIS_GESTURE_PRIMITIVE_TOUCH, GEIS_GESTURE_TYPE_TOUCH1, GEIS_GESTURE_TOUCH, s_touch_attrs, 1 }, | ||
152 | 140 | { GRAIL_TYPE_TOUCH2, GEIS_GESTURE_PRIMITIVE_TOUCH, GEIS_GESTURE_TYPE_TOUCH2, GEIS_GESTURE_TOUCH, s_touch_attrs, 2 }, | ||
153 | 141 | { GRAIL_TYPE_TOUCH3, GEIS_GESTURE_PRIMITIVE_TOUCH, GEIS_GESTURE_TYPE_TOUCH3, GEIS_GESTURE_TOUCH, s_touch_attrs, 3 }, | ||
154 | 142 | { GRAIL_TYPE_ETOUCH, GEIS_GESTURE_PRIMITIVE_TOUCH, GEIS_GESTURE_TYPE_TOUCH3, GEIS_GESTURE_TOUCH, s_touch_attrs, 3 }, | ||
155 | 143 | { GRAIL_TYPE_TOUCH4, GEIS_GESTURE_PRIMITIVE_TOUCH, GEIS_GESTURE_TYPE_TOUCH4, GEIS_GESTURE_TOUCH, s_touch_attrs, 4 }, | ||
156 | 144 | { GRAIL_TYPE_MTOUCH, GEIS_GESTURE_PRIMITIVE_TOUCH, GEIS_GESTURE_TYPE_TOUCH4, GEIS_GESTURE_TOUCH, s_touch_attrs, 4 }, | ||
157 | 145 | { GRAIL_TYPE_TOUCH5, GEIS_GESTURE_PRIMITIVE_TOUCH, GEIS_GESTURE_TYPE_TOUCH5, GEIS_GESTURE_TOUCH, s_touch_attrs, 5 }, | ||
158 | 131 | { -1, -1, NULL, NULL, NULL, 0 } /* sentinel */ | 146 | { -1, -1, NULL, NULL, NULL, 0 } /* sentinel */ |
159 | 132 | }; | 147 | }; |
160 | 133 | 148 | ||
161 | 134 | 149 | ||
162 | 135 | /* | 150 | /* |
171 | 136 | * Gets the bitmask for an entry in the GrailClassMap. | 151 | * Clears all the bits in a bitmask. |
172 | 137 | */ | 152 | */ |
173 | 138 | static inline GeisInteger | 153 | static inline void |
174 | 139 | _grail_bitmask_for(const GrailClassMap *entry) | 154 | _grail_mask_clear(uint32_t mask_len, |
175 | 140 | { | 155 | uint32_t* mask) |
176 | 141 | return 1 << entry->grail_type; | 156 | { |
177 | 142 | } | 157 | memset(mask, 0, mask_len * sizeof(uint32_t)); |
178 | 143 | 158 | } | |
179 | 159 | |||
180 | 160 | /* | ||
181 | 161 | * Sets the indicated bit in the bitmask. | ||
182 | 162 | * | ||
183 | 163 | * @todo: convert form uint32_t masks to byte masks | ||
184 | 164 | */ | ||
185 | 165 | static inline void | ||
186 | 166 | _grail_mask_set_bit(uint32_t mask_len __attribute__((unused)), | ||
187 | 167 | uint32_t* mask, | ||
188 | 168 | int index) | ||
189 | 169 | { | ||
190 | 170 | mask[index >> 5] |= 1 << (index & 0x1f); | ||
191 | 171 | } | ||
192 | 172 | |||
193 | 173 | /* | ||
194 | 174 | * Masks the bits in one bitmask by the bots in another. | ||
195 | 175 | */ | ||
196 | 176 | static inline void | ||
197 | 177 | _grail_mask_and(uint32_t mask_len, | ||
198 | 178 | uint32_t* mask_lhs, | ||
199 | 179 | uint32_t* mask_rhs) | ||
200 | 180 | { | ||
201 | 181 | uint32_t i; | ||
202 | 182 | for (i = 0; i < mask_len; ++i) | ||
203 | 183 | { | ||
204 | 184 | mask_lhs[i] &= mask_rhs[i]; | ||
205 | 185 | } | ||
206 | 186 | } | ||
207 | 144 | 187 | ||
208 | 145 | /* | 188 | /* |
209 | 146 | * Initializes the XCB gesture bitmap flags. | 189 | * Initializes the XCB gesture bitmap flags. |
210 | @@ -153,40 +196,46 @@ | |||
211 | 153 | uint32_t *mask_len, | 196 | uint32_t *mask_len, |
212 | 154 | uint32_t *mask) | 197 | uint32_t *mask) |
213 | 155 | { | 198 | { |
230 | 156 | *mask_len = 1; /* always */ | 199 | _grail_mask_clear(*mask_len, mask); |
231 | 157 | *mask = 0; | 200 | |
232 | 158 | *mask = (1 << GRAIL_TYPE_DRAG1) | 201 | _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_DRAG1); |
233 | 159 | | (1 << GRAIL_TYPE_PINCH1) | 202 | _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_PINCH1); |
234 | 160 | | (1 << GRAIL_TYPE_ROTATE1) | 203 | _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_ROTATE1); |
235 | 161 | | (1 << GRAIL_TYPE_TAP1) | 204 | _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_TAP1); |
236 | 162 | | (1 << GRAIL_TYPE_DRAG2) | 205 | _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_TOUCH1); |
237 | 163 | | (1 << GRAIL_TYPE_PINCH2) | 206 | _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_DRAG2); |
238 | 164 | | (1 << GRAIL_TYPE_ROTATE2) | 207 | _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_PINCH2); |
239 | 165 | | (1 << GRAIL_TYPE_TAP2) | 208 | _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_ROTATE2); |
240 | 166 | | (1 << GRAIL_TYPE_TAP3) | 209 | _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_TAP2); |
241 | 167 | | (1 << GRAIL_TYPE_TAP4) | 210 | _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_TOUCH2); |
242 | 168 | | (1 << GRAIL_TYPE_DRAG5) | 211 | _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_TAP3); |
243 | 169 | | (1 << GRAIL_TYPE_PINCH5) | 212 | _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_TAP4); |
244 | 170 | | (1 << GRAIL_TYPE_ROTATE5) | 213 | _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_DRAG5); |
245 | 171 | | (1 << GRAIL_TYPE_TAP5); | 214 | _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_PINCH5); |
246 | 215 | _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_ROTATE5); | ||
247 | 216 | _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_TAP5); | ||
248 | 172 | 217 | ||
249 | 173 | if (sub_flags & GEIS_SUBSCRIPTION_CONT) | 218 | if (sub_flags & GEIS_SUBSCRIPTION_CONT) |
250 | 174 | { | 219 | { |
257 | 175 | *mask |= ( (1 << GRAIL_TYPE_EDRAG) | 220 | _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_EDRAG); |
258 | 176 | | (1 << GRAIL_TYPE_EPINCH) | 221 | _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_EPINCH); |
259 | 177 | | (1 << GRAIL_TYPE_EROTATE) | 222 | _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_EROTATE); |
260 | 178 | | (1 << GRAIL_TYPE_MDRAG) | 223 | _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_ETOUCH); |
261 | 179 | | (1 << GRAIL_TYPE_MPINCH) | 224 | _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_MDRAG); |
262 | 180 | | (1 << GRAIL_TYPE_MROTATE) ); | 225 | _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_MPINCH); |
263 | 226 | _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_MROTATE); | ||
264 | 227 | _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_MTOUCH); | ||
265 | 181 | } | 228 | } |
266 | 182 | else | 229 | else |
267 | 183 | { | 230 | { |
274 | 184 | *mask |= ( (1 << GRAIL_TYPE_DRAG3) | 231 | _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_DRAG3); |
275 | 185 | | (1 << GRAIL_TYPE_PINCH3) | 232 | _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_PINCH3); |
276 | 186 | | (1 << GRAIL_TYPE_ROTATE3) | 233 | _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_ROTATE3); |
277 | 187 | | (1 << GRAIL_TYPE_DRAG4) | 234 | _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_TOUCH3); |
278 | 188 | | (1 << GRAIL_TYPE_PINCH4) | 235 | _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_DRAG4); |
279 | 189 | | (1 << GRAIL_TYPE_ROTATE4) ); | 236 | _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_PINCH4); |
280 | 237 | _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_ROTATE4); | ||
281 | 238 | _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_TOUCH4); | ||
282 | 190 | } | 239 | } |
283 | 191 | 240 | ||
284 | 192 | 241 | ||
285 | @@ -194,7 +243,7 @@ | |||
286 | 194 | { | 243 | { |
287 | 195 | *mask |= (1 << GRAIL_TYPE_SYSFLAG1); | 244 | *mask |= (1 << GRAIL_TYPE_SYSFLAG1); |
288 | 196 | } | 245 | } |
290 | 197 | geis_debug("initial bitmap is 0x%08x", *mask); | 246 | geis_debug("initial bitmap is 0x%08x %08x", mask[1], mask[0]); |
291 | 198 | } | 247 | } |
292 | 199 | 248 | ||
293 | 200 | 249 | ||
294 | @@ -203,23 +252,25 @@ | |||
295 | 203 | */ | 252 | */ |
296 | 204 | void | 253 | void |
297 | 205 | geis_xcb_backend_gesture_bitmask_filter_class(GeisString class_name, | 254 | geis_xcb_backend_gesture_bitmask_filter_class(GeisString class_name, |
299 | 206 | uint32_t *mask_len __attribute__((unused)), | 255 | uint32_t *mask_len, |
300 | 207 | uint32_t *mask) | 256 | uint32_t *mask) |
301 | 208 | { | 257 | { |
302 | 209 | uint32_t class_mask = 0; | ||
303 | 210 | const GrailClassMap *grail_class; | 258 | const GrailClassMap *grail_class; |
304 | 259 | uint32_t class_mask[*mask_len]; | ||
305 | 260 | |||
306 | 261 | _grail_mask_clear(*mask_len, class_mask); | ||
307 | 211 | for (grail_class = s_grail_class_map; | 262 | for (grail_class = s_grail_class_map; |
308 | 212 | grail_class->geis_class_id >= 0; | 263 | grail_class->geis_class_id >= 0; |
309 | 213 | ++grail_class) | 264 | ++grail_class) |
310 | 214 | { | 265 | { |
311 | 215 | if (0 == strcmp(grail_class->class_name, class_name)) | 266 | if (0 == strcmp(grail_class->class_name, class_name)) |
312 | 216 | { | 267 | { |
314 | 217 | class_mask |= _grail_bitmask_for(grail_class); | 268 | _grail_mask_set_bit(*mask_len, class_mask, grail_class->grail_type); |
315 | 218 | } | 269 | } |
316 | 219 | } | 270 | } |
320 | 220 | *mask &= class_mask; | 271 | _grail_mask_and(*mask_len, mask, class_mask); |
321 | 221 | geis_debug("class=\"%s\" mask=0x%08x bitmap is now 0x%08x", | 272 | geis_debug("class=\"%s\" mask is 0x%08x %08x bitmap is now 0x%08x %08x", |
322 | 222 | class_name, class_mask, *mask); | 273 | class_name, class_mask[1], class_mask[0], mask[1], mask[0]); |
323 | 223 | } | 274 | } |
324 | 224 | 275 | ||
325 | 225 | 276 | ||
326 | @@ -230,11 +281,13 @@ | |||
327 | 230 | void | 281 | void |
328 | 231 | geis_xcb_backend_gesture_bitmask_filter_touches(GeisSize min_touches, | 282 | geis_xcb_backend_gesture_bitmask_filter_touches(GeisSize min_touches, |
329 | 232 | GeisSize max_touches, | 283 | GeisSize max_touches, |
331 | 233 | uint32_t *mask_len __attribute__((unused)), | 284 | uint32_t *mask_len, |
332 | 234 | uint32_t *mask) | 285 | uint32_t *mask) |
333 | 235 | { | 286 | { |
334 | 236 | uint32_t touch_mask = 0; | ||
335 | 237 | const GrailClassMap *grail_class; | 287 | const GrailClassMap *grail_class; |
336 | 288 | uint32_t touch_mask[*mask_len]; | ||
337 | 289 | |||
338 | 290 | _grail_mask_clear(*mask_len, touch_mask); | ||
339 | 238 | for (grail_class = s_grail_class_map; | 291 | for (grail_class = s_grail_class_map; |
340 | 239 | grail_class->geis_class_id >= 0; | 292 | grail_class->geis_class_id >= 0; |
341 | 240 | ++grail_class) | 293 | ++grail_class) |
342 | @@ -242,12 +295,12 @@ | |||
343 | 242 | if (min_touches <= grail_class->touch_count | 295 | if (min_touches <= grail_class->touch_count |
344 | 243 | && grail_class->touch_count <= max_touches) | 296 | && grail_class->touch_count <= max_touches) |
345 | 244 | { | 297 | { |
347 | 245 | touch_mask |= _grail_bitmask_for(grail_class); | 298 | _grail_mask_set_bit(*mask_len, touch_mask, grail_class->grail_type); |
348 | 246 | } | 299 | } |
349 | 247 | } | 300 | } |
353 | 248 | *mask &= touch_mask; | 301 | _grail_mask_and(*mask_len, mask, touch_mask); |
354 | 249 | geis_debug("min_touches=%lu max_touches=%lu mask=0x%08x bitmap is now 0x%08x", | 302 | geis_debug("min_touches=%lu max_touches=%lu mask is 0x%08x %08x bitmap is now 0x%08x %08x", |
355 | 250 | min_touches, max_touches, touch_mask, *mask); | 303 | min_touches, max_touches, touch_mask[1], touch_mask[0], mask[1], mask[0]); |
356 | 251 | } | 304 | } |
357 | 252 | 305 | ||
358 | 253 | 306 | ||
359 | 254 | 307 | ||
360 | === modified file 'libutouch-geis/geis_v1.c' | |||
361 | --- libutouch-geis/geis_v1.c 2011-03-13 18:00:45 +0000 | |||
362 | +++ libutouch-geis/geis_v1.c 2011-03-28 12:59:24 +0000 | |||
363 | @@ -72,6 +72,11 @@ | |||
364 | 72 | { GEIS_GESTURE_TYPE_TAP3, GEIS_GESTURE_TAP, 3 }, | 72 | { GEIS_GESTURE_TYPE_TAP3, GEIS_GESTURE_TAP, 3 }, |
365 | 73 | { GEIS_GESTURE_TYPE_TAP4, GEIS_GESTURE_TAP, 4 }, | 73 | { GEIS_GESTURE_TYPE_TAP4, GEIS_GESTURE_TAP, 4 }, |
366 | 74 | { GEIS_GESTURE_TYPE_TAP5, GEIS_GESTURE_TAP, 5 }, | 74 | { GEIS_GESTURE_TYPE_TAP5, GEIS_GESTURE_TAP, 5 }, |
367 | 75 | { GEIS_GESTURE_TYPE_TOUCH1, GEIS_GESTURE_TOUCH, 1 }, | ||
368 | 76 | { GEIS_GESTURE_TYPE_TOUCH2, GEIS_GESTURE_TOUCH, 2 }, | ||
369 | 77 | { GEIS_GESTURE_TYPE_TOUCH3, GEIS_GESTURE_TOUCH, 3 }, | ||
370 | 78 | { GEIS_GESTURE_TYPE_TOUCH4, GEIS_GESTURE_TOUCH, 4 }, | ||
371 | 79 | { GEIS_GESTURE_TYPE_TOUCH5, GEIS_GESTURE_TOUCH, 5 }, | ||
372 | 75 | { NULL, NULL, 0 } | 80 | { NULL, NULL, 0 } |
373 | 76 | }; | 81 | }; |
374 | 77 | 82 | ||
375 | 78 | 83 | ||
376 | === modified file 'testsuite/geis1/Makefile.am' | |||
377 | --- testsuite/geis1/Makefile.am 2011-03-08 14:49:28 +0000 | |||
378 | +++ testsuite/geis1/Makefile.am 2011-03-28 12:59:24 +0000 | |||
379 | @@ -15,6 +15,7 @@ | |||
380 | 15 | 15 | ||
381 | 16 | check_geis1_api_SOURCES = \ | 16 | check_geis1_api_SOURCES = \ |
382 | 17 | check_instance.c \ | 17 | check_instance.c \ |
383 | 18 | check_gesture_types.c \ | ||
384 | 18 | check_gesture_attrs.c \ | 19 | check_gesture_attrs.c \ |
385 | 19 | check_geis1_api.c | 20 | check_geis1_api.c |
386 | 20 | 21 | ||
387 | 21 | 22 | ||
388 | === modified file 'testsuite/geis1/check_geis1_api.c' | |||
389 | --- testsuite/geis1/check_geis1_api.c 2011-03-08 14:49:28 +0000 | |||
390 | +++ testsuite/geis1/check_geis1_api.c 2011-03-28 12:59:24 +0000 | |||
391 | @@ -21,6 +21,7 @@ | |||
392 | 21 | #include <check.h> | 21 | #include <check.h> |
393 | 22 | 22 | ||
394 | 23 | extern Suite *geis1_instance_suite_new(); | 23 | extern Suite *geis1_instance_suite_new(); |
395 | 24 | extern Suite *geis1_gesture_types_new(); | ||
396 | 24 | extern Suite *geis1_gesture_attrs_new(); | 25 | extern Suite *geis1_gesture_attrs_new(); |
397 | 25 | 26 | ||
398 | 26 | int | 27 | int |
399 | @@ -31,6 +32,7 @@ | |||
400 | 31 | Suite *s = suite_create("GEIS v1.0 API"); | 32 | Suite *s = suite_create("GEIS v1.0 API"); |
401 | 32 | SRunner *sr = srunner_create(s); | 33 | SRunner *sr = srunner_create(s); |
402 | 33 | srunner_add_suite(sr, geis1_instance_suite_new()); | 34 | srunner_add_suite(sr, geis1_instance_suite_new()); |
403 | 35 | srunner_add_suite(sr, geis1_gesture_types_new()); | ||
404 | 34 | srunner_add_suite(sr, geis1_gesture_attrs_new()); | 36 | srunner_add_suite(sr, geis1_gesture_attrs_new()); |
405 | 35 | 37 | ||
406 | 36 | srunner_set_log(sr, "geis1_api.log"); | 38 | srunner_set_log(sr, "geis1_api.log"); |
407 | 37 | 39 | ||
408 | === added file 'testsuite/geis1/check_gesture_types.c' | |||
409 | --- testsuite/geis1/check_gesture_types.c 1970-01-01 00:00:00 +0000 | |||
410 | +++ testsuite/geis1/check_gesture_types.c 2011-03-28 12:59:24 +0000 | |||
411 | @@ -0,0 +1,77 @@ | |||
412 | 1 | /** | ||
413 | 2 | * @file check_gesture_types.c | ||
414 | 3 | * @brief Unit tests for GEIS v1 gesture types | ||
415 | 4 | * | ||
416 | 5 | * Copyright 2011 Canonical Ltd. | ||
417 | 6 | * | ||
418 | 7 | * This library is free software; you can redistribute it and/or modify it under | ||
419 | 8 | * the terms of the GNU Lesser General Public License as published by the Free | ||
420 | 9 | * Software Foundation; either version 3 of the License, or (at your option) any | ||
421 | 10 | * later version. | ||
422 | 11 | * | ||
423 | 12 | * This library is distributed in the hope that it will be useful, but WITHOUT | ||
424 | 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
425 | 14 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | ||
426 | 15 | * details. | ||
427 | 16 | * | ||
428 | 17 | * You should have received a copy of the GNU Lesser General Public License | ||
429 | 18 | * along with this program; if not, write to the Free Software Foundation, Inc., | ||
430 | 19 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
431 | 20 | */ | ||
432 | 21 | #include <check.h> | ||
433 | 22 | |||
434 | 23 | #include <geis/geis.h> | ||
435 | 24 | |||
436 | 25 | |||
437 | 26 | START_TEST(gesture_types) | ||
438 | 27 | { | ||
439 | 28 | GeisInteger geis_type; | ||
440 | 29 | GeisString geis_type_name; | ||
441 | 30 | |||
442 | 31 | geis_type = GEIS_GESTURE_PRIMITIVE_DRAG; | ||
443 | 32 | geis_type = GEIS_GESTURE_PRIMITIVE_PINCH; | ||
444 | 33 | geis_type = GEIS_GESTURE_PRIMITIVE_ROTATE; | ||
445 | 34 | geis_type = GEIS_GESTURE_PRIMITIVE_TAP; | ||
446 | 35 | geis_type = GEIS_GESTURE_PRIMITIVE_TOUCH; | ||
447 | 36 | |||
448 | 37 | geis_type_name = GEIS_GESTURE_TYPE_DRAG1; | ||
449 | 38 | geis_type_name = GEIS_GESTURE_TYPE_DRAG2; | ||
450 | 39 | geis_type_name = GEIS_GESTURE_TYPE_DRAG3; | ||
451 | 40 | geis_type_name = GEIS_GESTURE_TYPE_DRAG4; | ||
452 | 41 | geis_type_name = GEIS_GESTURE_TYPE_DRAG5; | ||
453 | 42 | geis_type_name = GEIS_GESTURE_TYPE_PINCH1; | ||
454 | 43 | geis_type_name = GEIS_GESTURE_TYPE_PINCH2; | ||
455 | 44 | geis_type_name = GEIS_GESTURE_TYPE_PINCH3; | ||
456 | 45 | geis_type_name = GEIS_GESTURE_TYPE_PINCH4; | ||
457 | 46 | geis_type_name = GEIS_GESTURE_TYPE_PINCH5; | ||
458 | 47 | geis_type_name = GEIS_GESTURE_TYPE_ROTATE1; | ||
459 | 48 | geis_type_name = GEIS_GESTURE_TYPE_ROTATE2; | ||
460 | 49 | geis_type_name = GEIS_GESTURE_TYPE_ROTATE3; | ||
461 | 50 | geis_type_name = GEIS_GESTURE_TYPE_ROTATE4; | ||
462 | 51 | geis_type_name = GEIS_GESTURE_TYPE_ROTATE5; | ||
463 | 52 | geis_type_name = GEIS_GESTURE_TYPE_TAP1; | ||
464 | 53 | geis_type_name = GEIS_GESTURE_TYPE_TAP2; | ||
465 | 54 | geis_type_name = GEIS_GESTURE_TYPE_TAP3; | ||
466 | 55 | geis_type_name = GEIS_GESTURE_TYPE_TAP4; | ||
467 | 56 | geis_type_name = GEIS_GESTURE_TYPE_TAP5; | ||
468 | 57 | geis_type_name = GEIS_GESTURE_TYPE_TOUCH1; | ||
469 | 58 | geis_type_name = GEIS_GESTURE_TYPE_TOUCH2; | ||
470 | 59 | geis_type_name = GEIS_GESTURE_TYPE_TOUCH3; | ||
471 | 60 | geis_type_name = GEIS_GESTURE_TYPE_TOUCH4; | ||
472 | 61 | geis_type_name = GEIS_GESTURE_TYPE_TOUCH5; | ||
473 | 62 | } | ||
474 | 63 | END_TEST | ||
475 | 64 | |||
476 | 65 | Suite * | ||
477 | 66 | geis1_gesture_types_new() | ||
478 | 67 | { | ||
479 | 68 | Suite *s = suite_create("geis1_gesture_types"); | ||
480 | 69 | TCase *test; | ||
481 | 70 | |||
482 | 71 | test = tcase_create("gesture_types"); | ||
483 | 72 | tcase_add_test(test, gesture_types); | ||
484 | 73 | suite_add_tcase(s, test); | ||
485 | 74 | |||
486 | 75 | return s; | ||
487 | 76 | } | ||
488 | 77 | |||
489 | 0 | 78 | ||
490 | === modified file 'testsuite/geistest/geistest.c' | |||
491 | --- testsuite/geistest/geistest.c 2011-03-22 16:35:35 +0000 | |||
492 | +++ testsuite/geistest/geistest.c 2011-03-28 12:59:24 +0000 | |||
493 | @@ -33,6 +33,7 @@ | |||
494 | 33 | GEIS_GESTURE_TYPE_PINCH2, GEIS_GESTURE_TYPE_PINCH3, | 33 | GEIS_GESTURE_TYPE_PINCH2, GEIS_GESTURE_TYPE_PINCH3, |
495 | 34 | GEIS_GESTURE_TYPE_ROTATE2, GEIS_GESTURE_TYPE_ROTATE3, | 34 | GEIS_GESTURE_TYPE_ROTATE2, GEIS_GESTURE_TYPE_ROTATE3, |
496 | 35 | GEIS_GESTURE_TYPE_TAP2, GEIS_GESTURE_TYPE_TAP3, GEIS_GESTURE_TYPE_TAP4, | 35 | GEIS_GESTURE_TYPE_TAP2, GEIS_GESTURE_TYPE_TAP3, GEIS_GESTURE_TYPE_TAP4, |
497 | 36 | GEIS_GESTURE_TYPE_TOUCH3, GEIS_GESTURE_TYPE_TOUCH4, | ||
498 | 36 | NULL | 37 | NULL |
499 | 37 | }; | 38 | }; |
500 | 38 | 39 |
I'd prefer to move to C99 and use dynamic array sizes than use alloca, just cause it seems more conventional.
The s_grail_class_map array has a bunch of changes to unaffected gesture types. It appears there's a comma added near the end of each line. I think the comma is superfluous and should be removed so there's no change.
grail_mask_clear could just use memset, which would make the code more readable.
Why does grail_mask_setbit only concern itself with the lower 5 bits of each uint32_t?
Although grail exposes velocity attributes for touch gestures, I don't want to expose the attributes through GEIS. I propose masking them out.
Looks good otherwise!