Merge lp:~bratsche/libgrope/rap-tap-tapping into lp:libgrope

Proposed by Cody Russell
Status: Merged
Merged at revision: 10
Proposed branch: lp:~bratsche/libgrope/rap-tap-tapping
Merge into: lp:libgrope
Diff against target: 202 lines (+124/-3)
3 files modified
examples/rectangle-mover/gesture.c (+10/-0)
src/gropegesturemanager.c (+93/-0)
src/gropegesturemanager.h (+21/-3)
To merge this branch: bzr merge lp:~bratsche/libgrope/rap-tap-tapping
Reviewer Review Type Date Requested Status
Stephen M. Webb (community) Approve
Review via email: mp+41237@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Stephen M. Webb (bregma) wrote :

Patch builds without including <grail-types.h> in src/gropegesturemanager.c. Are you sure you need this (and the extra build dependency)?

review: Needs Information
Revision history for this message
Cody Russell (bratsche) wrote :

Thanks, fixed.

10. By Cody Russell

Remove #include <grail-types.h>

Revision history for this message
Stephen M. Webb (bregma) wrote :

OK, looks great.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'examples/rectangle-mover/gesture.c'
2--- examples/rectangle-mover/gesture.c 2010-11-17 13:56:49 +0000
3+++ examples/rectangle-mover/gesture.c 2010-11-19 00:20:44 +0000
4@@ -102,6 +102,9 @@
5 rotate += e->angle_delta * 100;
6 }
7 break;
8+
9+ case GROPE_GESTURE_TAP:
10+ break;
11 }
12 }
13
14@@ -134,6 +137,13 @@
15 2,
16 gesture_callback,
17 NULL, NULL);
18+
19+ grope_gesture_manager_register_window (manager,
20+ window,
21+ GROPE_GESTURE_TAP,
22+ 2,
23+ gesture_callback,
24+ NULL, NULL);
25 }
26
27 static void
28
29=== modified file 'src/gropegesturemanager.c'
30--- src/gropegesturemanager.c 2010-11-15 16:05:03 +0000
31+++ src/gropegesturemanager.c 2010-11-19 00:20:44 +0000
32@@ -318,6 +318,45 @@
33 return touches;
34 }
35
36+static gint
37+tap_gesture_handle_properties (GropeEventGestureTap *event,
38+ GeisSize attr_count,
39+ GeisGestureAttr *attrs)
40+{
41+ gint i;
42+ gint touches = 0;
43+
44+ for (i = 0; i < attr_count; ++i)
45+ {
46+ if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_TOUCHES) == 0 &&
47+ attrs[i].type == GEIS_ATTR_TYPE_INTEGER)
48+ {
49+ touches = attrs[i].integer_val;
50+ }
51+ else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_TIMESTAMP) == 0 &&
52+ attrs[i].type == GEIS_ATTR_TYPE_INTEGER)
53+ {
54+ event->timestamp = attrs[i].integer_val;
55+ }
56+ else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_POSITION_X) == 0 &&
57+ attrs[i].type == GEIS_ATTR_TYPE_FLOAT)
58+ {
59+ event->position_x = attrs[i].float_val;
60+ }
61+ else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_POSITION_Y) == 0 &&
62+ attrs[i].type == GEIS_ATTR_TYPE_FLOAT)
63+ {
64+ event->position_y = attrs[i].float_val;
65+ }
66+ else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_TAP_TIME) == 0 &&
67+ attrs[i].type == GEIS_ATTR_TYPE_INTEGER)
68+ {
69+ event->tap_time = attrs[i].float_val;
70+ }
71+ }
72+
73+ return touches;
74+}
75
76 static void
77 gesture_added (void *cookie,
78@@ -407,6 +446,24 @@
79 binding->data);
80 }
81 }
82+ else if (type == GROPE_GESTURE_TAP)
83+ {
84+ GropeEventGestureTap tap;
85+
86+ tap.type = type;
87+ tap.id = id;
88+ tap.fingers = tap_gesture_handle_properties (&tap,
89+ attr_count,
90+ attrs);
91+
92+ if (tap.fingers == binding->touches)
93+ {
94+ binding->callback (reg->window,
95+ GROPE_TIME_START,
96+ ((GropeGestureEvent*)&tap),
97+ binding->data);
98+ }
99+ }
100
101 return;
102 }
103@@ -483,6 +540,24 @@
104 binding->data);
105 }
106 }
107+ else if (type == GROPE_GESTURE_TAP)
108+ {
109+ GropeEventGestureTap tap;
110+
111+ tap.type = type;
112+ tap.id = id;
113+ tap.fingers = tap_gesture_handle_properties (&tap,
114+ attr_count,
115+ attrs);
116+
117+ if (tap.fingers == binding->touches)
118+ {
119+ binding->callback (reg->window,
120+ GROPE_TIME_UPDATE,
121+ ((GropeGestureEvent*)&tap),
122+ binding->data);
123+ }
124+ }
125 }
126 }
127 }
128@@ -557,6 +632,24 @@
129 binding->data);
130 }
131 }
132+ else if (type == GROPE_GESTURE_TAP)
133+ {
134+ GropeEventGestureTap tap;
135+
136+ tap.type = type;
137+ tap.id = id;
138+ tap.fingers = tap_gesture_handle_properties (&tap,
139+ attr_count,
140+ attrs);
141+
142+ if (tap.fingers == binding->touches)
143+ {
144+ binding->callback (reg->window,
145+ GROPE_TIME_END,
146+ ((GropeGestureEvent*)&tap),
147+ binding->data);
148+ }
149+ }
150 }
151 }
152 }
153
154=== modified file 'src/gropegesturemanager.h'
155--- src/gropegesturemanager.h 2010-11-12 20:27:52 +0000
156+++ src/gropegesturemanager.h 2010-11-19 00:20:44 +0000
157@@ -45,11 +45,13 @@
158 typedef struct _GropeEventGestureDrag GropeEventGestureDrag;
159 typedef struct _GropeEventGesturePinch GropeEventGesturePinch;
160 typedef struct _GropeEventGestureRotate GropeEventGestureRotate;
161+typedef struct _GropeEventGestureTap GropeEventGestureTap;
162
163 typedef enum {
164- GROPE_GESTURE_DRAG,
165- GROPE_GESTURE_PINCH,
166- GROPE_GESTURE_ROTATE
167+ GROPE_GESTURE_DRAG = 0,
168+ GROPE_GESTURE_PINCH = 1,
169+ GROPE_GESTURE_ROTATE = 2,
170+ GROPE_GESTURE_TAP = 15
171 } GropeGestureType;
172
173 typedef enum {
174@@ -109,12 +111,28 @@
175 gdouble angle;
176 };
177
178+struct _GropeEventGestureTap
179+{
180+ GropeGestureType type;
181+ guint id;
182+ GdkWindow *window;
183+ GdkWindow *root;
184+ GdkWindow *child;
185+ guint32 timestamp;
186+ guint fingers;
187+
188+ guint32 tap_time;
189+ gfloat position_x;
190+ gfloat position_y;
191+};
192+
193 union _GropeGestureEvent
194 {
195 GropeGestureType type;
196 GropeEventGestureDrag drag;
197 GropeEventGesturePinch pinch;
198 GropeEventGestureRotate rotate;
199+ GropeEventGestureTap tap;
200 };
201
202 /**

Subscribers

People subscribed via source and target branches