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
=== modified file 'examples/rectangle-mover/gesture.c'
--- examples/rectangle-mover/gesture.c 2010-11-17 13:56:49 +0000
+++ examples/rectangle-mover/gesture.c 2010-11-19 00:20:44 +0000
@@ -102,6 +102,9 @@
102 rotate += e->angle_delta * 100;102 rotate += e->angle_delta * 100;
103 }103 }
104 break;104 break;
105
106 case GROPE_GESTURE_TAP:
107 break;
105 }108 }
106 }109 }
107110
@@ -134,6 +137,13 @@
134 2,137 2,
135 gesture_callback,138 gesture_callback,
136 NULL, NULL);139 NULL, NULL);
140
141 grope_gesture_manager_register_window (manager,
142 window,
143 GROPE_GESTURE_TAP,
144 2,
145 gesture_callback,
146 NULL, NULL);
137}147}
138148
139static void149static void
140150
=== modified file 'src/gropegesturemanager.c'
--- src/gropegesturemanager.c 2010-11-15 16:05:03 +0000
+++ src/gropegesturemanager.c 2010-11-19 00:20:44 +0000
@@ -318,6 +318,45 @@
318 return touches;318 return touches;
319}319}
320320
321static gint
322tap_gesture_handle_properties (GropeEventGestureTap *event,
323 GeisSize attr_count,
324 GeisGestureAttr *attrs)
325{
326 gint i;
327 gint touches = 0;
328
329 for (i = 0; i < attr_count; ++i)
330 {
331 if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_TOUCHES) == 0 &&
332 attrs[i].type == GEIS_ATTR_TYPE_INTEGER)
333 {
334 touches = attrs[i].integer_val;
335 }
336 else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_TIMESTAMP) == 0 &&
337 attrs[i].type == GEIS_ATTR_TYPE_INTEGER)
338 {
339 event->timestamp = attrs[i].integer_val;
340 }
341 else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_POSITION_X) == 0 &&
342 attrs[i].type == GEIS_ATTR_TYPE_FLOAT)
343 {
344 event->position_x = attrs[i].float_val;
345 }
346 else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_POSITION_Y) == 0 &&
347 attrs[i].type == GEIS_ATTR_TYPE_FLOAT)
348 {
349 event->position_y = attrs[i].float_val;
350 }
351 else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_TAP_TIME) == 0 &&
352 attrs[i].type == GEIS_ATTR_TYPE_INTEGER)
353 {
354 event->tap_time = attrs[i].float_val;
355 }
356 }
357
358 return touches;
359}
321360
322static void361static void
323gesture_added (void *cookie,362gesture_added (void *cookie,
@@ -407,6 +446,24 @@
407 binding->data);446 binding->data);
408 }447 }
409 }448 }
449 else if (type == GROPE_GESTURE_TAP)
450 {
451 GropeEventGestureTap tap;
452
453 tap.type = type;
454 tap.id = id;
455 tap.fingers = tap_gesture_handle_properties (&tap,
456 attr_count,
457 attrs);
458
459 if (tap.fingers == binding->touches)
460 {
461 binding->callback (reg->window,
462 GROPE_TIME_START,
463 ((GropeGestureEvent*)&tap),
464 binding->data);
465 }
466 }
410467
411 return;468 return;
412 }469 }
@@ -483,6 +540,24 @@
483 binding->data);540 binding->data);
484 }541 }
485 }542 }
543 else if (type == GROPE_GESTURE_TAP)
544 {
545 GropeEventGestureTap tap;
546
547 tap.type = type;
548 tap.id = id;
549 tap.fingers = tap_gesture_handle_properties (&tap,
550 attr_count,
551 attrs);
552
553 if (tap.fingers == binding->touches)
554 {
555 binding->callback (reg->window,
556 GROPE_TIME_UPDATE,
557 ((GropeGestureEvent*)&tap),
558 binding->data);
559 }
560 }
486 }561 }
487 }562 }
488}563}
@@ -557,6 +632,24 @@
557 binding->data);632 binding->data);
558 }633 }
559 }634 }
635 else if (type == GROPE_GESTURE_TAP)
636 {
637 GropeEventGestureTap tap;
638
639 tap.type = type;
640 tap.id = id;
641 tap.fingers = tap_gesture_handle_properties (&tap,
642 attr_count,
643 attrs);
644
645 if (tap.fingers == binding->touches)
646 {
647 binding->callback (reg->window,
648 GROPE_TIME_END,
649 ((GropeGestureEvent*)&tap),
650 binding->data);
651 }
652 }
560 }653 }
561 }654 }
562}655}
563656
=== modified file 'src/gropegesturemanager.h'
--- src/gropegesturemanager.h 2010-11-12 20:27:52 +0000
+++ src/gropegesturemanager.h 2010-11-19 00:20:44 +0000
@@ -45,11 +45,13 @@
45typedef struct _GropeEventGestureDrag GropeEventGestureDrag;45typedef struct _GropeEventGestureDrag GropeEventGestureDrag;
46typedef struct _GropeEventGesturePinch GropeEventGesturePinch;46typedef struct _GropeEventGesturePinch GropeEventGesturePinch;
47typedef struct _GropeEventGestureRotate GropeEventGestureRotate;47typedef struct _GropeEventGestureRotate GropeEventGestureRotate;
48typedef struct _GropeEventGestureTap GropeEventGestureTap;
4849
49typedef enum {50typedef enum {
50 GROPE_GESTURE_DRAG,51 GROPE_GESTURE_DRAG = 0,
51 GROPE_GESTURE_PINCH,52 GROPE_GESTURE_PINCH = 1,
52 GROPE_GESTURE_ROTATE53 GROPE_GESTURE_ROTATE = 2,
54 GROPE_GESTURE_TAP = 15
53} GropeGestureType;55} GropeGestureType;
5456
55typedef enum {57typedef enum {
@@ -109,12 +111,28 @@
109 gdouble angle;111 gdouble angle;
110};112};
111113
114struct _GropeEventGestureTap
115{
116 GropeGestureType type;
117 guint id;
118 GdkWindow *window;
119 GdkWindow *root;
120 GdkWindow *child;
121 guint32 timestamp;
122 guint fingers;
123
124 guint32 tap_time;
125 gfloat position_x;
126 gfloat position_y;
127};
128
112union _GropeGestureEvent129union _GropeGestureEvent
113{130{
114 GropeGestureType type;131 GropeGestureType type;
115 GropeEventGestureDrag drag;132 GropeEventGestureDrag drag;
116 GropeEventGesturePinch pinch;133 GropeEventGesturePinch pinch;
117 GropeEventGestureRotate rotate;134 GropeEventGestureRotate rotate;
135 GropeEventGestureTap tap;
118};136};
119137
120/**138/**

Subscribers

People subscribed via source and target branches