Merge lp:~bregma/libgrip/lp-1168370 into lp:libgrip
- lp-1168370
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Stephen M. Webb | ||||
Approved revision: | 80 | ||||
Merged at revision: | 77 | ||||
Proposed branch: | lp:~bregma/libgrip/lp-1168370 | ||||
Merge into: | lp:libgrip | ||||
Diff against target: |
2145 lines (+703/-1177) 2 files modified
src/gripgesturemanager.c (+672/-1154) src/gripinputdevice.c (+31/-23) |
||||
To merge this branch: | bzr merge lp:~bregma/libgrip/lp-1168370 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Open Input Framework Team | Pending | ||
Review via email: mp+159242@code.launchpad.net |
Commit message
Moved to GEISv2 to fix an unfortunate lack of events (lp: #1168370).
Description of the change
Rewrote libgrip to use GEISv2 instead of GEISv1 because libgrip's assumptions about device tracking across instances was invalid, and GEISv1 is deprecated.
PS Jenkins bot (ps-jenkins) wrote : | # |
Brandon Schaefer (brandontschaefer) wrote : | # |
120 -static const gchar *geis_gesture_
Moved?
252 + g_ptr_array_
496 + g_ptr_array_foreach (priv->devices, (GFunc) g_object_unref, NULL);
Does manager-
230 + goto final_exit;
333 +final_exit:
334 + return;
335 +}
Cant you just do a 'return;'? Instead of a goto?
362 + for (l = priv->classes; l != NULL; l = l->next)
363 + {
355 + switch (geis_event_
356 + {
Most likely just the coding style, but how come its switched from new line style to GNU style? (or the new line + spaces style).
Hopefully these stay constant during the loop:
1172 + for (i = 0; i < geis_groupset_
1182 + for (j = 0; j < geis_group_
I couldn't find them defined, or how you add to it soo I wasn't sure if:
1184 + GeisFrame frame = geis_group_
Would extract, and remove anything from the group_frame. Hopefully not!
- 79. By Stephen M. Webb
-
replaced gotos with something more GTK-like
- 80. By Stephen M. Webb
-
small stylistic repair
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:80
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Stephen M. Webb (bregma) wrote : | # |
(1) manager-
(2) gotos replaced
(3) style fixed
(4) the data returned from GEIS is readonly, none of the group/frame accessor calls modifiy the data
Preview Diff
1 | === modified file 'src/gripgesturemanager.c' | |||
2 | --- src/gripgesturemanager.c 2012-05-29 20:47:37 +0000 | |||
3 | +++ src/gripgesturemanager.c 2013-04-17 15:02:24 +0000 | |||
4 | @@ -1,5 +1,5 @@ | |||
5 | 1 | /* | 1 | /* |
7 | 2 | * Copyright 2010, 2011 Canonical, Ltd. | 2 | * Copyright 2010, 2011, 2013 Canonical, Ltd. |
8 | 3 | * | 3 | * |
9 | 4 | * This program is free software: you can redistribute it and/or modify it | 4 | * This program is free software: you can redistribute it and/or modify it |
10 | 5 | * under the terms of either or both of the following licenses: | 5 | * under the terms of either or both of the following licenses: |
11 | @@ -29,25 +29,49 @@ | |||
12 | 29 | #include <geis/geis.h> | 29 | #include <geis/geis.h> |
13 | 30 | #include "gripinputdevice.h" | 30 | #include "gripinputdevice.h" |
14 | 31 | 31 | ||
15 | 32 | typedef struct _GripGestureRegistration GripGestureRegistration; | ||
16 | 33 | typedef struct _GripGestureBinding GripGestureBinding; | 32 | typedef struct _GripGestureBinding GripGestureBinding; |
17 | 34 | typedef struct _GripRegistrationRequest GripRegistrationRequest; | 33 | typedef struct _GripRegistrationRequest GripRegistrationRequest; |
18 | 35 | 34 | ||
19 | 36 | typedef GPtrArray GripDevices; | 35 | typedef GPtrArray GripDevices; |
20 | 37 | 36 | ||
26 | 38 | struct Registrations { | 37 | /* |
27 | 39 | GripGestureRegistration *touchscreen; | 38 | * GripGestureClassMap: |
28 | 40 | GripGestureRegistration *touchpad; | 39 | * @grip_type: the libgrip gesture type |
29 | 41 | GripGestureRegistration *independent; | 40 | * @geis_class: the geis gesture class |
30 | 42 | }; | 41 | * |
31 | 42 | * Provides a mapping between a grip gesture type and a geis gesture class. | ||
32 | 43 | */ | ||
33 | 44 | typedef struct _GripGestureClassMap | ||
34 | 45 | { | ||
35 | 46 | GripGestureType grip_type; | ||
36 | 47 | GeisGestureClass geis_class; | ||
37 | 48 | } GripGestureClassMap; | ||
38 | 43 | 49 | ||
39 | 50 | /* | ||
40 | 51 | * GripGestureManagerPrivate: | ||
41 | 52 | * @geis: the GEIS instance | ||
42 | 53 | * @iochannel: connects the geis object with the main loop | ||
43 | 54 | * @iochannel_id: the identifier for the iochannel | ||
44 | 55 | * @devices: a collection of recognized input devices | ||
45 | 56 | * @classes: a list of grip type to geis class mappings | ||
46 | 57 | * @requests: a list of pending binding requests | ||
47 | 58 | * @bindings: a list of current gesture bindings | ||
48 | 59 | */ | ||
49 | 44 | struct _GripGestureManagerPrivate | 60 | struct _GripGestureManagerPrivate |
50 | 45 | { | 61 | { |
54 | 46 | GHashTable *registered_windows; | 62 | Geis geis; |
55 | 47 | GList *requests; | 63 | GIOChannel *iochannel; |
56 | 48 | GripDevices *devices; | 64 | int iochannel_id; |
57 | 65 | GripDevices *devices; | ||
58 | 66 | GList *classes; | ||
59 | 67 | GList *requests; | ||
60 | 68 | GList *bindings; | ||
61 | 49 | }; | 69 | }; |
62 | 50 | 70 | ||
63 | 71 | G_DEFINE_TYPE (GripGestureManager, grip_gesture_manager, G_TYPE_OBJECT) | ||
64 | 72 | |||
65 | 73 | #define GRIP_GESTURE_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GRIP_TYPE_GESTURE_MANAGER, GripGestureManagerPrivate)) | ||
66 | 74 | |||
67 | 51 | /* | 75 | /* |
68 | 52 | * GripGestureBinding: | 76 | * GripGestureBinding: |
69 | 53 | * @type: | 77 | * @type: |
70 | @@ -64,32 +88,27 @@ | |||
71 | 64 | GripGestureType type; | 88 | GripGestureType type; |
72 | 65 | GtkWidget *widget; | 89 | GtkWidget *widget; |
73 | 66 | guint touches; | 90 | guint touches; |
74 | 91 | GeisSubscription subscription; | ||
75 | 67 | GripGestureCallback callback; | 92 | GripGestureCallback callback; |
76 | 68 | gpointer data; | 93 | gpointer data; |
77 | 69 | GDestroyNotify destroy; | 94 | GDestroyNotify destroy; |
78 | 70 | }; | 95 | }; |
79 | 71 | 96 | ||
80 | 97 | |||
81 | 72 | /* | 98 | /* |
88 | 73 | * GripGestureRegistration: | 99 | * GripRegistrationRequest: |
89 | 74 | * @window: the GTK window | 100 | * @manager: the @GripGestureManager |
90 | 75 | * @bindings: a list of #GripGestureBinding | 101 | * @widget: the GtkWidget to be bound |
91 | 76 | * @gesture_list: a list the names of GEIS gestures beging subscribed to | 102 | * @gesture_type: the type of gesture to subscribe for |
92 | 77 | * @instance: | 103 | * @device_type: the type of input device to subscribe for |
93 | 78 | * @iochannel: | 104 | * @touch_points: the number of touches making the gesture |
94 | 105 | * @callback: the callback to be invoked on gesture events | ||
95 | 106 | * @user_data: the callback context to be passed back on gesture events | ||
96 | 107 | * @destroy: function to destroy the callback context (NULL for no function) | ||
97 | 79 | * | 108 | * |
100 | 80 | * A collection of all gesture subscriptions for all widgets contained within a | 109 | * A collection of information required to register a callback for a |
101 | 81 | * top-level GTK window. | 110 | * particulatr type of gestures on a window. |
102 | 82 | */ | 111 | */ |
103 | 83 | struct _GripGestureRegistration | ||
104 | 84 | { | ||
105 | 85 | GtkWindow *window; | ||
106 | 86 | GList *bindings; | ||
107 | 87 | GPtrArray *gesture_list; | ||
108 | 88 | GeisInstance instance; | ||
109 | 89 | GIOChannel *iochannel; | ||
110 | 90 | int iochannel_id; | ||
111 | 91 | }; | ||
112 | 92 | |||
113 | 93 | struct _GripRegistrationRequest | 112 | struct _GripRegistrationRequest |
114 | 94 | { | 113 | { |
115 | 95 | GripGestureManager *manager; | 114 | GripGestureManager *manager; |
116 | @@ -102,30 +121,8 @@ | |||
117 | 102 | GDestroyNotify destroy; | 121 | GDestroyNotify destroy; |
118 | 103 | }; | 122 | }; |
119 | 104 | 123 | ||
144 | 105 | static const gchar *geis_gesture_types[] = { | 124 | enum |
145 | 106 | GEIS_GESTURE_TYPE_DRAG1, | 125 | { |
122 | 107 | GEIS_GESTURE_TYPE_DRAG2, | ||
123 | 108 | GEIS_GESTURE_TYPE_DRAG3, | ||
124 | 109 | GEIS_GESTURE_TYPE_DRAG4, | ||
125 | 110 | GEIS_GESTURE_TYPE_DRAG5, | ||
126 | 111 | GEIS_GESTURE_TYPE_PINCH1, | ||
127 | 112 | GEIS_GESTURE_TYPE_PINCH2, | ||
128 | 113 | GEIS_GESTURE_TYPE_PINCH3, | ||
129 | 114 | GEIS_GESTURE_TYPE_PINCH4, | ||
130 | 115 | GEIS_GESTURE_TYPE_PINCH5, | ||
131 | 116 | GEIS_GESTURE_TYPE_ROTATE1, | ||
132 | 117 | GEIS_GESTURE_TYPE_ROTATE2, | ||
133 | 118 | GEIS_GESTURE_TYPE_ROTATE3, | ||
134 | 119 | GEIS_GESTURE_TYPE_ROTATE4, | ||
135 | 120 | GEIS_GESTURE_TYPE_ROTATE5, | ||
136 | 121 | GEIS_GESTURE_TYPE_TAP1, | ||
137 | 122 | GEIS_GESTURE_TYPE_TAP2, | ||
138 | 123 | GEIS_GESTURE_TYPE_TAP3, | ||
139 | 124 | GEIS_GESTURE_TYPE_TAP4, | ||
140 | 125 | GEIS_GESTURE_TYPE_TAP5, | ||
141 | 126 | }; | ||
142 | 127 | |||
143 | 128 | enum { | ||
146 | 129 | DEVICE_AVAILABLE, | 126 | DEVICE_AVAILABLE, |
147 | 130 | DEVICE_UNAVAILABLE, | 127 | DEVICE_UNAVAILABLE, |
148 | 131 | SIGNAL_LAST | 128 | SIGNAL_LAST |
149 | @@ -133,132 +130,151 @@ | |||
150 | 133 | 130 | ||
151 | 134 | static guint signals[SIGNAL_LAST]; | 131 | static guint signals[SIGNAL_LAST]; |
152 | 135 | 132 | ||
182 | 136 | static void gesture_added (void *cookie, | 133 | static void process_gesture_events (GripGestureManager *manager, |
183 | 137 | GeisGestureType gesture_type, | 134 | GeisEvent geis_event); |
155 | 138 | GeisGestureId gesture_id, | ||
156 | 139 | GeisSize attr_count, | ||
157 | 140 | GeisGestureAttr *attrs); | ||
158 | 141 | |||
159 | 142 | static void gesture_removed (void *cookie, | ||
160 | 143 | GeisGestureType gesture_type, | ||
161 | 144 | GeisGestureId gesture_id, | ||
162 | 145 | GeisSize attr_count, | ||
163 | 146 | GeisGestureAttr *attrs); | ||
164 | 147 | |||
165 | 148 | static void gesture_start (void *cookie, | ||
166 | 149 | GeisGestureType gesture_type, | ||
167 | 150 | GeisGestureId gesture_id, | ||
168 | 151 | GeisSize attr_count, | ||
169 | 152 | GeisGestureAttr *attrs); | ||
170 | 153 | |||
171 | 154 | static void gesture_update (void *cookie, | ||
172 | 155 | GeisGestureType gesture_type, | ||
173 | 156 | GeisGestureId gesture_id, | ||
174 | 157 | GeisSize attr_count, | ||
175 | 158 | GeisGestureAttr *attrs); | ||
176 | 159 | |||
177 | 160 | static void gesture_finish (void *cookie, | ||
178 | 161 | GeisGestureType gesture_type, | ||
179 | 162 | GeisGestureId gesture_id, | ||
180 | 163 | GeisSize attr_count, | ||
181 | 164 | GeisGestureAttr *attrs); | ||
184 | 165 | 135 | ||
185 | 166 | static void toplevel_mapped_cb (GtkWidget *toplevel, | 136 | static void toplevel_mapped_cb (GtkWidget *toplevel, |
186 | 167 | GdkEvent *event, | 137 | GdkEvent *event, |
187 | 168 | gpointer user_data); | 138 | gpointer user_data); |
188 | 169 | 139 | ||
281 | 170 | static GeisGestureFuncs gesture_funcs = { | 140 | |
282 | 171 | gesture_added, | 141 | static void |
283 | 172 | gesture_removed, | 142 | grip_geis_device_added(GripGestureManager *manager G_GNUC_UNUSED, GeisEvent geis_event) |
284 | 173 | gesture_start, | 143 | { |
285 | 174 | gesture_update, | 144 | GeisAttr attr = geis_event_attr_by_name(geis_event, GEIS_EVENT_ATTRIBUTE_DEVICE); |
286 | 175 | gesture_finish | 145 | g_return_if_fail (attr); |
287 | 176 | }; | 146 | |
288 | 177 | 147 | GeisDevice device = geis_attr_value_to_pointer(attr); | |
289 | 178 | 148 | g_return_if_fail (device); | |
290 | 179 | static void | 149 | |
291 | 180 | device_added (void *cookie, GeisInputDeviceId id G_GNUC_UNUSED, void *attrs) | 150 | switch (geis_event_type(geis_event)) |
292 | 181 | { | 151 | { |
293 | 182 | GripGestureManager *gesture_manager = (GripGestureManager *) cookie; | 152 | case GEIS_EVENT_DEVICE_AVAILABLE: |
294 | 183 | GripInputDevice *input_device = g_object_new (GRIP_TYPE_INPUT_DEVICE, | 153 | { |
295 | 184 | "device-attrs", attrs, | 154 | GripInputDevice *input_device = g_object_new (GRIP_TYPE_INPUT_DEVICE, |
296 | 185 | NULL); | 155 | "geis-device", device, |
297 | 186 | 156 | NULL); | |
298 | 187 | g_ptr_array_add(gesture_manager->priv->devices, input_device); | 157 | |
299 | 188 | g_signal_emit (gesture_manager, signals[DEVICE_AVAILABLE], 0, input_device); | 158 | g_ptr_array_add(manager->priv->devices, input_device); |
300 | 189 | } | 159 | g_signal_emit (manager, signals[DEVICE_AVAILABLE], 0, input_device); |
301 | 190 | 160 | } | |
302 | 191 | 161 | break; | |
303 | 192 | static void | 162 | |
304 | 193 | device_removed (void *cookie, GeisInputDeviceId id, void *attrs G_GNUC_UNUSED) | 163 | case GEIS_EVENT_DEVICE_UNAVAILABLE: |
305 | 194 | { | 164 | { |
306 | 195 | guint i; | 165 | guint device_id = geis_device_id (device); |
307 | 196 | GripGestureManager *gesture_manager = (GripGestureManager *) cookie; | 166 | GripDevices *devices = manager->priv->devices; |
308 | 197 | GripDevices *devices = gesture_manager->priv->devices; | 167 | guint i; |
309 | 198 | 168 | for (i = 0; i < devices->len; ++i) | |
310 | 199 | for (i = 0; i < devices->len; ++i) | 169 | { |
311 | 200 | { | 170 | GripInputDevice *input_device = g_ptr_array_index (devices, i); |
312 | 201 | GripInputDevice *input_device = g_ptr_array_index (devices, i); | 171 | if (device_id == grip_input_device_get_id (input_device)) |
313 | 202 | if (id == grip_input_device_get_id (input_device)) | 172 | { |
314 | 203 | { | 173 | g_signal_emit (manager, signals[DEVICE_UNAVAILABLE], 0, |
315 | 204 | g_signal_emit (gesture_manager, signals[DEVICE_UNAVAILABLE], 0, | 174 | input_device); |
316 | 205 | input_device); | 175 | g_ptr_array_remove_index (devices, i); |
317 | 206 | g_ptr_array_remove_index (devices, i); | 176 | break; |
318 | 207 | break; | 177 | } |
319 | 208 | } | 178 | } |
320 | 209 | } | 179 | } |
321 | 210 | } | 180 | break; |
322 | 211 | 181 | ||
323 | 212 | 182 | default: | |
324 | 213 | static GeisInputFuncs input_funcs = { | 183 | break; |
325 | 214 | device_added, | 184 | } |
326 | 215 | NULL, | 185 | } |
327 | 216 | device_removed, | 186 | |
328 | 217 | }; | 187 | |
329 | 218 | 188 | static void | |
330 | 219 | 189 | process_class_event(GripGestureManagerPrivate *priv G_GNUC_UNUSED, GeisEvent geis_event) | |
331 | 220 | static void | 190 | { |
332 | 221 | grip_get_devices (GripGestureManager *gesture_manager) | 191 | GeisAttr attr = geis_event_attr_by_name (geis_event, |
333 | 222 | { | 192 | GEIS_EVENT_ATTRIBUTE_CLASS); |
334 | 223 | GeisXcbWinInfo xcb_win_info = { | 193 | g_return_if_fail (attr); |
335 | 224 | .display_name = NULL, | 194 | |
336 | 225 | .screenp = NULL, | 195 | GeisGestureClass gesture_class = geis_attr_value_to_pointer (attr); |
337 | 226 | .window_id = 0, | 196 | g_return_if_fail (gesture_class); |
338 | 227 | }; | 197 | |
339 | 228 | GeisWinInfo win_info = { | 198 | switch (geis_event_type (geis_event)) |
340 | 229 | GEIS_XCB_FULL_WINDOW, | 199 | { |
341 | 230 | &xcb_win_info, | 200 | case GEIS_EVENT_CLASS_AVAILABLE: |
342 | 231 | }; | 201 | { |
343 | 232 | GeisInstance instance; | 202 | gchar const *class_name = geis_gesture_class_name (gesture_class); |
344 | 233 | GeisStatus status; | 203 | /* check for dups */ |
345 | 234 | 204 | GList *l; | |
346 | 235 | status = geis_init (&win_info, &instance); | 205 | for (l = priv->classes; l != NULL; l = l->next) |
347 | 236 | if (status != GEIS_STATUS_SUCCESS) | 206 | { |
348 | 237 | { | 207 | GripGestureClassMap *p = (GripGestureClassMap *)l->data; |
349 | 238 | g_warning ("failed to determine device types\n"); | 208 | if (0 == g_strcmp0 (geis_gesture_class_name (p->geis_class), |
350 | 239 | return; | 209 | class_name)) |
351 | 240 | } | 210 | { |
352 | 241 | 211 | g_warning ("multiple class definitions for '%s' received", | |
353 | 242 | status = geis_input_devices (instance, &input_funcs, gesture_manager); | 212 | class_name); |
354 | 243 | if (status != GEIS_STATUS_SUCCESS) | 213 | return; |
355 | 244 | { | 214 | } |
356 | 245 | g_warning ("failed to determine device types\n"); | 215 | } |
357 | 246 | return; | 216 | |
358 | 247 | } | 217 | GripGestureClassMap *m = g_new0 (GripGestureClassMap, 1); |
359 | 248 | 218 | if (0 == g_strcmp0 (class_name, "Drag")) | |
360 | 249 | status = geis_event_dispatch (instance); | 219 | m->grip_type = GRIP_GESTURE_DRAG; |
361 | 250 | if (status != GEIS_STATUS_SUCCESS) | 220 | else if (0 == g_strcmp0 (class_name, "Pinch")) |
362 | 251 | { | 221 | m->grip_type = GRIP_GESTURE_PINCH; |
363 | 252 | g_warning ("failed to determine device types\n"); | 222 | else if (0 == g_strcmp0 (class_name, "Rotate")) |
364 | 253 | return; | 223 | m->grip_type = GRIP_GESTURE_ROTATE; |
365 | 254 | } | 224 | else if (0 == g_strcmp0 (class_name, "Tap")) |
366 | 255 | 225 | m->grip_type = GRIP_GESTURE_TAP; | |
367 | 256 | geis_finish (instance); | 226 | else |
368 | 257 | } | 227 | m->grip_type = (GripGestureType)100; |
369 | 258 | 228 | m->geis_class = gesture_class; | |
370 | 259 | G_DEFINE_TYPE (GripGestureManager, grip_gesture_manager, G_TYPE_OBJECT) | 229 | priv->classes = g_list_append (priv->classes, m); |
371 | 260 | 230 | } | |
372 | 261 | #define GRIP_GESTURE_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GRIP_TYPE_GESTURE_MANAGER, GripGestureManagerPrivate)) | 231 | break; |
373 | 232 | |||
374 | 233 | default: | ||
375 | 234 | /* @todo handle class-changed and class-unavailable events */ | ||
376 | 235 | g_warning ("gesture class event ignored"); | ||
377 | 236 | break; | ||
378 | 237 | } | ||
379 | 238 | } | ||
380 | 239 | |||
381 | 240 | |||
382 | 241 | static void | ||
383 | 242 | grip_geis_event_callback(Geis geis G_GNUC_UNUSED, GeisEvent geis_event, void *context) | ||
384 | 243 | { | ||
385 | 244 | GripGestureManager *self = GRIP_GESTURE_MANAGER (context); | ||
386 | 245 | GripGestureManagerPrivate *priv = GRIP_GESTURE_MANAGER_GET_PRIVATE (self); | ||
387 | 246 | |||
388 | 247 | switch (geis_event_type(geis_event)) | ||
389 | 248 | { | ||
390 | 249 | case GEIS_EVENT_DEVICE_AVAILABLE: | ||
391 | 250 | case GEIS_EVENT_DEVICE_UNAVAILABLE: | ||
392 | 251 | grip_geis_device_added (self, geis_event); | ||
393 | 252 | break; | ||
394 | 253 | |||
395 | 254 | case GEIS_EVENT_CLASS_AVAILABLE: | ||
396 | 255 | case GEIS_EVENT_CLASS_CHANGED: | ||
397 | 256 | case GEIS_EVENT_CLASS_UNAVAILABLE: | ||
398 | 257 | process_class_event(priv, geis_event); | ||
399 | 258 | break; | ||
400 | 259 | |||
401 | 260 | case GEIS_EVENT_INIT_COMPLETE: | ||
402 | 261 | break; | ||
403 | 262 | |||
404 | 263 | case GEIS_EVENT_GESTURE_BEGIN: | ||
405 | 264 | case GEIS_EVENT_GESTURE_UPDATE: | ||
406 | 265 | case GEIS_EVENT_GESTURE_END: | ||
407 | 266 | process_gesture_events(self, geis_event); | ||
408 | 267 | break; | ||
409 | 268 | |||
410 | 269 | default: | ||
411 | 270 | g_warning ("event ignored"); | ||
412 | 271 | break; | ||
413 | 272 | } | ||
414 | 273 | |||
415 | 274 | geis_event_delete(geis_event); | ||
416 | 275 | return; | ||
417 | 276 | } | ||
418 | 277 | |||
419 | 262 | 278 | ||
420 | 263 | static void | 279 | static void |
421 | 264 | grip_gesture_manager_dispose (GObject *object G_GNUC_UNUSED) | 280 | grip_gesture_manager_dispose (GObject *object G_GNUC_UNUSED) |
422 | @@ -267,59 +283,18 @@ | |||
423 | 267 | 283 | ||
424 | 268 | 284 | ||
425 | 269 | static void | 285 | static void |
426 | 270 | free_registration(GripGestureRegistration *reg) | ||
427 | 271 | { | ||
428 | 272 | GList *tmp = NULL; | ||
429 | 273 | |||
430 | 274 | if (!reg) | ||
431 | 275 | return; | ||
432 | 276 | |||
433 | 277 | geis_unsubscribe (reg->instance, | ||
434 | 278 | (GeisGestureType*)reg->gesture_list->pdata); | ||
435 | 279 | |||
436 | 280 | /* We don't need to free the values in the GPtrArray. */ | ||
437 | 281 | g_ptr_array_free (reg->gesture_list, TRUE); | ||
438 | 282 | |||
439 | 283 | for (tmp = reg->bindings; tmp != NULL; tmp = tmp->next) | ||
440 | 284 | { | ||
441 | 285 | g_free (tmp->data); | ||
442 | 286 | } | ||
443 | 287 | |||
444 | 288 | g_list_free (reg->bindings); | ||
445 | 289 | } | ||
446 | 290 | |||
447 | 291 | /* Helper function needed to make things work with GTK. */ | ||
448 | 292 | |||
449 | 293 | static void | ||
450 | 294 | free_registration_adapter (gpointer key G_GNUC_UNUSED, | ||
451 | 295 | gpointer value, | ||
452 | 296 | gpointer user_data G_GNUC_UNUSED) | ||
453 | 297 | { | ||
454 | 298 | struct Registrations *regs = (struct Registrations *)value; | ||
455 | 299 | free_registration(regs->touchscreen); | ||
456 | 300 | free_registration(regs->touchpad); | ||
457 | 301 | free_registration(regs->independent); | ||
458 | 302 | } | ||
459 | 303 | |||
460 | 304 | static void | ||
461 | 305 | grip_gesture_manager_finalize (GObject *object) | 286 | grip_gesture_manager_finalize (GObject *object) |
462 | 306 | { | 287 | { |
463 | 307 | GripGestureManagerPrivate *priv = GRIP_GESTURE_MANAGER_GET_PRIVATE (object); | 288 | GripGestureManagerPrivate *priv = GRIP_GESTURE_MANAGER_GET_PRIVATE (object); |
464 | 308 | 289 | ||
477 | 309 | if (priv->registered_windows != NULL) | 290 | g_list_foreach(priv->classes, (GFunc) g_free, NULL); |
478 | 310 | { | 291 | g_list_free(priv->classes); |
479 | 311 | g_hash_table_foreach (priv->registered_windows, | 292 | |
480 | 312 | free_registration_adapter, | 293 | g_ptr_array_foreach (priv->devices, (GFunc) g_object_unref, NULL); |
481 | 313 | NULL); | 294 | g_ptr_array_unref (priv->devices); |
470 | 314 | |||
471 | 315 | g_hash_table_unref (priv->registered_windows); | ||
472 | 316 | priv->registered_windows = NULL; | ||
473 | 317 | |||
474 | 318 | g_ptr_array_foreach (priv->devices, (GFunc) g_object_unref, NULL); | ||
475 | 319 | g_ptr_array_unref (priv->devices); | ||
476 | 320 | } | ||
482 | 321 | } | 295 | } |
483 | 322 | 296 | ||
484 | 297 | |||
485 | 323 | static GObject * | 298 | static GObject * |
486 | 324 | grip_gesture_manager_constructor (GType type, | 299 | grip_gesture_manager_constructor (GType type, |
487 | 325 | guint n_params, | 300 | guint n_params, |
488 | @@ -332,12 +307,12 @@ | |||
489 | 332 | self = G_OBJECT_CLASS (grip_gesture_manager_parent_class)-> | 307 | self = G_OBJECT_CLASS (grip_gesture_manager_parent_class)-> |
490 | 333 | constructor (type, n_params, params); | 308 | constructor (type, n_params, params); |
491 | 334 | g_object_add_weak_pointer (self, (gpointer) &self); | 309 | g_object_add_weak_pointer (self, (gpointer) &self); |
492 | 335 | grip_get_devices (GRIP_GESTURE_MANAGER (self)); | ||
493 | 336 | } | 310 | } |
494 | 337 | 311 | ||
495 | 338 | return g_object_ref (self); | 312 | return g_object_ref (self); |
496 | 339 | } | 313 | } |
497 | 340 | 314 | ||
498 | 315 | |||
499 | 341 | static void | 316 | static void |
500 | 342 | grip_gesture_manager_class_init (GripGestureManagerClass *class) | 317 | grip_gesture_manager_class_init (GripGestureManagerClass *class) |
501 | 343 | { | 318 | { |
502 | @@ -386,7 +361,6 @@ | |||
503 | 386 | G_TYPE_NONE, | 361 | G_TYPE_NONE, |
504 | 387 | 1, | 362 | 1, |
505 | 388 | GRIP_TYPE_INPUT_DEVICE); | 363 | GRIP_TYPE_INPUT_DEVICE); |
506 | 389 | |||
507 | 390 | } | 364 | } |
508 | 391 | 365 | ||
509 | 392 | 366 | ||
510 | @@ -420,592 +394,306 @@ | |||
511 | 420 | return input_device; | 394 | return input_device; |
512 | 421 | } | 395 | } |
513 | 422 | 396 | ||
514 | 423 | /* | ||
515 | 424 | * registration_for_input_device: | ||
516 | 425 | * @registrations: A collection of #GripGestureRegistration | ||
517 | 426 | * @input_device: A pointer to a #GripInputDevice | ||
518 | 427 | * | ||
519 | 428 | * Determines which #GripGestureRegistration to use dependeng on properties of | ||
520 | 429 | * the #GripInputDevice. | ||
521 | 430 | * | ||
522 | 431 | * Returns: a pointer to a #GripGestureRegistration or %NULL if not found. | ||
523 | 432 | */ | ||
524 | 433 | static GripGestureRegistration * | ||
525 | 434 | registration_for_input_device (struct Registrations *registrations, | ||
526 | 435 | GripInputDevice *input_device) | ||
527 | 436 | { | ||
528 | 437 | GripDeviceType device_type = grip_get_device_type(input_device); | ||
529 | 438 | if (device_type == GRIP_DEVICE_TOUCHSCREEN) | ||
530 | 439 | { | ||
531 | 440 | return registrations->touchscreen; | ||
532 | 441 | } | ||
533 | 442 | else if (GRIP_DEVICE_TOUCHPAD) | ||
534 | 443 | { | ||
535 | 444 | return registrations->touchpad; | ||
536 | 445 | } | ||
537 | 446 | else if (GRIP_DEVICE_INDEPENDENT) | ||
538 | 447 | { | ||
539 | 448 | return registrations->independent; | ||
540 | 449 | } | ||
541 | 450 | return NULL; | ||
542 | 451 | } | ||
543 | 452 | |||
544 | 453 | 397 | ||
545 | 454 | static gint | 398 | static gint |
546 | 455 | pinch_gesture_handle_properties (GripEventGesturePinch *event, | 399 | pinch_gesture_handle_properties (GripEventGesturePinch *event, |
549 | 456 | GeisSize attr_count, | 400 | GeisFrame frame) |
548 | 457 | GeisGestureAttr *attrs) | ||
550 | 458 | { | 401 | { |
554 | 459 | guint i = 0; | 402 | guint attr_count = geis_frame_attr_count (frame); |
555 | 460 | gint touches = 0; | 403 | gint num_touches = 0; |
556 | 461 | 404 | guint i; | |
557 | 462 | for (i = 0; i < attr_count; ++i) | 405 | for (i = 0; i < attr_count; ++i) |
558 | 463 | { | 406 | { |
605 | 464 | if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_TOUCHES) == 0 && | 407 | GeisAttr attr = geis_frame_attr(frame, i); |
606 | 465 | attrs[i].type == GEIS_ATTR_TYPE_INTEGER) | 408 | GeisString attr_name = geis_attr_name(attr); |
561 | 466 | { | ||
562 | 467 | touches = attrs[i].integer_val; | ||
563 | 468 | } | ||
564 | 469 | if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_TIMESTAMP) == 0 && | ||
565 | 470 | attrs[i].type == GEIS_ATTR_TYPE_INTEGER) | ||
566 | 471 | { | ||
567 | 472 | event->timestamp = attrs[i].integer_val; | ||
568 | 473 | } | ||
569 | 474 | else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_FOCUS_X) == 0 && | ||
570 | 475 | attrs[i].type == GEIS_ATTR_TYPE_FLOAT) | ||
571 | 476 | { | ||
572 | 477 | event->focus_x = attrs[i].float_val; | ||
573 | 478 | } | ||
574 | 479 | else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_FOCUS_Y) == 0 && | ||
575 | 480 | attrs[i].type == GEIS_ATTR_TYPE_FLOAT) | ||
576 | 481 | { | ||
577 | 482 | event->focus_y = attrs[i].float_val; | ||
578 | 483 | } | ||
579 | 484 | else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_RADIUS_DELTA) == 0 && | ||
580 | 485 | attrs[i].type == GEIS_ATTR_TYPE_FLOAT) | ||
581 | 486 | { | ||
582 | 487 | event->radius_delta = attrs[i].float_val; | ||
583 | 488 | } | ||
584 | 489 | else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_RADIAL_VELOCITY) == 0 && | ||
585 | 490 | attrs[i].type == GEIS_ATTR_TYPE_FLOAT) | ||
586 | 491 | { | ||
587 | 492 | event->radial_velocity = attrs[i].float_val; | ||
588 | 493 | } | ||
589 | 494 | else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_RADIUS) == 0 && | ||
590 | 495 | attrs[i].type == GEIS_ATTR_TYPE_FLOAT) | ||
591 | 496 | { | ||
592 | 497 | event->radius = attrs[i].float_val; | ||
593 | 498 | } | ||
594 | 499 | else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_POSITION_X) == 0 && | ||
595 | 500 | attrs[i].type == GEIS_ATTR_TYPE_FLOAT) | ||
596 | 501 | { | ||
597 | 502 | event->position_x = attrs[i].float_val; | ||
598 | 503 | } | ||
599 | 504 | else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_POSITION_Y) == 0 && | ||
600 | 505 | attrs[i].type == GEIS_ATTR_TYPE_FLOAT) | ||
601 | 506 | { | ||
602 | 507 | event->position_y = attrs[i].float_val; | ||
603 | 508 | } | ||
604 | 509 | } | ||
607 | 510 | 409 | ||
609 | 511 | return touches; | 410 | if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_TOUCHES) == 0) |
610 | 411 | num_touches = geis_attr_value_to_integer(attr); | ||
611 | 412 | if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_TIMESTAMP) == 0) | ||
612 | 413 | event->timestamp = geis_attr_value_to_integer(attr); | ||
613 | 414 | else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_FOCUS_X) == 0) | ||
614 | 415 | event->focus_x = geis_attr_value_to_float(attr); | ||
615 | 416 | else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_FOCUS_Y) == 0) | ||
616 | 417 | event->focus_y = geis_attr_value_to_float(attr); | ||
617 | 418 | else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_RADIUS_DELTA) == 0) | ||
618 | 419 | event->radius_delta = geis_attr_value_to_float(attr); | ||
619 | 420 | else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_RADIAL_VELOCITY) == 0) | ||
620 | 421 | event->radial_velocity = geis_attr_value_to_float(attr); | ||
621 | 422 | else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_RADIUS) == 0) | ||
622 | 423 | event->radius = geis_attr_value_to_float(attr); | ||
623 | 424 | else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_POSITION_X) == 0) | ||
624 | 425 | event->position_x = geis_attr_value_to_float(attr); | ||
625 | 426 | else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_POSITION_Y) == 0) | ||
626 | 427 | event->position_y = geis_attr_value_to_float(attr); | ||
627 | 428 | } | ||
628 | 429 | return num_touches; | ||
629 | 512 | } | 430 | } |
630 | 513 | 431 | ||
631 | 514 | static gint | 432 | static gint |
632 | 515 | drag_gesture_handle_properties (GripEventGestureDrag *event, | 433 | drag_gesture_handle_properties (GripEventGestureDrag *event, |
635 | 516 | GeisSize attr_count, | 434 | GeisFrame frame) |
634 | 517 | GeisGestureAttr *attrs) | ||
636 | 518 | { | 435 | { |
637 | 436 | guint attr_count = geis_frame_attr_count (frame); | ||
638 | 437 | gint num_touches = 0; | ||
639 | 519 | guint i; | 438 | guint i; |
640 | 520 | gint touches = 0; | ||
641 | 521 | |||
642 | 522 | for (i = 0; i < attr_count; ++i) | 439 | for (i = 0; i < attr_count; ++i) |
643 | 523 | { | 440 | { |
695 | 524 | if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_TOUCHES) == 0 && | 441 | GeisAttr attr = geis_frame_attr(frame, i); |
696 | 525 | attrs[i].type == GEIS_ATTR_TYPE_INTEGER) | 442 | GeisString attr_name = geis_attr_name(attr); |
646 | 526 | { | ||
647 | 527 | touches = attrs[i].integer_val; | ||
648 | 528 | } | ||
649 | 529 | if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_TIMESTAMP) == 0 && | ||
650 | 530 | attrs[i].type == GEIS_ATTR_TYPE_INTEGER) | ||
651 | 531 | { | ||
652 | 532 | event->timestamp = attrs[i].integer_val; | ||
653 | 533 | } | ||
654 | 534 | else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_FOCUS_X) == 0 && | ||
655 | 535 | attrs[i].type == GEIS_ATTR_TYPE_FLOAT) | ||
656 | 536 | { | ||
657 | 537 | event->focus_x = attrs[i].float_val; | ||
658 | 538 | } | ||
659 | 539 | else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_FOCUS_Y) == 0 && | ||
660 | 540 | attrs[i].type == GEIS_ATTR_TYPE_FLOAT) | ||
661 | 541 | { | ||
662 | 542 | event->focus_y = attrs[i].float_val; | ||
663 | 543 | } | ||
664 | 544 | else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_DELTA_X) == 0 && | ||
665 | 545 | attrs[i].type == GEIS_ATTR_TYPE_FLOAT) | ||
666 | 546 | { | ||
667 | 547 | event->delta_x = attrs[i].float_val; | ||
668 | 548 | } | ||
669 | 549 | else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_DELTA_Y) == 0 && | ||
670 | 550 | attrs[i].type == GEIS_ATTR_TYPE_FLOAT) | ||
671 | 551 | { | ||
672 | 552 | event->delta_y = attrs[i].float_val; | ||
673 | 553 | } | ||
674 | 554 | else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_VELOCITY_X) == 0 && | ||
675 | 555 | attrs[i].type == GEIS_ATTR_TYPE_FLOAT) | ||
676 | 556 | { | ||
677 | 557 | event->velocity_x = attrs[i].float_val; | ||
678 | 558 | } | ||
679 | 559 | else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_VELOCITY_Y) == 0 && | ||
680 | 560 | attrs[i].type == GEIS_ATTR_TYPE_FLOAT) | ||
681 | 561 | { | ||
682 | 562 | event->velocity_y = attrs[i].float_val; | ||
683 | 563 | } | ||
684 | 564 | else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_POSITION_X) == 0 && | ||
685 | 565 | attrs[i].type == GEIS_ATTR_TYPE_FLOAT) | ||
686 | 566 | { | ||
687 | 567 | event->position_x = attrs[i].float_val; | ||
688 | 568 | } | ||
689 | 569 | else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_POSITION_Y) == 0 && | ||
690 | 570 | attrs[i].type == GEIS_ATTR_TYPE_FLOAT) | ||
691 | 571 | { | ||
692 | 572 | event->position_y = attrs[i].float_val; | ||
693 | 573 | } | ||
694 | 574 | } | ||
697 | 575 | 443 | ||
699 | 576 | return touches; | 444 | if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_TOUCHES) == 0) |
700 | 445 | num_touches = geis_attr_value_to_integer(attr); | ||
701 | 446 | if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_TIMESTAMP) == 0) | ||
702 | 447 | event->timestamp = geis_attr_value_to_integer(attr); | ||
703 | 448 | else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_FOCUS_X) == 0) | ||
704 | 449 | event->focus_x = geis_attr_value_to_float(attr); | ||
705 | 450 | else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_FOCUS_Y) == 0) | ||
706 | 451 | event->focus_y = geis_attr_value_to_float(attr); | ||
707 | 452 | else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_DELTA_X) == 0) | ||
708 | 453 | event->delta_x = geis_attr_value_to_float(attr); | ||
709 | 454 | else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_DELTA_Y) == 0) | ||
710 | 455 | event->delta_y = geis_attr_value_to_float(attr); | ||
711 | 456 | else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_VELOCITY_X) == 0) | ||
712 | 457 | event->velocity_x = geis_attr_value_to_float(attr); | ||
713 | 458 | else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_VELOCITY_Y) == 0) | ||
714 | 459 | event->velocity_y = geis_attr_value_to_float(attr); | ||
715 | 460 | else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_POSITION_X) == 0) | ||
716 | 461 | event->position_x = geis_attr_value_to_float(attr); | ||
717 | 462 | else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_POSITION_Y) == 0) | ||
718 | 463 | event->position_y = geis_attr_value_to_float(attr); | ||
719 | 464 | } | ||
720 | 465 | return num_touches; | ||
721 | 577 | } | 466 | } |
722 | 578 | 467 | ||
723 | 468 | |||
724 | 579 | static gint | 469 | static gint |
725 | 580 | rotate_gesture_handle_properties (GripEventGestureRotate *event, | 470 | rotate_gesture_handle_properties (GripEventGestureRotate *event, |
728 | 581 | GeisSize attr_count, | 471 | GeisFrame frame) |
727 | 582 | GeisGestureAttr *attrs) | ||
729 | 583 | { | 472 | { |
730 | 473 | guint attr_count = geis_frame_attr_count (frame); | ||
731 | 474 | gint num_touches = 0; | ||
732 | 584 | guint i; | 475 | guint i; |
733 | 585 | gint touches = 0; | ||
734 | 586 | |||
735 | 587 | for (i = 0; i < attr_count; ++i) | 476 | for (i = 0; i < attr_count; ++i) |
736 | 588 | { | 477 | { |
783 | 589 | if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_TOUCHES) == 0 && | 478 | GeisAttr attr = geis_frame_attr(frame, i); |
784 | 590 | attrs[i].type == GEIS_ATTR_TYPE_INTEGER) | 479 | GeisString attr_name = geis_attr_name(attr); |
739 | 591 | { | ||
740 | 592 | touches = attrs[i].integer_val; | ||
741 | 593 | } | ||
742 | 594 | if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_TIMESTAMP) == 0 && | ||
743 | 595 | attrs[i].type == GEIS_ATTR_TYPE_INTEGER) | ||
744 | 596 | { | ||
745 | 597 | event->timestamp = attrs[i].integer_val; | ||
746 | 598 | } | ||
747 | 599 | else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_FOCUS_X) == 0 && | ||
748 | 600 | attrs[i].type == GEIS_ATTR_TYPE_FLOAT) | ||
749 | 601 | { | ||
750 | 602 | event->focus_x = attrs[i].float_val; | ||
751 | 603 | } | ||
752 | 604 | else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_FOCUS_Y) == 0 && | ||
753 | 605 | attrs[i].type == GEIS_ATTR_TYPE_FLOAT) | ||
754 | 606 | { | ||
755 | 607 | event->focus_y = attrs[i].float_val; | ||
756 | 608 | } | ||
757 | 609 | else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_ANGLE_DELTA) == 0 && | ||
758 | 610 | attrs[i].type == GEIS_ATTR_TYPE_FLOAT) | ||
759 | 611 | { | ||
760 | 612 | event->angle_delta = attrs[i].float_val; | ||
761 | 613 | } | ||
762 | 614 | else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_ANGULAR_VELOCITY) == 0 && | ||
763 | 615 | attrs[i].type == GEIS_ATTR_TYPE_FLOAT) | ||
764 | 616 | { | ||
765 | 617 | event->angular_velocity = attrs[i].float_val; | ||
766 | 618 | } | ||
767 | 619 | else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_ANGLE) == 0 && | ||
768 | 620 | attrs[i].type == GEIS_ATTR_TYPE_FLOAT) | ||
769 | 621 | { | ||
770 | 622 | event->angle = attrs[i].float_val; | ||
771 | 623 | } | ||
772 | 624 | else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_POSITION_X) == 0 && | ||
773 | 625 | attrs[i].type == GEIS_ATTR_TYPE_FLOAT) | ||
774 | 626 | { | ||
775 | 627 | event->position_x = attrs[i].float_val; | ||
776 | 628 | } | ||
777 | 629 | else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_POSITION_Y) == 0 && | ||
778 | 630 | attrs[i].type == GEIS_ATTR_TYPE_FLOAT) | ||
779 | 631 | { | ||
780 | 632 | event->position_y = attrs[i].float_val; | ||
781 | 633 | } | ||
782 | 634 | } | ||
785 | 635 | 480 | ||
787 | 636 | return touches; | 481 | if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_TOUCHES) == 0) |
788 | 482 | num_touches = geis_attr_value_to_integer(attr); | ||
789 | 483 | if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_TIMESTAMP) == 0) | ||
790 | 484 | event->timestamp = geis_attr_value_to_integer(attr); | ||
791 | 485 | else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_FOCUS_X) == 0) | ||
792 | 486 | event->focus_x = geis_attr_value_to_float(attr); | ||
793 | 487 | else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_FOCUS_Y) == 0) | ||
794 | 488 | event->focus_y = geis_attr_value_to_float(attr); | ||
795 | 489 | else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_ANGLE_DELTA) == 0) | ||
796 | 490 | event->angle_delta = geis_attr_value_to_float(attr); | ||
797 | 491 | else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_ANGULAR_VELOCITY) == 0) | ||
798 | 492 | event->angular_velocity = geis_attr_value_to_float(attr); | ||
799 | 493 | else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_ANGLE) == 0) | ||
800 | 494 | event->angle = geis_attr_value_to_float(attr); | ||
801 | 495 | else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_POSITION_X) == 0) | ||
802 | 496 | event->position_x = geis_attr_value_to_float(attr); | ||
803 | 497 | else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_POSITION_Y) == 0) | ||
804 | 498 | event->position_y = geis_attr_value_to_float(attr); | ||
805 | 499 | } | ||
806 | 500 | return num_touches; | ||
807 | 637 | } | 501 | } |
808 | 638 | 502 | ||
809 | 503 | |||
810 | 639 | static gint | 504 | static gint |
811 | 640 | tap_gesture_handle_properties (GripEventGestureTap *event, | 505 | tap_gesture_handle_properties (GripEventGestureTap *event, |
814 | 641 | GeisSize attr_count, | 506 | GeisFrame frame) |
813 | 642 | GeisGestureAttr *attrs) | ||
815 | 643 | { | 507 | { |
816 | 508 | guint attr_count = geis_frame_attr_count (frame); | ||
817 | 509 | gint num_touches = 0; | ||
818 | 644 | guint i; | 510 | guint i; |
819 | 645 | gint touches = 0; | ||
820 | 646 | |||
821 | 647 | for (i = 0; i < attr_count; ++i) | 511 | for (i = 0; i < attr_count; ++i) |
822 | 648 | { | 512 | { |
922 | 649 | if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_TOUCHES) == 0 && | 513 | GeisAttr attr = geis_frame_attr(frame, i); |
923 | 650 | attrs[i].type == GEIS_ATTR_TYPE_INTEGER) | 514 | GeisString attr_name = geis_attr_name(attr); |
924 | 651 | { | 515 | |
925 | 652 | touches = attrs[i].integer_val; | 516 | if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_TOUCHES) == 0) |
926 | 653 | } | 517 | num_touches = geis_attr_value_to_integer(attr); |
927 | 654 | else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_TIMESTAMP) == 0 && | 518 | if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_TIMESTAMP) == 0) |
928 | 655 | attrs[i].type == GEIS_ATTR_TYPE_INTEGER) | 519 | event->timestamp = geis_attr_value_to_integer(attr); |
929 | 656 | { | 520 | else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_FOCUS_X) == 0) |
930 | 657 | event->timestamp = attrs[i].integer_val; | 521 | event->focus_x = geis_attr_value_to_float(attr); |
931 | 658 | } | 522 | else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_FOCUS_Y) == 0) |
932 | 659 | else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_FOCUS_X) == 0 && | 523 | event->focus_y = geis_attr_value_to_float(attr); |
933 | 660 | attrs[i].type == GEIS_ATTR_TYPE_FLOAT) | 524 | else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_POSITION_X) == 0) |
934 | 661 | { | 525 | event->position_x = geis_attr_value_to_float(attr); |
935 | 662 | event->focus_x = attrs[i].float_val; | 526 | else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_POSITION_Y) == 0) |
936 | 663 | } | 527 | event->position_y = geis_attr_value_to_float(attr); |
937 | 664 | else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_FOCUS_Y) == 0 && | 528 | else if (g_strcmp0 (attr_name, GEIS_GESTURE_ATTRIBUTE_TAP_TIME) == 0) |
938 | 665 | attrs[i].type == GEIS_ATTR_TYPE_FLOAT) | 529 | event->tap_time = geis_attr_value_to_float(attr); |
939 | 666 | { | 530 | } |
940 | 667 | event->focus_y = attrs[i].float_val; | 531 | return num_touches; |
941 | 668 | } | 532 | } |
942 | 669 | else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_POSITION_X) == 0 && | 533 | |
943 | 670 | attrs[i].type == GEIS_ATTR_TYPE_FLOAT) | 534 | |
944 | 671 | { | 535 | static void |
945 | 672 | event->position_x = attrs[i].float_val; | 536 | process_gesture_events(GripGestureManager *manager, GeisEvent geis_event) |
946 | 673 | } | 537 | { |
947 | 674 | else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_POSITION_Y) == 0 && | 538 | GripGestureManagerPrivate *priv = manager->priv; |
948 | 675 | attrs[i].type == GEIS_ATTR_TYPE_FLOAT) | 539 | |
949 | 676 | { | 540 | GripTimeType time_type = GRIP_TIME_UPDATE; |
950 | 677 | event->position_y = attrs[i].float_val; | 541 | if (geis_event_type(geis_event) == GEIS_EVENT_GESTURE_BEGIN) |
951 | 678 | } | 542 | time_type = GRIP_TIME_START; |
952 | 679 | else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_TAP_TIME) == 0 && | 543 | else if (geis_event_type(geis_event) == GEIS_EVENT_GESTURE_END) |
953 | 680 | attrs[i].type == GEIS_ATTR_TYPE_INTEGER) | 544 | time_type = GRIP_TIME_END; |
954 | 681 | { | 545 | |
955 | 682 | event->tap_time = attrs[i].float_val; | 546 | GeisAttr attr = geis_event_attr_by_name (geis_event, GEIS_EVENT_ATTRIBUTE_GROUPSET); |
956 | 683 | } | 547 | g_return_if_fail (attr); |
957 | 684 | } | 548 | |
958 | 685 | 549 | GeisGroupSet groupset = geis_attr_value_to_pointer (attr); | |
959 | 686 | return touches; | 550 | g_return_if_fail (groupset); |
960 | 687 | } | 551 | |
862 | 688 | |||
863 | 689 | static void | ||
864 | 690 | gesture_added (void *cookie G_GNUC_UNUSED, | ||
865 | 691 | GeisGestureType gesture_type G_GNUC_UNUSED, | ||
866 | 692 | GeisGestureId gesture_id G_GNUC_UNUSED, | ||
867 | 693 | GeisSize attr_count G_GNUC_UNUSED, | ||
868 | 694 | GeisGestureAttr *attrs G_GNUC_UNUSED) | ||
869 | 695 | { | ||
870 | 696 | } | ||
871 | 697 | |||
872 | 698 | static void | ||
873 | 699 | gesture_removed (void *cookie G_GNUC_UNUSED, | ||
874 | 700 | GeisGestureType gesture_type G_GNUC_UNUSED, | ||
875 | 701 | GeisGestureId gesture_id G_GNUC_UNUSED, | ||
876 | 702 | GeisSize attr_count G_GNUC_UNUSED, | ||
877 | 703 | GeisGestureAttr *attrs G_GNUC_UNUSED) | ||
878 | 704 | { | ||
879 | 705 | } | ||
880 | 706 | |||
881 | 707 | static gboolean | ||
882 | 708 | matches_widget (GtkWidget *widget, | ||
883 | 709 | GdkWindow *window, | ||
884 | 710 | gint x, | ||
885 | 711 | gint y) | ||
886 | 712 | { | ||
887 | 713 | GtkAllocation alloc; | ||
888 | 714 | gint ax, ay; | ||
889 | 715 | |||
890 | 716 | gtk_widget_get_allocation (widget, &alloc); | ||
891 | 717 | gdk_window_get_root_coords (window, alloc.x, alloc.y, &ax, &ay); | ||
892 | 718 | |||
893 | 719 | return (x >= ax && x < ax + alloc.width && y >= ay && y < ay + alloc.height); | ||
894 | 720 | } | ||
895 | 721 | |||
896 | 722 | |||
897 | 723 | /* | ||
898 | 724 | * process_gesture: | ||
899 | 725 | * @cookie: | ||
900 | 726 | * @type: | ||
901 | 727 | * @id: | ||
902 | 728 | * @attr_count: | ||
903 | 729 | * @attrs: | ||
904 | 730 | * @time_type: | ||
905 | 731 | * | ||
906 | 732 | * The generic gesture event dispatch engine. | ||
907 | 733 | */ | ||
908 | 734 | static void | ||
909 | 735 | process_gesture (void *cookie, | ||
910 | 736 | GeisGestureType type, | ||
911 | 737 | GeisGestureId id, | ||
912 | 738 | GeisSize attr_count, | ||
913 | 739 | GeisGestureAttr *attrs, | ||
914 | 740 | GripTimeType time_type) | ||
915 | 741 | { | ||
916 | 742 | GripGestureManager *manager = (GripGestureManager *) cookie; | ||
917 | 743 | GripInputDevice *input_device = NULL; | ||
918 | 744 | GtkWindow *gtk_window = NULL; | ||
919 | 745 | struct Registrations *registrations = NULL; | ||
920 | 746 | GripGestureRegistration *reg = NULL; | ||
921 | 747 | GList *l = NULL; | ||
961 | 748 | GeisSize i; | 552 | GeisSize i; |
1148 | 749 | 553 | for (i = 0; i < geis_groupset_group_count (groupset); ++i) | |
1149 | 750 | for (i = 0; i < attr_count; ++i) | 554 | { |
1150 | 751 | { | 555 | GeisGroup group = geis_groupset_group (groupset, i); |
1151 | 752 | if (0 == g_strcmp0(attrs[i].name, GEIS_GESTURE_ATTRIBUTE_DEVICE_ID)) | 556 | g_return_if_fail (group); |
1152 | 753 | { | 557 | |
1153 | 754 | input_device = device_id_to_input_device(manager, attrs[i].integer_val); | 558 | GeisSize j; |
1154 | 755 | } | 559 | for (j = 0; j < geis_group_frame_count (group); ++j) |
1155 | 756 | else if (0 == g_strcmp0(attrs[i].name, GEIS_GESTURE_ATTRIBUTE_EVENT_WINDOW_ID)) | 560 | { |
1156 | 757 | { | 561 | GeisFrame frame = geis_group_frame(group, j); |
1157 | 758 | GHashTableIter iter; | 562 | g_return_if_fail (frame); |
1158 | 759 | GtkWidget *key; | 563 | |
1159 | 760 | struct Registrations *value; | 564 | GeisAttr window_attr = geis_frame_attr_by_name(frame, GEIS_GESTURE_ATTRIBUTE_EVENT_WINDOW_ID); |
1160 | 761 | guint window_id = attrs[i].integer_val; | 565 | guint window_id = geis_attr_value_to_integer(window_attr); |
1161 | 762 | 566 | ||
1162 | 763 | g_hash_table_iter_init (&iter, manager->priv->registered_windows); | 567 | GeisAttr device_attr = geis_frame_attr_by_name(frame, GEIS_GESTURE_ATTRIBUTE_DEVICE_ID); |
1163 | 764 | while (g_hash_table_iter_next(&iter, (gpointer *)&key, (gpointer *)&value)) | 568 | guint device_id = geis_attr_value_to_integer(device_attr); |
1164 | 765 | { | 569 | GripInputDevice *input_device = device_id_to_input_device (manager, device_id); |
1165 | 766 | if (GDK_WINDOW_XID (gtk_widget_get_window (key)) == window_id) | 570 | |
1166 | 767 | { | 571 | GList *l; |
1167 | 768 | gtk_window = (GtkWindow *)key; | 572 | for (l = priv->bindings; l != NULL; l = l->next) |
1168 | 769 | break; | 573 | { |
1169 | 770 | } | 574 | GripGestureBinding *binding = (GripGestureBinding *)l->data; |
1170 | 771 | } | 575 | guint widget_window_id = GDK_WINDOW_XID (gtk_widget_get_window (binding->widget)); |
1171 | 772 | } | 576 | if (widget_window_id == window_id) |
1172 | 773 | } | 577 | { |
1173 | 774 | g_return_if_fail(input_device != NULL); | 578 | GList *class_list; |
1174 | 775 | g_return_if_fail(gtk_window != NULL); | 579 | for (class_list = priv->classes; class_list != NULL; class_list = class_list->next) |
1175 | 776 | 580 | { | |
1176 | 777 | registrations = g_hash_table_lookup (manager->priv->registered_windows, gtk_window); | 581 | GripGestureClassMap *p = (GripGestureClassMap *)class_list->data; |
1177 | 778 | g_return_if_fail(registrations != NULL); | 582 | if (p->grip_type == binding->type) |
1178 | 779 | reg = registration_for_input_device (registrations, input_device); | 583 | { |
1179 | 780 | g_return_if_fail(reg != NULL); | 584 | if (geis_frame_is_class(frame, p->geis_class)) |
1180 | 781 | 585 | { | |
1181 | 782 | for (l = reg->bindings; l != NULL; l = l->next) | 586 | GripGestureEvent *grip_event = grip_gesture_event_new (p->grip_type); |
1182 | 783 | { | 587 | if (p->grip_type == GRIP_GESTURE_DRAG) |
1183 | 784 | GripGestureBinding *binding = (GripGestureBinding *)l->data; | 588 | { |
1184 | 785 | 589 | GripEventGestureDrag *drag = (GripEventGestureDrag *)grip_event; | |
1185 | 786 | if (binding->type == type) | 590 | drag->type = p->grip_type; |
1186 | 787 | { | 591 | drag->id = geis_frame_id(frame); |
1187 | 788 | GripGestureEvent *event = grip_gesture_event_new (type); | 592 | drag->input_device = input_device; |
1188 | 789 | 593 | drag->fingers = drag_gesture_handle_properties (drag, frame); | |
1189 | 790 | if (type == GRIP_GESTURE_DRAG) | 594 | binding->callback (binding->widget, |
1190 | 791 | { | 595 | time_type, |
1191 | 792 | GripEventGestureDrag *drag = (GripEventGestureDrag *)event; | 596 | grip_event, |
1192 | 793 | 597 | binding->data); | |
1193 | 794 | drag->type = type; | 598 | } |
1194 | 795 | drag->id = id; | 599 | else if (p->grip_type == GRIP_GESTURE_PINCH) |
1195 | 796 | drag->input_device = input_device; | 600 | { |
1196 | 797 | drag->fingers = drag_gesture_handle_properties (drag, | 601 | GripEventGesturePinch *pinch = (GripEventGesturePinch *)grip_event; |
1197 | 798 | attr_count, | 602 | pinch->type = p->grip_type; |
1198 | 799 | attrs); | 603 | pinch->id = geis_frame_id(frame); |
1199 | 800 | 604 | pinch->input_device = input_device; | |
1200 | 801 | if (drag->fingers == (gint)binding->touches) | 605 | pinch->fingers = pinch_gesture_handle_properties (pinch, frame); |
1201 | 802 | { | 606 | binding->callback (binding->widget, |
1202 | 803 | if (matches_widget (binding->widget, | 607 | time_type, |
1203 | 804 | gtk_widget_get_window(GTK_WIDGET (reg->window)), | 608 | grip_event, |
1204 | 805 | (gint)drag->focus_x, | 609 | binding->data); |
1205 | 806 | (gint)drag->focus_y)) | 610 | } |
1206 | 807 | { | 611 | else if (p->grip_type == GRIP_GESTURE_ROTATE) |
1207 | 808 | binding->callback (binding->widget, | 612 | { |
1208 | 809 | time_type, | 613 | GripEventGestureRotate *rotate = (GripEventGestureRotate *)grip_event; |
1209 | 810 | event, | 614 | rotate->type = p->grip_type; |
1210 | 811 | binding->data); | 615 | rotate->id = geis_frame_id(frame); |
1211 | 812 | } | 616 | rotate->input_device = input_device; |
1212 | 813 | } | 617 | rotate->fingers = rotate_gesture_handle_properties (rotate, frame); |
1213 | 814 | } | 618 | binding->callback (binding->widget, |
1214 | 815 | else if (type == GRIP_GESTURE_PINCH) | 619 | time_type, |
1215 | 816 | { | 620 | grip_event, |
1216 | 817 | GripEventGesturePinch *pinch = (GripEventGesturePinch *)event; | 621 | binding->data); |
1217 | 818 | 622 | } | |
1218 | 819 | pinch->type = type; | 623 | else if (p->grip_type == GRIP_GESTURE_TAP) |
1219 | 820 | pinch->id = id; | 624 | { |
1220 | 821 | pinch->input_device = input_device; | 625 | GripEventGestureTap *tap = (GripEventGestureTap *)grip_event; |
1221 | 822 | pinch->fingers = pinch_gesture_handle_properties (pinch, | 626 | tap->type = p->grip_type; |
1222 | 823 | attr_count, | 627 | tap->id = geis_frame_id(frame); |
1223 | 824 | attrs); | 628 | tap->input_device = input_device; |
1224 | 825 | 629 | tap->fingers = tap_gesture_handle_properties (tap, frame); | |
1225 | 826 | if (pinch->fingers == binding->touches) | 630 | binding->callback (binding->widget, |
1226 | 827 | { | 631 | time_type, |
1227 | 828 | if (matches_widget (binding->widget, | 632 | grip_event, |
1228 | 829 | gtk_widget_get_window(GTK_WIDGET (reg->window)), | 633 | binding->data); |
1229 | 830 | (gint)pinch->focus_x, | 634 | } |
1230 | 831 | (gint)pinch->focus_y)) | 635 | grip_gesture_event_free (grip_event); |
1231 | 832 | { | 636 | } |
1232 | 833 | binding->callback (binding->widget, | 637 | } |
1233 | 834 | time_type, | 638 | } |
1234 | 835 | event, | 639 | } |
1235 | 836 | binding->data); | 640 | } |
1236 | 837 | } | 641 | } |
1237 | 838 | } | 642 | } |
1238 | 839 | } | 643 | } |
1239 | 840 | else if (type == GRIP_GESTURE_ROTATE) | 644 | |
1240 | 841 | { | 645 | |
1241 | 842 | GripEventGestureRotate *rotate = (GripEventGestureRotate *)event; | 646 | static gboolean |
1242 | 843 | 647 | grip_geis_event_ready (GIOChannel *source G_GNUC_UNUSED, | |
1243 | 844 | rotate->type = type; | 648 | GIOCondition condition G_GNUC_UNUSED, |
1244 | 845 | rotate->id = id; | 649 | gpointer context) |
1245 | 846 | rotate->input_device = input_device; | 650 | { |
1246 | 847 | rotate->fingers = rotate_gesture_handle_properties (rotate, | 651 | Geis geis = (Geis)context; |
1247 | 848 | attr_count, | 652 | GeisStatus status G_GNUC_UNUSED = geis_dispatch_events(geis); |
1248 | 849 | attrs); | 653 | return TRUE; |
1249 | 850 | 654 | } | |
1250 | 851 | if (rotate->fingers == binding->touches) | 655 | |
1251 | 852 | { | 656 | |
1252 | 853 | if (matches_widget (binding->widget, | 657 | static void |
1253 | 854 | gtk_widget_get_window(GTK_WIDGET (reg->window)), | 658 | grip_gesture_manager_init (GripGestureManager *self) |
1254 | 855 | (gint)rotate->focus_x, | 659 | { |
1255 | 856 | (gint)rotate->focus_y)) | 660 | GripGestureManagerPrivate *priv = self->priv = GRIP_GESTURE_MANAGER_GET_PRIVATE (self); |
1070 | 857 | { | ||
1071 | 858 | binding->callback (binding->widget, | ||
1072 | 859 | time_type, | ||
1073 | 860 | event, | ||
1074 | 861 | binding->data); | ||
1075 | 862 | } | ||
1076 | 863 | } | ||
1077 | 864 | } | ||
1078 | 865 | else if (type == GRIP_GESTURE_TAP) | ||
1079 | 866 | { | ||
1080 | 867 | GripEventGestureTap *tap = (GripEventGestureTap *)event; | ||
1081 | 868 | |||
1082 | 869 | tap->type = type; | ||
1083 | 870 | tap->id = id; | ||
1084 | 871 | tap->input_device = input_device; | ||
1085 | 872 | tap->fingers = tap_gesture_handle_properties (tap, | ||
1086 | 873 | attr_count, | ||
1087 | 874 | attrs); | ||
1088 | 875 | |||
1089 | 876 | if (tap->fingers == binding->touches) | ||
1090 | 877 | { | ||
1091 | 878 | if (matches_widget (binding->widget, | ||
1092 | 879 | gtk_widget_get_window(GTK_WIDGET (reg->window)), | ||
1093 | 880 | (gint)tap->focus_x, | ||
1094 | 881 | (gint)tap->focus_y)) | ||
1095 | 882 | { | ||
1096 | 883 | binding->callback (binding->widget, | ||
1097 | 884 | time_type, | ||
1098 | 885 | event, | ||
1099 | 886 | binding->data); | ||
1100 | 887 | } | ||
1101 | 888 | } | ||
1102 | 889 | } | ||
1103 | 890 | |||
1104 | 891 | grip_gesture_event_free (event); | ||
1105 | 892 | } | ||
1106 | 893 | } | ||
1107 | 894 | } | ||
1108 | 895 | |||
1109 | 896 | static void | ||
1110 | 897 | gesture_start (void *cookie, | ||
1111 | 898 | GeisGestureType type, | ||
1112 | 899 | GeisGestureId id, | ||
1113 | 900 | GeisSize attr_count, | ||
1114 | 901 | GeisGestureAttr *attrs) | ||
1115 | 902 | { | ||
1116 | 903 | process_gesture(cookie, type, id, attr_count, attrs, GRIP_TIME_START); | ||
1117 | 904 | } | ||
1118 | 905 | |||
1119 | 906 | static void | ||
1120 | 907 | gesture_update (void *cookie, | ||
1121 | 908 | GeisGestureType type, | ||
1122 | 909 | GeisGestureId id, | ||
1123 | 910 | GeisSize attr_count, | ||
1124 | 911 | GeisGestureAttr *attrs) | ||
1125 | 912 | { | ||
1126 | 913 | process_gesture(cookie, type, id, attr_count, attrs, GRIP_TIME_UPDATE); | ||
1127 | 914 | } | ||
1128 | 915 | |||
1129 | 916 | static void | ||
1130 | 917 | gesture_finish (void *cookie, | ||
1131 | 918 | GeisGestureType type, | ||
1132 | 919 | GeisGestureId id, | ||
1133 | 920 | GeisSize attr_count, | ||
1134 | 921 | GeisGestureAttr *attrs) | ||
1135 | 922 | { | ||
1136 | 923 | process_gesture(cookie, type, id, attr_count, attrs, GRIP_TIME_END); | ||
1137 | 924 | } | ||
1138 | 925 | |||
1139 | 926 | static void | ||
1140 | 927 | grip_gesture_manager_init (GripGestureManager *item) | ||
1141 | 928 | { | ||
1142 | 929 | GripGestureManagerPrivate *priv; | ||
1143 | 930 | |||
1144 | 931 | priv = item->priv = GRIP_GESTURE_MANAGER_GET_PRIVATE (item); | ||
1145 | 932 | |||
1146 | 933 | priv->registered_windows = g_hash_table_new (g_direct_hash, g_direct_equal); | ||
1147 | 934 | |||
1256 | 935 | priv->devices = g_ptr_array_new (); | 661 | priv->devices = g_ptr_array_new (); |
1301 | 936 | } | 662 | |
1302 | 937 | 663 | priv->geis = geis_new (GEIS_INIT_TRACK_DEVICES, GEIS_INIT_TRACK_GESTURE_CLASSES, NULL); | |
1303 | 938 | static gboolean | 664 | g_return_if_fail (priv->geis); |
1304 | 939 | io_callback (GIOChannel *source G_GNUC_UNUSED, | 665 | |
1305 | 940 | GIOCondition condition G_GNUC_UNUSED, | 666 | int fd; |
1306 | 941 | gpointer data) | 667 | geis_get_configuration(priv->geis, GEIS_CONFIGURATION_FD, &fd); |
1307 | 942 | { | 668 | priv->iochannel = g_io_channel_unix_new (fd); |
1308 | 943 | GripGestureRegistration *reg = (GripGestureRegistration *)data; | 669 | priv->iochannel_id = g_io_add_watch (priv->iochannel, G_IO_IN, grip_geis_event_ready, priv->geis); |
1309 | 944 | 670 | geis_register_device_callback (priv->geis, grip_geis_event_callback, self); | |
1310 | 945 | geis_event_dispatch (reg->instance); | 671 | geis_register_class_callback (priv->geis, grip_geis_event_callback, self); |
1311 | 946 | 672 | geis_register_event_callback (priv->geis, grip_geis_event_callback, self); | |
1312 | 947 | return TRUE; | 673 | } |
1313 | 948 | } | 674 | |
1270 | 949 | |||
1271 | 950 | static void | ||
1272 | 951 | destroy_registration(GripGestureRegistration *reg) | ||
1273 | 952 | { | ||
1274 | 953 | GList *list; | ||
1275 | 954 | |||
1276 | 955 | for (list = reg->bindings; list != NULL; list = list->next) | ||
1277 | 956 | { | ||
1278 | 957 | GripGestureBinding *binding = (GripGestureBinding *)list->data; | ||
1279 | 958 | |||
1280 | 959 | if (binding->destroy) | ||
1281 | 960 | { | ||
1282 | 961 | GDestroyNotify d = binding->destroy; | ||
1283 | 962 | |||
1284 | 963 | d (binding->data); | ||
1285 | 964 | } | ||
1286 | 965 | |||
1287 | 966 | g_free (binding); | ||
1288 | 967 | } | ||
1289 | 968 | |||
1290 | 969 | g_list_free (reg->bindings); | ||
1291 | 970 | |||
1292 | 971 | g_io_channel_shutdown (reg->iochannel, FALSE, NULL); | ||
1293 | 972 | g_source_remove (reg->iochannel_id); | ||
1294 | 973 | g_io_channel_unref (reg->iochannel); | ||
1295 | 974 | |||
1296 | 975 | geis_finish (reg->instance); | ||
1297 | 976 | |||
1298 | 977 | reg->instance = NULL; | ||
1299 | 978 | reg->iochannel = NULL; | ||
1300 | 979 | } | ||
1314 | 980 | 675 | ||
1315 | 981 | static void | 676 | static void |
1316 | 982 | window_destroyed_cb (GtkWidget *object, | 677 | window_destroyed_cb (GtkWidget *object, |
1317 | 983 | gpointer user_data) | 678 | gpointer user_data) |
1318 | 984 | { | 679 | { |
1319 | 985 | GripGestureManager *manager = (GripGestureManager *)user_data; | 680 | GripGestureManager *manager = (GripGestureManager *)user_data; |
1343 | 986 | GripGestureManagerPrivate *priv = manager->priv; | 681 | GList *l = manager->priv->bindings; |
1344 | 987 | struct Registrations *reg = g_hash_table_lookup (priv->registered_windows, object); | 682 | while (l != NULL) |
1345 | 988 | 683 | { | |
1346 | 989 | if (!reg) | 684 | GList *next = l->next; |
1347 | 990 | return; | 685 | GripGestureBinding *binding = l->data; |
1348 | 991 | 686 | if (gtk_widget_get_toplevel (binding->widget) == object) | |
1349 | 992 | destroy_registration(reg->touchpad); | 687 | { |
1350 | 993 | destroy_registration(reg->touchscreen); | 688 | geis_subscription_delete (binding->subscription); |
1351 | 994 | destroy_registration(reg->independent); | 689 | |
1352 | 995 | 690 | if (binding->destroy) | |
1353 | 996 | g_hash_table_remove (priv->registered_windows, object); | 691 | binding->destroy (binding->data); |
1354 | 997 | g_free (reg); | 692 | g_free (binding); |
1355 | 998 | } | 693 | manager->priv->bindings = g_list_delete_link (manager->priv->bindings, l); |
1356 | 999 | 694 | } | |
1357 | 1000 | static const gchar * | 695 | l = next; |
1358 | 1001 | grip_type_to_geis_type (GripGestureType gesture_type, | 696 | } |
1336 | 1002 | gint touch_points) | ||
1337 | 1003 | { | ||
1338 | 1004 | /* grail taps begin at 15, so let's convert that into something we | ||
1339 | 1005 | * can index in geis_gesture_types. */ | ||
1340 | 1006 | int t = gesture_type == 15 ? 3 : gesture_type; | ||
1341 | 1007 | |||
1342 | 1008 | return geis_gesture_types[(t * 5 + touch_points) - 1]; | ||
1359 | 1009 | } | 697 | } |
1360 | 1010 | 698 | ||
1361 | 1011 | 699 | ||
1362 | @@ -1017,232 +705,207 @@ | |||
1363 | 1017 | } | 705 | } |
1364 | 1018 | 706 | ||
1365 | 1019 | 707 | ||
1366 | 708 | /* | ||
1367 | 709 | * processed_mapped_window_request: | ||
1368 | 710 | * @reg: a #GripRegistrationRequest (removed from the GripGestureManager | ||
1369 | 711 | * requests listand freed). | ||
1370 | 712 | * | ||
1371 | 713 | * Creates a subscription for a widget mapped to a window. | ||
1372 | 714 | */ | ||
1373 | 1020 | static void | 715 | static void |
1376 | 1021 | grip_devices_for_type (GripDeviceType type, GArray *selection, | 716 | processed_mapped_window_request (GripRegistrationRequest *req) |
1375 | 1022 | GripDevices *devices) | ||
1377 | 1023 | { | 717 | { |
1381 | 1024 | guint i; | 718 | g_return_if_fail (GRIP_IS_GESTURE_MANAGER (req->manager)); |
1382 | 1025 | 719 | g_return_if_fail (GTK_IS_WIDGET (req->widget)); | |
1383 | 1026 | for (i = 0; i < devices->len; ++i) | 720 | |
1384 | 721 | GtkWidget *toplevel = gtk_widget_get_toplevel (req->widget); | ||
1385 | 722 | g_return_if_fail (GTK_IS_WINDOW (toplevel)); | ||
1386 | 723 | |||
1387 | 724 | GripGestureManagerPrivate *priv = req->manager->priv; | ||
1388 | 725 | |||
1389 | 726 | guint window_id = GDK_WINDOW_XID (gtk_widget_get_window(req->widget)); | ||
1390 | 727 | |||
1391 | 728 | /* XXX - check for duplicates in reg->bindings first */ | ||
1392 | 729 | GripGestureBinding *binding = g_new0 (GripGestureBinding, 1); | ||
1393 | 730 | binding->type = req->gesture_type; | ||
1394 | 731 | binding->widget = req->widget; | ||
1395 | 732 | binding->touches = req->touch_points; | ||
1396 | 733 | binding->callback = req->callback; | ||
1397 | 734 | binding->data = req->user_data; | ||
1398 | 735 | binding->destroy = req->destroy; | ||
1399 | 736 | |||
1400 | 737 | char sub_name[48]; | ||
1401 | 738 | snprintf(sub_name, 48, "sub-%x-%x-%x", window_id, req->gesture_type, req->touch_points); | ||
1402 | 739 | binding->subscription = geis_subscription_new (priv->geis, sub_name, GEIS_SUBSCRIPTION_CONT); | ||
1403 | 740 | g_return_if_fail (binding->subscription); | ||
1404 | 741 | |||
1405 | 742 | char filter_id[20]; | ||
1406 | 743 | snprintf(filter_id, 20, "grip-%x", window_id); | ||
1407 | 744 | GeisFilter window_filter = geis_filter_new(priv->geis, filter_id); | ||
1408 | 745 | geis_filter_add_term(window_filter, GEIS_FILTER_REGION, | ||
1409 | 746 | GEIS_REGION_ATTRIBUTE_WINDOWID, GEIS_FILTER_OP_EQ, window_id, | ||
1410 | 747 | NULL); | ||
1411 | 748 | |||
1412 | 749 | switch (req->gesture_type) | ||
1413 | 1027 | { | 750 | { |
1430 | 1028 | GripInputDevice *input_device = g_ptr_array_index (devices, i); | 751 | case GRIP_GESTURE_DRAG: |
1431 | 1029 | GeisInputDeviceId id = grip_input_device_get_id (input_device); | 752 | geis_filter_add_term(window_filter, GEIS_FILTER_CLASS, |
1432 | 1030 | GripDeviceType device_type= grip_get_device_type(input_device); | 753 | GEIS_CLASS_ATTRIBUTE_NAME, GEIS_FILTER_OP_EQ, GEIS_GESTURE_DRAG, |
1433 | 1031 | 754 | GEIS_GESTURE_ATTRIBUTE_TOUCHES, GEIS_FILTER_OP_EQ, req->touch_points, | |
1434 | 1032 | if ((type & GRIP_DEVICE_TOUCHSCREEN) && device_type == GRIP_DEVICE_TOUCHSCREEN) | 755 | NULL); |
1435 | 1033 | { | 756 | break; |
1436 | 1034 | g_array_append_val (selection, id); | 757 | case GRIP_GESTURE_PINCH: |
1437 | 1035 | } | 758 | geis_filter_add_term(window_filter, GEIS_FILTER_CLASS, |
1438 | 1036 | if ((type & GRIP_DEVICE_TOUCHPAD) && device_type == GRIP_DEVICE_TOUCHPAD) | 759 | GEIS_CLASS_ATTRIBUTE_NAME, GEIS_FILTER_OP_EQ, GEIS_GESTURE_PINCH, |
1439 | 1037 | { | 760 | GEIS_GESTURE_ATTRIBUTE_TOUCHES, GEIS_FILTER_OP_EQ, req->touch_points, |
1440 | 1038 | g_array_append_val (selection, id); | 761 | NULL); |
1441 | 1039 | } | 762 | break; |
1442 | 1040 | if ((type & GRIP_DEVICE_INDEPENDENT) && device_type == GRIP_DEVICE_INDEPENDENT) | 763 | case GRIP_GESTURE_ROTATE: |
1443 | 1041 | { | 764 | geis_filter_add_term(window_filter, GEIS_FILTER_CLASS, |
1444 | 1042 | g_array_append_val (selection, id); | 765 | GEIS_CLASS_ATTRIBUTE_NAME, GEIS_FILTER_OP_EQ, GEIS_GESTURE_ROTATE, |
1445 | 1043 | } | 766 | GEIS_GESTURE_ATTRIBUTE_TOUCHES, GEIS_FILTER_OP_EQ, req->touch_points, |
1446 | 767 | NULL); | ||
1447 | 768 | break; | ||
1448 | 769 | case GRIP_GESTURE_TAP: | ||
1449 | 770 | geis_filter_add_term(window_filter, GEIS_FILTER_CLASS, | ||
1450 | 771 | GEIS_CLASS_ATTRIBUTE_NAME, GEIS_FILTER_OP_EQ, GEIS_GESTURE_TAP, | ||
1451 | 772 | GEIS_GESTURE_ATTRIBUTE_TOUCHES, GEIS_FILTER_OP_EQ, req->touch_points, | ||
1452 | 773 | NULL); | ||
1453 | 774 | break; | ||
1454 | 1044 | } | 775 | } |
1506 | 1045 | } | 776 | |
1507 | 1046 | 777 | if (req->device_type & GRIP_DEVICE_TOUCHSCREEN) | |
1508 | 1047 | /* | 778 | { |
1509 | 1048 | * new_window_registration: | 779 | char filter_name[32]; |
1510 | 1049 | * @manager: a GripGestureManager | 780 | snprintf(filter_name, 32, "%s/touchscreen", filter_id); |
1511 | 1050 | * @toplevel: a toplevel #GtkWindow | 781 | GeisFilter touchscreen_filter = geis_filter_clone (window_filter, filter_name); |
1512 | 1051 | * | 782 | geis_filter_add_term(touchscreen_filter, GEIS_FILTER_DEVICE, |
1513 | 1052 | * Constructs a new #GripGestureRegistration for a #GtkWidget. | 783 | GEIS_DEVICE_ATTRIBUTE_DIRECT_TOUCH, GEIS_FILTER_OP_EQ, GEIS_TRUE, |
1514 | 1053 | */ | 784 | NULL); |
1515 | 1054 | static GripGestureRegistration * | 785 | GeisStatus status = geis_subscription_add_filter(binding->subscription, touchscreen_filter); |
1516 | 1055 | new_window_registration(GripGestureManager *manager, | 786 | g_return_if_fail (status == GEIS_STATUS_SUCCESS); |
1517 | 1056 | GtkWidget *toplevel) | 787 | } |
1518 | 1057 | { | 788 | if (req->device_type & GRIP_DEVICE_TOUCHPAD) |
1519 | 1058 | GripGestureRegistration *reg; | 789 | { |
1520 | 1059 | GeisInstance instance; | 790 | char filter_name[32]; |
1521 | 1060 | gint fd = -1; | 791 | snprintf(filter_name, 32, "%s/touchpad", filter_id); |
1522 | 1061 | GeisXcbWinInfo xcb_win_info = { | 792 | GeisFilter touchpad_filter = geis_filter_clone (window_filter, filter_name); |
1523 | 1062 | .display_name = NULL, | 793 | geis_filter_add_term(touchpad_filter, GEIS_FILTER_DEVICE, |
1524 | 1063 | .screenp = NULL, | 794 | GEIS_DEVICE_ATTRIBUTE_DIRECT_TOUCH, GEIS_FILTER_OP_EQ, GEIS_FALSE, |
1525 | 1064 | .window_id = GDK_WINDOW_XID (gtk_widget_get_window(toplevel)) | 795 | NULL); |
1526 | 1065 | }; | 796 | GeisStatus status = geis_subscription_add_filter(binding->subscription, touchpad_filter); |
1527 | 1066 | GeisWinInfo win_info = { | 797 | g_return_if_fail (status == GEIS_STATUS_SUCCESS); |
1528 | 1067 | GEIS_XCB_FULL_WINDOW, | 798 | } |
1529 | 1068 | &xcb_win_info | 799 | if (req->device_type & GRIP_DEVICE_INDEPENDENT) |
1530 | 1069 | }; | 800 | { |
1531 | 1070 | 801 | char filter_name[32]; | |
1532 | 1071 | if (geis_init (&win_info, &instance) != GEIS_STATUS_SUCCESS) | 802 | snprintf(filter_name, 32, "%s/indep", filter_id); |
1533 | 1072 | { | 803 | GeisFilter indep_filter = geis_filter_clone (window_filter, filter_name); |
1534 | 1073 | g_warning ("Failed to initialize gesture manager."); | 804 | geis_filter_add_term(indep_filter, GEIS_FILTER_DEVICE, |
1535 | 1074 | return NULL; | 805 | GEIS_DEVICE_ATTRIBUTE_INDEPENDENT_TOUCH, GEIS_FILTER_OP_EQ, GEIS_TRUE, |
1536 | 1075 | } | 806 | NULL); |
1537 | 1076 | 807 | GeisStatus status = geis_subscription_add_filter(binding->subscription, indep_filter); | |
1538 | 1077 | if (geis_configuration_supported (instance, | 808 | g_return_if_fail (status == GEIS_STATUS_SUCCESS); |
1539 | 1078 | GEIS_CONFIG_UNIX_FD) != GEIS_STATUS_SUCCESS) | 809 | } |
1540 | 1079 | { | 810 | |
1541 | 1080 | g_warning ("Gesture manager does not support UNIX fd."); | 811 | /* |
1542 | 1081 | return NULL; | 812 | * If any device types were specified, the window_filter was cloned and needs |
1543 | 1082 | } | 813 | * to be disposed of, otehrwise it's _the_ filter. |
1544 | 1083 | 814 | */ | |
1545 | 1084 | if (geis_configuration_get_value (instance, | 815 | if (req->device_type) |
1546 | 1085 | GEIS_CONFIG_UNIX_FD, | 816 | { |
1547 | 1086 | &fd) != GEIS_STATUS_SUCCESS) | 817 | geis_filter_delete(window_filter); |
1548 | 1087 | { | 818 | } |
1549 | 1088 | g_error ("Gesture manager failed to obtain UNIX fd."); | 819 | else |
1550 | 1089 | return NULL; | 820 | { |
1551 | 1090 | } | 821 | GeisStatus status = geis_subscription_add_filter(binding->subscription, window_filter); |
1552 | 1091 | 822 | g_return_if_fail (status == GEIS_STATUS_SUCCESS); | |
1553 | 1092 | reg = g_new0 (GripGestureRegistration, 1); | 823 | } |
1554 | 1093 | 824 | ||
1555 | 1094 | reg->window = GTK_WINDOW (toplevel); | 825 | |
1556 | 1095 | reg->instance = instance; | 826 | GeisStatus status = geis_subscription_activate (binding->subscription); |
1557 | 827 | g_return_if_fail (status == GEIS_STATUS_SUCCESS); | ||
1558 | 828 | |||
1559 | 829 | priv->bindings = g_list_append (priv->bindings, binding); | ||
1560 | 1096 | 830 | ||
1561 | 1097 | g_signal_connect (toplevel, | 831 | g_signal_connect (toplevel, |
1562 | 1098 | "destroy", | 832 | "destroy", |
1563 | 1099 | G_CALLBACK (window_destroyed_cb), | 833 | G_CALLBACK (window_destroyed_cb), |
1677 | 1100 | manager); | 834 | req->manager); |
1678 | 1101 | 835 | ||
1679 | 1102 | reg->iochannel = g_io_channel_unix_new (fd); | 836 | /* remove the request from the watch list */ |
1680 | 1103 | reg->iochannel_id = g_io_add_watch (reg->iochannel, | 837 | g_free (req); |
1681 | 1104 | G_IO_IN, | 838 | priv->requests = g_list_remove (priv->requests, req); |
1682 | 1105 | io_callback, | 839 | } |
1683 | 1106 | reg); | 840 | |
1684 | 1107 | reg->gesture_list = g_ptr_array_new (); | 841 | |
1685 | 1108 | 842 | /* | |
1686 | 1109 | return reg; | 843 | * register_mapped_window: |
1687 | 1110 | } | 844 | * @manager: a Grip gesture manager object |
1688 | 1111 | 845 | * @toplevel: a top-level widget | |
1689 | 1112 | static void | 846 | * |
1690 | 1113 | bind_registration(GripGestureManager *manager, | 847 | * Processes all subscriptions requests for a newly-mapped window. |
1691 | 1114 | GripGestureRegistration *reg, | 848 | */ |
1692 | 1115 | GtkWidget *widget, | 849 | static void |
1693 | 1116 | GripGestureType gesture_type, | 850 | register_mapped_window (GripGestureManager *manager, GtkWidget *toplevel) |
1694 | 1117 | GripDeviceType device_type, | 851 | { |
1695 | 1118 | gint touch_points, | 852 | g_return_if_fail (gtk_widget_is_toplevel (toplevel)); |
1696 | 1119 | GripGestureCallback callback, | 853 | |
1697 | 1120 | gpointer user_data, | 854 | GList *pending_request = manager->priv->requests; |
1698 | 1121 | GDestroyNotify destroy) | 855 | while (pending_request) |
1699 | 1122 | { | 856 | { |
1700 | 1123 | GripGestureManagerPrivate *priv; | 857 | GList *next = pending_request->next; |
1701 | 1124 | GripGestureBinding *binding; | 858 | GripRegistrationRequest *req = pending_request->data; |
1702 | 1125 | GArray *devices; | 859 | |
1703 | 1126 | 860 | if (gtk_widget_get_toplevel (req->widget) == toplevel) | |
1704 | 1127 | priv = manager->priv; | 861 | { |
1705 | 1128 | 862 | processed_mapped_window_request (req); | |
1706 | 1129 | if (reg->gesture_list->len) | 863 | } |
1707 | 1130 | g_ptr_array_remove_index (reg->gesture_list, | 864 | pending_request = next; |
1708 | 1131 | reg->gesture_list->len - 1); | 865 | } |
1709 | 1132 | 866 | } | |
1710 | 1133 | devices = g_array_new (TRUE, FALSE, sizeof(GeisInputDeviceId)); | 867 | |
1711 | 1134 | grip_devices_for_type(device_type, devices, priv->devices); | 868 | |
1712 | 1135 | if (devices->len == 0) { | 869 | /* |
1713 | 1136 | g_array_free(devices, TRUE); | 870 | * register_toplevel_widget: |
1714 | 1137 | return; | 871 | * @manager: a Grip gesture manager object |
1715 | 1138 | } | 872 | * @toplevel: a top-level widget |
1716 | 1139 | 873 | * | |
1717 | 1140 | g_ptr_array_add (reg->gesture_list, | 874 | * Handles the registration of a widget that has just become a top-level widget. |
1718 | 1141 | (gchar *)grip_type_to_geis_type (gesture_type, touch_points)); | 875 | * |
1719 | 1142 | g_ptr_array_add (reg->gesture_list, | 876 | * If the top-level widget is mapped to a window, it;s handled right away. |
1720 | 1143 | NULL); | 877 | * Otherwise, a callback is queued for when it does become mapped to a window. |
1721 | 1144 | 878 | */ | |
1722 | 1145 | geis_subscribe (reg->instance, | 879 | static void |
1723 | 1146 | (GeisInputDeviceId *)(void *)devices->data, | 880 | register_toplevel_widget (GripGestureManager *manager, GtkWidget *toplevel) |
1724 | 1147 | (const char**)reg->gesture_list->pdata, | 881 | { |
1725 | 1148 | &gesture_funcs, | 882 | g_return_if_fail (gtk_widget_is_toplevel (toplevel)); |
1726 | 1149 | manager); | 883 | |
1727 | 1150 | 884 | if (gtk_widget_get_mapped (GTK_WIDGET (toplevel))) | |
1728 | 1151 | g_array_unref (devices); | 885 | { |
1729 | 1152 | 886 | register_mapped_window (manager, toplevel); | |
1617 | 1153 | /* XXX - check for duplicates in reg->bindings first */ | ||
1618 | 1154 | binding = g_new0 (GripGestureBinding, 1); | ||
1619 | 1155 | |||
1620 | 1156 | binding->type = gesture_type; | ||
1621 | 1157 | binding->widget = widget; | ||
1622 | 1158 | binding->touches = touch_points; | ||
1623 | 1159 | binding->callback = callback; | ||
1624 | 1160 | binding->data = user_data; | ||
1625 | 1161 | binding->destroy = destroy; | ||
1626 | 1162 | |||
1627 | 1163 | reg->bindings = g_list_append (reg->bindings, binding); | ||
1628 | 1164 | } | ||
1629 | 1165 | |||
1630 | 1166 | /* | ||
1631 | 1167 | * register_internal: | ||
1632 | 1168 | * @manager: the @GripGestureManager | ||
1633 | 1169 | * @widget: the GtkWidget to be bound | ||
1634 | 1170 | * @gesture_type: the type of gesture to subscribe for | ||
1635 | 1171 | * @device_type: the type of input device to subscribe for | ||
1636 | 1172 | * @touch_points: | ||
1637 | 1173 | * @callback: the callback to be invoked on gesture events | ||
1638 | 1174 | * @user_data: the callbackl context to be passed back on gesture events | ||
1639 | 1175 | * @destroy: | ||
1640 | 1176 | * | ||
1641 | 1177 | * Binds or rebinds a gesture subscription for a widget. | ||
1642 | 1178 | */ | ||
1643 | 1179 | static void | ||
1644 | 1180 | register_internal (GripGestureManager *manager, | ||
1645 | 1181 | GtkWidget *widget, | ||
1646 | 1182 | GripGestureType gesture_type, | ||
1647 | 1183 | GripDeviceType device_type, | ||
1648 | 1184 | gint touch_points, | ||
1649 | 1185 | GripGestureCallback callback, | ||
1650 | 1186 | gpointer user_data, | ||
1651 | 1187 | GDestroyNotify destroy) | ||
1652 | 1188 | { | ||
1653 | 1189 | GripGestureManagerPrivate *priv; | ||
1654 | 1190 | GtkWidget *toplevel; | ||
1655 | 1191 | struct Registrations *registrations; | ||
1656 | 1192 | |||
1657 | 1193 | g_return_if_fail (GRIP_IS_GESTURE_MANAGER (manager)); | ||
1658 | 1194 | g_return_if_fail (GTK_IS_WIDGET (widget)); | ||
1659 | 1195 | |||
1660 | 1196 | toplevel = gtk_widget_get_toplevel (widget); | ||
1661 | 1197 | |||
1662 | 1198 | g_return_if_fail (GTK_IS_WINDOW (toplevel)); | ||
1663 | 1199 | |||
1664 | 1200 | priv = manager->priv; | ||
1665 | 1201 | |||
1666 | 1202 | if (!(registrations = g_hash_table_lookup (priv->registered_windows, toplevel))) | ||
1667 | 1203 | { | ||
1668 | 1204 | registrations = g_new(struct Registrations, 1); | ||
1669 | 1205 | registrations->touchscreen = new_window_registration(manager, toplevel); | ||
1670 | 1206 | registrations->touchpad = new_window_registration(manager, toplevel); | ||
1671 | 1207 | registrations->independent = new_window_registration(manager, toplevel); | ||
1672 | 1208 | |||
1673 | 1209 | if (registrations->touchscreen == NULL || | ||
1674 | 1210 | registrations->touchpad == NULL || | ||
1675 | 1211 | registrations->independent == NULL) | ||
1676 | 1212 | return; | ||
1730 | 1213 | } | 887 | } |
1731 | 1214 | else | 888 | else |
1732 | 1215 | { | 889 | { |
1742 | 1216 | if (device_type & GRIP_DEVICE_TOUCHSCREEN) | 890 | g_signal_connect (toplevel, |
1743 | 1217 | geis_unsubscribe (registrations->touchscreen->instance, | 891 | "map-event", |
1744 | 1218 | (GeisGestureType*)registrations->touchscreen->gesture_list->pdata); | 892 | G_CALLBACK (toplevel_mapped_cb), |
1745 | 1219 | if (device_type & GRIP_DEVICE_TOUCHPAD) | 893 | manager); |
1737 | 1220 | geis_unsubscribe (registrations->touchpad->instance, | ||
1738 | 1221 | (GeisGestureType*)registrations->touchpad->gesture_list->pdata); | ||
1739 | 1222 | if (device_type & GRIP_DEVICE_INDEPENDENT) | ||
1740 | 1223 | geis_unsubscribe (registrations->independent->instance, | ||
1741 | 1224 | (GeisGestureType*)registrations->independent->gesture_list->pdata); | ||
1746 | 1225 | } | 894 | } |
1747 | 1226 | |||
1748 | 1227 | if (device_type & GRIP_DEVICE_TOUCHSCREEN) | ||
1749 | 1228 | bind_registration(manager, | ||
1750 | 1229 | registrations->touchscreen, widget, gesture_type, GRIP_DEVICE_TOUCHSCREEN, touch_points, | ||
1751 | 1230 | callback, user_data, destroy); | ||
1752 | 1231 | |||
1753 | 1232 | if (device_type & GRIP_DEVICE_TOUCHPAD) | ||
1754 | 1233 | bind_registration(manager, | ||
1755 | 1234 | registrations->touchpad, widget, gesture_type, GRIP_DEVICE_TOUCHPAD, touch_points, | ||
1756 | 1235 | callback, user_data, destroy); | ||
1757 | 1236 | |||
1758 | 1237 | if (device_type & GRIP_DEVICE_INDEPENDENT) | ||
1759 | 1238 | bind_registration(manager, | ||
1760 | 1239 | registrations->independent, widget, gesture_type, GRIP_DEVICE_INDEPENDENT, touch_points, | ||
1761 | 1240 | callback, user_data, destroy); | ||
1762 | 1241 | g_hash_table_insert (priv->registered_windows, | ||
1763 | 1242 | toplevel, | ||
1764 | 1243 | registrations); | ||
1765 | 1244 | } | 895 | } |
1766 | 1245 | 896 | ||
1767 | 897 | |||
1768 | 898 | /* | ||
1769 | 899 | * toplevel_notify_cb: | ||
1770 | 900 | * | ||
1771 | 901 | * Called when a widget property has changed. | ||
1772 | 902 | * | ||
1773 | 903 | * The only widget property we're interested in here is the "parent" property. | ||
1774 | 904 | * We can't subscribe to gestures on a window until the widget is mapped to a | ||
1775 | 905 | * window. Only top-level widgets can be mapped to a window: we just keep | ||
1776 | 906 | * queueing this callback on successive parent widgets until one is a top-level | ||
1777 | 907 | * widget, then process that one. | ||
1778 | 908 | */ | ||
1779 | 1246 | static void | 909 | static void |
1780 | 1247 | toplevel_notify_cb (GtkWidget *widget, | 910 | toplevel_notify_cb (GtkWidget *widget, |
1781 | 1248 | GParamSpec *pspec, | 911 | GParamSpec *pspec, |
1782 | @@ -1251,7 +914,7 @@ | |||
1783 | 1251 | if (pspec->name == g_intern_static_string ("parent")) | 914 | if (pspec->name == g_intern_static_string ("parent")) |
1784 | 1252 | { | 915 | { |
1785 | 1253 | GtkWidget *toplevel = gtk_widget_get_toplevel (widget); | 916 | GtkWidget *toplevel = gtk_widget_get_toplevel (widget); |
1787 | 1254 | GripRegistrationRequest *req = (GripRegistrationRequest *)user_data; | 917 | GripGestureManager *manager = (GripGestureManager *)user_data; |
1788 | 1255 | 918 | ||
1789 | 1256 | g_signal_handlers_disconnect_by_func (widget, | 919 | g_signal_handlers_disconnect_by_func (widget, |
1790 | 1257 | G_CALLBACK (toplevel_notify_cb), | 920 | G_CALLBACK (toplevel_notify_cb), |
1791 | @@ -1259,30 +922,7 @@ | |||
1792 | 1259 | 922 | ||
1793 | 1260 | if (gtk_widget_is_toplevel (toplevel)) | 923 | if (gtk_widget_is_toplevel (toplevel)) |
1794 | 1261 | { | 924 | { |
1819 | 1262 | if (gtk_widget_get_mapped (GTK_WIDGET (toplevel))) | 925 | register_toplevel_widget (manager, toplevel); |
1796 | 1263 | { | ||
1797 | 1264 | register_internal (req->manager, | ||
1798 | 1265 | req->widget, | ||
1799 | 1266 | req->gesture_type, | ||
1800 | 1267 | req->device_type, | ||
1801 | 1268 | req->touch_points, | ||
1802 | 1269 | req->callback, | ||
1803 | 1270 | req->user_data, | ||
1804 | 1271 | req->destroy); | ||
1805 | 1272 | |||
1806 | 1273 | g_free (req); | ||
1807 | 1274 | } | ||
1808 | 1275 | else | ||
1809 | 1276 | { | ||
1810 | 1277 | GripGestureManagerPrivate *priv = req->manager->priv; | ||
1811 | 1278 | |||
1812 | 1279 | priv->requests = g_list_append (priv->requests, req); | ||
1813 | 1280 | |||
1814 | 1281 | g_signal_connect (toplevel, | ||
1815 | 1282 | "map-event", | ||
1816 | 1283 | G_CALLBACK (toplevel_mapped_cb), | ||
1817 | 1284 | req->manager); | ||
1818 | 1285 | } | ||
1820 | 1286 | } | 926 | } |
1821 | 1287 | else | 927 | else |
1822 | 1288 | { | 928 | { |
1823 | @@ -1294,96 +934,29 @@ | |||
1824 | 1294 | } | 934 | } |
1825 | 1295 | } | 935 | } |
1826 | 1296 | 936 | ||
1827 | 937 | |||
1828 | 1297 | /* | 938 | /* |
1837 | 1298 | * register_widget: | 939 | * toplevel_mapped_cb: |
1838 | 1299 | * | 940 | * |
1839 | 1300 | * Registers a specific widget for a specific gesture made by a specific input | 941 | * A callback invoked when a toplevel widget with one or more pending gesture |
1840 | 1301 | * device type. | 942 | * registration requests has been mapped to a window. |
1841 | 1302 | * | 943 | * |
1842 | 1303 | * If the widget's containing window is a valid window, the widget is registered | 944 | * This callback will in fact process all pending registration requests for the |
1843 | 1304 | * right away, otherwise the registration is deferred until the widget actually | 945 | * newly-mapped window. |
1836 | 1305 | * has a top-level window. | ||
1844 | 1306 | */ | 946 | */ |
1845 | 1307 | static void | 947 | static void |
1846 | 1308 | register_widget (GripGestureManager *manager, | ||
1847 | 1309 | GtkWidget *widget, | ||
1848 | 1310 | GripGestureType gesture_type, | ||
1849 | 1311 | GripDeviceType device_type, | ||
1850 | 1312 | gint touch_points, | ||
1851 | 1313 | GripGestureCallback callback, | ||
1852 | 1314 | gpointer user_data, | ||
1853 | 1315 | GDestroyNotify destroy) | ||
1854 | 1316 | { | ||
1855 | 1317 | GtkWidget *toplevel = gtk_widget_get_toplevel (widget); | ||
1856 | 1318 | |||
1857 | 1319 | if (gtk_widget_is_toplevel (toplevel)) | ||
1858 | 1320 | { | ||
1859 | 1321 | register_internal (manager, | ||
1860 | 1322 | widget, | ||
1861 | 1323 | gesture_type, | ||
1862 | 1324 | device_type, | ||
1863 | 1325 | touch_points, | ||
1864 | 1326 | callback, | ||
1865 | 1327 | user_data, | ||
1866 | 1328 | destroy); | ||
1867 | 1329 | } | ||
1868 | 1330 | else | ||
1869 | 1331 | { | ||
1870 | 1332 | GripRegistrationRequest *req = g_new0 (GripRegistrationRequest, 1); | ||
1871 | 1333 | |||
1872 | 1334 | req->manager = manager; | ||
1873 | 1335 | req->widget = widget; | ||
1874 | 1336 | req->gesture_type = gesture_type; | ||
1875 | 1337 | req->device_type = device_type; | ||
1876 | 1338 | req->touch_points = touch_points; | ||
1877 | 1339 | req->callback = callback; | ||
1878 | 1340 | req->user_data = user_data; | ||
1879 | 1341 | req->destroy = destroy; | ||
1880 | 1342 | |||
1881 | 1343 | g_signal_connect (toplevel, | ||
1882 | 1344 | "notify", | ||
1883 | 1345 | G_CALLBACK (toplevel_notify_cb), | ||
1884 | 1346 | req); | ||
1885 | 1347 | } | ||
1886 | 1348 | } | ||
1887 | 1349 | |||
1888 | 1350 | static void | ||
1889 | 1351 | toplevel_mapped_cb (GtkWidget *toplevel, | 948 | toplevel_mapped_cb (GtkWidget *toplevel, |
1890 | 1352 | GdkEvent *event G_GNUC_UNUSED, | 949 | GdkEvent *event G_GNUC_UNUSED, |
1891 | 1353 | gpointer user_data) | 950 | gpointer user_data) |
1892 | 1354 | { | 951 | { |
1893 | 1355 | GripGestureManager *manager = (GripGestureManager *)user_data; | 952 | GripGestureManager *manager = (GripGestureManager *)user_data; |
1920 | 1356 | GripGestureManagerPrivate *priv = manager->priv; | 953 | register_mapped_window (manager, toplevel); |
1895 | 1357 | GList *request = priv->requests; | ||
1896 | 1358 | |||
1897 | 1359 | while (request) | ||
1898 | 1360 | { | ||
1899 | 1361 | GList *next = request->next; | ||
1900 | 1362 | GripRegistrationRequest *req = request->data; | ||
1901 | 1363 | |||
1902 | 1364 | if (gtk_widget_get_toplevel (req->widget) == toplevel) | ||
1903 | 1365 | { | ||
1904 | 1366 | register_widget (req->manager, | ||
1905 | 1367 | req->widget, | ||
1906 | 1368 | req->gesture_type, | ||
1907 | 1369 | req->device_type, | ||
1908 | 1370 | req->touch_points, | ||
1909 | 1371 | req->callback, | ||
1910 | 1372 | req->user_data, | ||
1911 | 1373 | req->destroy); | ||
1912 | 1374 | |||
1913 | 1375 | priv->requests = g_list_remove_link (priv->requests, request); | ||
1914 | 1376 | g_free (req); | ||
1915 | 1377 | g_list_free_1 (request); | ||
1916 | 1378 | } | ||
1917 | 1379 | request = next; | ||
1918 | 1380 | } | ||
1919 | 1381 | |||
1921 | 1382 | g_signal_handlers_disconnect_by_func (toplevel, | 954 | g_signal_handlers_disconnect_by_func (toplevel, |
1922 | 1383 | toplevel_mapped_cb, | 955 | toplevel_mapped_cb, |
1923 | 1384 | user_data); | 956 | user_data); |
1924 | 1385 | } | 957 | } |
1925 | 1386 | 958 | ||
1926 | 959 | |||
1927 | 1387 | /** | 960 | /** |
1928 | 1388 | * grip_gesture_manager_register_window: | 961 | * grip_gesture_manager_register_window: |
1929 | 1389 | * @manager: A #GripGestureManager instance. | 962 | * @manager: A #GripGestureManager instance. |
1930 | @@ -1411,102 +984,47 @@ | |||
1931 | 1411 | gpointer user_data, | 984 | gpointer user_data, |
1932 | 1412 | GDestroyNotify destroy) | 985 | GDestroyNotify destroy) |
1933 | 1413 | { | 986 | { |
1934 | 1414 | GtkWidget *toplevel; | ||
1935 | 1415 | |||
1936 | 1416 | g_return_if_fail (GRIP_IS_GESTURE_MANAGER (manager)); | 987 | g_return_if_fail (GRIP_IS_GESTURE_MANAGER (manager)); |
1937 | 1417 | g_return_if_fail (GTK_IS_WIDGET (widget)); | 988 | g_return_if_fail (GTK_IS_WIDGET (widget)); |
1938 | 1418 | 989 | ||
1940 | 1419 | toplevel = gtk_widget_get_toplevel (widget); | 990 | GtkWidget *toplevel = gtk_widget_get_toplevel (widget); |
1941 | 991 | |||
1942 | 992 | GripRegistrationRequest *req = g_new0 (GripRegistrationRequest, 1); | ||
1943 | 993 | req->manager = manager; | ||
1944 | 994 | req->widget = widget; | ||
1945 | 995 | req->gesture_type = gesture_type; | ||
1946 | 996 | req->device_type = device_type; | ||
1947 | 997 | req->touch_points = touch_points; | ||
1948 | 998 | req->callback = callback; | ||
1949 | 999 | req->user_data = user_data; | ||
1950 | 1000 | req->destroy = destroy; | ||
1951 | 1001 | manager->priv->requests = g_list_append (manager->priv->requests, req); | ||
1952 | 1420 | 1002 | ||
1953 | 1421 | if (GTK_IS_WINDOW (toplevel)) | 1003 | if (GTK_IS_WINDOW (toplevel)) |
1954 | 1422 | { | 1004 | { |
1987 | 1423 | if (gtk_widget_get_mapped (GTK_WIDGET (toplevel))) | 1005 | register_toplevel_widget (manager, toplevel); |
1956 | 1424 | { | ||
1957 | 1425 | register_internal (manager, | ||
1958 | 1426 | widget, | ||
1959 | 1427 | gesture_type, | ||
1960 | 1428 | device_type, | ||
1961 | 1429 | touch_points, | ||
1962 | 1430 | callback, | ||
1963 | 1431 | user_data, | ||
1964 | 1432 | destroy); | ||
1965 | 1433 | } | ||
1966 | 1434 | else | ||
1967 | 1435 | { | ||
1968 | 1436 | GripRegistrationRequest *req = g_new0 (GripRegistrationRequest, 1); | ||
1969 | 1437 | GripGestureManagerPrivate *priv = manager->priv; | ||
1970 | 1438 | |||
1971 | 1439 | req->manager = manager; | ||
1972 | 1440 | req->widget = widget; | ||
1973 | 1441 | req->gesture_type = gesture_type; | ||
1974 | 1442 | req->device_type = device_type; | ||
1975 | 1443 | req->touch_points = touch_points; | ||
1976 | 1444 | req->callback = callback; | ||
1977 | 1445 | req->user_data = user_data; | ||
1978 | 1446 | req->destroy = destroy; | ||
1979 | 1447 | |||
1980 | 1448 | priv->requests = g_list_append (priv->requests, req); | ||
1981 | 1449 | |||
1982 | 1450 | g_signal_connect (toplevel, | ||
1983 | 1451 | "map-event", | ||
1984 | 1452 | G_CALLBACK (toplevel_mapped_cb), | ||
1985 | 1453 | manager); | ||
1986 | 1454 | } | ||
1988 | 1455 | } | 1006 | } |
1989 | 1456 | else | 1007 | else |
1990 | 1457 | { | 1008 | { |
1991 | 1458 | GripRegistrationRequest *req = g_new0 (GripRegistrationRequest, 1); | ||
1992 | 1459 | |||
1993 | 1460 | req->manager = manager; | ||
1994 | 1461 | req->widget = widget; | ||
1995 | 1462 | req->gesture_type = gesture_type; | ||
1996 | 1463 | req->device_type = device_type; | ||
1997 | 1464 | req->touch_points = touch_points; | ||
1998 | 1465 | req->callback = callback; | ||
1999 | 1466 | req->user_data = user_data; | ||
2000 | 1467 | req->destroy = destroy; | ||
2001 | 1468 | |||
2002 | 1469 | g_signal_connect (toplevel, | 1009 | g_signal_connect (toplevel, |
2003 | 1470 | "notify", | 1010 | "notify", |
2004 | 1471 | G_CALLBACK (toplevel_notify_cb), | 1011 | G_CALLBACK (toplevel_notify_cb), |
2006 | 1472 | req); | 1012 | manager); |
2007 | 1473 | } | 1013 | } |
2008 | 1474 | } | 1014 | } |
2009 | 1475 | 1015 | ||
2010 | 1476 | static void | ||
2011 | 1477 | shutdown_registration(GripGestureRegistration *reg) | ||
2012 | 1478 | { | ||
2013 | 1479 | free_registration(reg); | ||
2014 | 1480 | geis_finish(reg->instance); | ||
2015 | 1481 | reg->instance = NULL; | ||
2016 | 1482 | g_free(reg); | ||
2017 | 1483 | } | ||
2018 | 1484 | 1016 | ||
2019 | 1485 | void | 1017 | void |
2022 | 1486 | grip_gesture_manager_unregister_window (GripGestureManager *manager, | 1018 | grip_gesture_manager_unregister_window (GripGestureManager *manager G_GNUC_UNUSED, |
2023 | 1487 | GtkWidget *toplevel) | 1019 | GtkWidget *toplevel G_GNUC_UNUSED) |
2024 | 1488 | { | 1020 | { |
2025 | 1489 | GripGestureManagerPrivate *priv = manager->priv; | ||
2026 | 1490 | struct Registrations *registrations; | ||
2027 | 1491 | |||
2028 | 1492 | g_return_if_fail (GRIP_IS_GESTURE_MANAGER (manager)); | 1021 | g_return_if_fail (GRIP_IS_GESTURE_MANAGER (manager)); |
2029 | 1493 | g_return_if_fail (GTK_IS_WINDOW (toplevel)); | 1022 | g_return_if_fail (GTK_IS_WINDOW (toplevel)); |
2030 | 1494 | 1023 | ||
2044 | 1495 | /* Currently only allow unsubscribing after the window has been shown. */ | 1024 | window_destroyed_cb (toplevel, manager); |
2032 | 1496 | g_return_if_fail (gtk_widget_get_mapped (GTK_WIDGET (toplevel))); | ||
2033 | 1497 | registrations = g_hash_table_lookup (priv->registered_windows, toplevel); | ||
2034 | 1498 | if (!registrations) { | ||
2035 | 1499 | return; | ||
2036 | 1500 | } | ||
2037 | 1501 | |||
2038 | 1502 | shutdown_registration(registrations->touchscreen); | ||
2039 | 1503 | shutdown_registration(registrations->touchpad); | ||
2040 | 1504 | shutdown_registration(registrations->independent); | ||
2041 | 1505 | g_free(registrations); | ||
2042 | 1506 | g_hash_table_remove(priv->registered_windows, toplevel); | ||
2043 | 1507 | |||
2045 | 1508 | } | 1025 | } |
2046 | 1509 | 1026 | ||
2047 | 1027 | |||
2048 | 1510 | GType | 1028 | GType |
2049 | 1511 | grip_gesture_event_get_type (void) | 1029 | grip_gesture_event_get_type (void) |
2050 | 1512 | { | 1030 | { |
2051 | 1513 | 1031 | ||
2052 | === modified file 'src/gripinputdevice.c' | |||
2053 | --- src/gripinputdevice.c 2011-10-19 14:05:35 +0000 | |||
2054 | +++ src/gripinputdevice.c 2013-04-17 15:02:24 +0000 | |||
2055 | @@ -1,5 +1,5 @@ | |||
2056 | 1 | /* | 1 | /* |
2058 | 2 | * Copyright 2011 Canonical, Ltd. | 2 | * Copyright 2011, 2013 Canonical Ltd. |
2059 | 3 | * | 3 | * |
2060 | 4 | * This program is free software: you can redistribute it and/or modify it | 4 | * This program is free software: you can redistribute it and/or modify it |
2061 | 5 | * under the terms of either or both of the following licenses: | 5 | * under the terms of either or both of the following licenses: |
2062 | @@ -79,53 +79,61 @@ | |||
2063 | 79 | for (a = attrs; a->name; a++) | 79 | for (a = attrs; a->name; a++) |
2064 | 80 | { | 80 | { |
2065 | 81 | if (0 == g_strcmp0 (a->name, GEIS_DEVICE_ATTRIBUTE_NAME)) | 81 | if (0 == g_strcmp0 (a->name, GEIS_DEVICE_ATTRIBUTE_NAME)) |
2066 | 82 | { | ||
2067 | 83 | input_device->priv->name = g_strdup (a->string_val); | 82 | input_device->priv->name = g_strdup (a->string_val); |
2068 | 84 | } | ||
2069 | 85 | else if (0 == g_strcmp0 (a->name, GEIS_DEVICE_ATTRIBUTE_ID)) | 83 | else if (0 == g_strcmp0 (a->name, GEIS_DEVICE_ATTRIBUTE_ID)) |
2070 | 86 | { | ||
2071 | 87 | input_device->priv->device_id = a->integer_val; | 84 | input_device->priv->device_id = a->integer_val; |
2072 | 88 | } | ||
2073 | 89 | else if (0 == g_strcmp0 (a->name, GEIS_DEVICE_ATTRIBUTE_TOUCHES)) | 85 | else if (0 == g_strcmp0 (a->name, GEIS_DEVICE_ATTRIBUTE_TOUCHES)) |
2074 | 90 | { | ||
2075 | 91 | input_device->priv->touches = a->integer_val; | 86 | input_device->priv->touches = a->integer_val; |
2076 | 92 | } | ||
2077 | 93 | else if (0 == g_strcmp0 (a->name, GEIS_DEVICE_ATTRIBUTE_DIRECT_TOUCH)) | 87 | else if (0 == g_strcmp0 (a->name, GEIS_DEVICE_ATTRIBUTE_DIRECT_TOUCH)) |
2078 | 94 | { | ||
2079 | 95 | input_device->priv->is_direct = a->boolean_val; | 88 | input_device->priv->is_direct = a->boolean_val; |
2080 | 96 | } | ||
2081 | 97 | else if (0 == g_strcmp0 (a->name, GEIS_DEVICE_ATTRIBUTE_INDEPENDENT_TOUCH)) | 89 | else if (0 == g_strcmp0 (a->name, GEIS_DEVICE_ATTRIBUTE_INDEPENDENT_TOUCH)) |
2082 | 98 | { | ||
2083 | 99 | input_device->priv->is_independent = a->boolean_val; | 90 | input_device->priv->is_independent = a->boolean_val; |
2084 | 100 | } | ||
2085 | 101 | else if (0 == g_strcmp0 (a->name, GEIS_DEVICE_ATTRIBUTE_MIN_X)) | 91 | else if (0 == g_strcmp0 (a->name, GEIS_DEVICE_ATTRIBUTE_MIN_X)) |
2086 | 102 | { | ||
2087 | 103 | input_device->priv->x_extents.minimum = a->float_val; | 92 | input_device->priv->x_extents.minimum = a->float_val; |
2088 | 104 | } | ||
2089 | 105 | else if (0 == g_strcmp0 (a->name, GEIS_DEVICE_ATTRIBUTE_MAX_X)) | 93 | else if (0 == g_strcmp0 (a->name, GEIS_DEVICE_ATTRIBUTE_MAX_X)) |
2090 | 106 | { | ||
2091 | 107 | input_device->priv->x_extents.maximum = a->float_val; | 94 | input_device->priv->x_extents.maximum = a->float_val; |
2092 | 108 | } | ||
2093 | 109 | else if (0 == g_strcmp0 (a->name, GEIS_DEVICE_ATTRIBUTE_RES_X)) | 95 | else if (0 == g_strcmp0 (a->name, GEIS_DEVICE_ATTRIBUTE_RES_X)) |
2094 | 110 | { | ||
2095 | 111 | input_device->priv->x_extents.resolution = a->float_val; | 96 | input_device->priv->x_extents.resolution = a->float_val; |
2096 | 112 | } | ||
2097 | 113 | else if (0 == g_strcmp0 (a->name, GEIS_DEVICE_ATTRIBUTE_MIN_Y)) | 97 | else if (0 == g_strcmp0 (a->name, GEIS_DEVICE_ATTRIBUTE_MIN_Y)) |
2098 | 114 | { | ||
2099 | 115 | input_device->priv->y_extents.minimum = a->float_val; | 98 | input_device->priv->y_extents.minimum = a->float_val; |
2100 | 116 | } | ||
2101 | 117 | else if (0 == g_strcmp0 (a->name, GEIS_DEVICE_ATTRIBUTE_MAX_Y)) | 99 | else if (0 == g_strcmp0 (a->name, GEIS_DEVICE_ATTRIBUTE_MAX_Y)) |
2102 | 118 | { | ||
2103 | 119 | input_device->priv->y_extents.maximum = a->float_val; | 100 | input_device->priv->y_extents.maximum = a->float_val; |
2104 | 120 | } | ||
2105 | 121 | else if (0 == g_strcmp0 (a->name, GEIS_DEVICE_ATTRIBUTE_RES_Y)) | 101 | else if (0 == g_strcmp0 (a->name, GEIS_DEVICE_ATTRIBUTE_RES_Y)) |
2106 | 122 | { | ||
2107 | 123 | input_device->priv->y_extents.resolution = a->float_val; | 102 | input_device->priv->y_extents.resolution = a->float_val; |
2108 | 124 | } | ||
2109 | 125 | } | 103 | } |
2110 | 126 | } | 104 | } |
2111 | 127 | } | 105 | } |
2112 | 128 | } | 106 | } |
2113 | 107 | else | ||
2114 | 108 | { | ||
2115 | 109 | guint num_attrs = geis_device_attr_count(input_device->priv->geis_device); | ||
2116 | 110 | for (i = 0; i < num_attrs; ++i) | ||
2117 | 111 | { | ||
2118 | 112 | GeisAttr attr = geis_device_attr(input_device->priv->geis_device, i); | ||
2119 | 113 | if (0 == g_strcmp0 (geis_attr_name(attr), GEIS_DEVICE_ATTRIBUTE_NAME)) | ||
2120 | 114 | input_device->priv->name = g_strdup (geis_attr_value_to_string(attr)); | ||
2121 | 115 | else if (0 == g_strcmp0 (geis_attr_name(attr), GEIS_DEVICE_ATTRIBUTE_ID)) | ||
2122 | 116 | input_device->priv->device_id = geis_attr_value_to_integer(attr); | ||
2123 | 117 | else if (0 == g_strcmp0 (geis_attr_name(attr), GEIS_DEVICE_ATTRIBUTE_TOUCHES)) | ||
2124 | 118 | input_device->priv->touches = geis_attr_value_to_integer(attr); | ||
2125 | 119 | else if (0 == g_strcmp0 (geis_attr_name(attr), GEIS_DEVICE_ATTRIBUTE_DIRECT_TOUCH)) | ||
2126 | 120 | input_device->priv->is_direct = geis_attr_value_to_boolean(attr); | ||
2127 | 121 | else if (0 == g_strcmp0 (geis_attr_name(attr), GEIS_DEVICE_ATTRIBUTE_INDEPENDENT_TOUCH)) | ||
2128 | 122 | input_device->priv->is_independent = geis_attr_value_to_boolean(attr); | ||
2129 | 123 | else if (0 == g_strcmp0 (geis_attr_name(attr), GEIS_DEVICE_ATTRIBUTE_MIN_X)) | ||
2130 | 124 | input_device->priv->x_extents.minimum = geis_attr_value_to_float(attr); | ||
2131 | 125 | else if (0 == g_strcmp0 (geis_attr_name(attr), GEIS_DEVICE_ATTRIBUTE_MAX_X)) | ||
2132 | 126 | input_device->priv->x_extents.maximum = geis_attr_value_to_float(attr); | ||
2133 | 127 | else if (0 == g_strcmp0 (geis_attr_name(attr), GEIS_DEVICE_ATTRIBUTE_RES_X)) | ||
2134 | 128 | input_device->priv->x_extents.resolution = geis_attr_value_to_float(attr); | ||
2135 | 129 | else if (0 == g_strcmp0 (geis_attr_name(attr), GEIS_DEVICE_ATTRIBUTE_MIN_Y)) | ||
2136 | 130 | input_device->priv->y_extents.minimum = geis_attr_value_to_float(attr); | ||
2137 | 131 | else if (0 == g_strcmp0 (geis_attr_name(attr), GEIS_DEVICE_ATTRIBUTE_MAX_Y)) | ||
2138 | 132 | input_device->priv->y_extents.maximum = geis_attr_value_to_float(attr); | ||
2139 | 133 | else if (0 == g_strcmp0 (geis_attr_name(attr), GEIS_DEVICE_ATTRIBUTE_RES_Y)) | ||
2140 | 134 | input_device->priv->y_extents.resolution = geis_attr_value_to_float(attr); | ||
2141 | 135 | } | ||
2142 | 136 | } | ||
2143 | 129 | 137 | ||
2144 | 130 | return object; | 138 | return object; |
2145 | 131 | } | 139 | } |
PASSED: Continuous integration, rev:78 jenkins. qa.ubuntu. com/job/ libgrip- ci/1/ jenkins. qa.ubuntu. com/job/ libgrip- raring- amd64-ci/ 1 jenkins. qa.ubuntu. com/job/ libgrip- raring- armhf-ci/ 1 jenkins. qa.ubuntu. com/job/ libgrip- raring- i386-ci/ 1
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins: 8080/job/ libgrip- ci/1/rebuild
http://