diff options
author | Cody Russell <crussell@canonical.com> | 2010-09-14 17:26:36 -0500 |
---|---|---|
committer | Cody Russell <crussell@canonical.com> | 2010-09-14 17:26:36 -0500 |
commit | 9aa08ce6f34cc9db361c58bb6bbc5da33eb4aed3 (patch) | |
tree | d63ea12523cf7eaa88c4a386e42375990a56fef2 /src | |
parent | f3ca63f0d411a477a5ccbb4faa4ab7c625705ffe (diff) | |
parent | 0a8cdd0815379bbbbb344863185a0b6628ce8e6a (diff) | |
download | ayatana-ido-9aa08ce6f34cc9db361c58bb6bbc5da33eb4aed3.tar.gz ayatana-ido-9aa08ce6f34cc9db361c58bb6bbc5da33eb4aed3.tar.bz2 ayatana-ido-9aa08ce6f34cc9db361c58bb6bbc5da33eb4aed3.zip |
Merge geis updates.
Diffstat (limited to 'src')
-rw-r--r-- | src/idogesturemanager.c | 320 | ||||
-rw-r--r-- | src/idogesturemanager.h | 29 |
2 files changed, 168 insertions, 181 deletions
diff --git a/src/idogesturemanager.c b/src/idogesturemanager.c index f603816..5225d10 100644 --- a/src/idogesturemanager.c +++ b/src/idogesturemanager.c @@ -39,6 +39,7 @@ struct _IdoGestureManagerPrivate struct _IdoGestureBinding { IdoGestureType type; + gint touches; IdoGestureCallback start; IdoGestureCallback update; IdoGestureCallback end; @@ -172,145 +173,169 @@ print_attr (GeisGestureAttr *attr) } */ -static void +static gint pinch_gesture_handle_properties (IdoEventGesturePinch *event, GeisSize attr_count, GeisGestureAttr *attrs) { gint i = 0; + gint touches = 0; for (i = 0; i < attr_count; ++i) { - if (g_strcmp0 (attrs[i].name, "timestamp") == 0 && + if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_FINGERS) == 0 && + attrs[i].type == GEIS_ATTR_TYPE_INTEGER) + { + touches = attrs[i].integer_val; + } + if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_TIMESTAMP) == 0 && attrs[i].type == GEIS_ATTR_TYPE_INTEGER) { event->timestamp = attrs[i].integer_val; } - else if (g_strcmp0 (attrs[i].name, "focus X") == 0 && + else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_FOCUS_X) == 0 && attrs[i].type == GEIS_ATTR_TYPE_FLOAT) { event->focus_x = attrs[i].float_val; } - else if (g_strcmp0 (attrs[i].name, "focus Y") == 0 && + else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_FOCUS_Y) == 0 && attrs[i].type == GEIS_ATTR_TYPE_FLOAT) { event->focus_y = attrs[i].float_val; } - else if (g_strcmp0 (attrs[i].name, "radius delta") == 0 && + else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_RADIUS_DELTA) == 0 && attrs[i].type == GEIS_ATTR_TYPE_FLOAT) { event->radius_delta = attrs[i].float_val; } - else if (g_strcmp0 (attrs[i].name, "radial velocity") == 0 && + else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_RADIAL_VELOCITY) == 0 && attrs[i].type == GEIS_ATTR_TYPE_FLOAT) { event->radial_velocity = attrs[i].float_val; } - else if (g_strcmp0 (attrs[i].name, "radius") == 0 && + else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_RADIUS) == 0 && attrs[i].type == GEIS_ATTR_TYPE_FLOAT) { event->radius = attrs[i].float_val; } } + + return touches; } -static void +static gint drag_gesture_handle_properties (IdoEventGestureDrag *event, GeisSize attr_count, GeisGestureAttr *attrs) { gint i; + gint touches = 0; for (i = 0; i < attr_count; ++i) { - if (g_strcmp0 (attrs[i].name, "timestamp") == 0 && + if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_FINGERS) == 0 && + attrs[i].type == GEIS_ATTR_TYPE_INTEGER) + { + touches = attrs[i].integer_val; + } + if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_TIMESTAMP) == 0 && attrs[i].type == GEIS_ATTR_TYPE_INTEGER) { event->timestamp = attrs[i].integer_val; } - else if (g_strcmp0 (attrs[i].name, "focus X") == 0 && + else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_FOCUS_X) == 0 && attrs[i].type == GEIS_ATTR_TYPE_FLOAT) { event->focus_x = attrs[i].float_val; } - else if (g_strcmp0 (attrs[i].name, "focus Y") == 0 && + else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_FOCUS_Y) == 0 && attrs[i].type == GEIS_ATTR_TYPE_FLOAT) { event->focus_y = attrs[i].float_val; } - else if (g_strcmp0 (attrs[i].name, "delta X") == 0 && + else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_DELTA_X) == 0 && attrs[i].type == GEIS_ATTR_TYPE_FLOAT) { event->delta_x = attrs[i].float_val; } - else if (g_strcmp0 (attrs[i].name, "delta Y") == 0 && + else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_DELTA_Y) == 0 && attrs[i].type == GEIS_ATTR_TYPE_FLOAT) { event->delta_y = attrs[i].float_val; } - else if (g_strcmp0 (attrs[i].name, "velocity X") == 0 && + else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_VELOCITY_X) == 0 && attrs[i].type == GEIS_ATTR_TYPE_FLOAT) { event->velocity_x = attrs[i].float_val; } - else if (g_strcmp0 (attrs[i].name, "velocity Y") == 0 && + else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_VELOCITY_Y) == 0 && attrs[i].type == GEIS_ATTR_TYPE_FLOAT) { event->velocity_y = attrs[i].float_val; } - else if (g_strcmp0 (attrs[i].name, "position X") == 0 && + else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_POSITION_X) == 0 && attrs[i].type == GEIS_ATTR_TYPE_FLOAT) { event->position_x = attrs[i].float_val; } - else if (g_strcmp0 (attrs[i].name, "position Y") == 0 && + else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_POSITION_Y) == 0 && attrs[i].type == GEIS_ATTR_TYPE_FLOAT) { event->position_y = attrs[i].float_val; } } + + return touches; } -static void +static gint rotate_gesture_handle_properties (IdoEventGestureRotate *event, GeisSize attr_count, GeisGestureAttr *attrs) { gint i; + gint touches = 0; for (i = 0; i < attr_count; ++i) { - if (g_strcmp0 (attrs[i].name, "timestamp") == 0 && + if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_FINGERS) == 0 && + attrs[i].type == GEIS_ATTR_TYPE_INTEGER) + { + touches = attrs[i].integer_val; + } + if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_TIMESTAMP) == 0 && attrs[i].type == GEIS_ATTR_TYPE_INTEGER) { event->timestamp = attrs[i].integer_val; } - else if (g_strcmp0 (attrs[i].name, "focus X") == 0 && + else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_FOCUS_X) == 0 && attrs[i].type == GEIS_ATTR_TYPE_FLOAT) { event->focus_x = attrs[i].float_val; } - else if (g_strcmp0 (attrs[i].name, "focus Y") == 0 && + else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_FOCUS_Y) == 0 && attrs[i].type == GEIS_ATTR_TYPE_FLOAT) { event->focus_y = attrs[i].float_val; } - else if (g_strcmp0 (attrs[i].name, "angle delta") == 0 && + else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_ANGLE_DELTA) == 0 && attrs[i].type == GEIS_ATTR_TYPE_FLOAT) { event->angle_delta = attrs[i].float_val; } - else if (g_strcmp0 (attrs[i].name, "angular velocity") == 0 && + else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_ANGULAR_VELOCITY) == 0 && attrs[i].type == GEIS_ATTR_TYPE_FLOAT) { event->angular_velocity = attrs[i].float_val; } - else if (g_strcmp0 (attrs[i].name, "angle") == 0 && + else if (g_strcmp0 (attrs[i].name, GEIS_GESTURE_ATTRIBUTE_ANGLE) == 0 && attrs[i].type == GEIS_ATTR_TYPE_FLOAT) { event->angle = attrs[i].float_val; } } + + return touches; } @@ -348,59 +373,53 @@ gesture_start (void *cookie, if (binding->type == type) { - if (type == IDO_GESTURE_DRAG1 || - type == IDO_GESTURE_DRAG2 || - type == IDO_GESTURE_DRAG3 || - type == IDO_GESTURE_DRAG4 || - type == IDO_GESTURE_DRAG5) + if (type == IDO_GESTURE_DRAG) { IdoEventGestureDrag drag; - drag.type = type; - drag.id = id; - - drag_gesture_handle_properties (&drag, - attr_count, - attrs); - - binding->start (reg->window, - ((IdoGestureEvent*)&drag)); + drag.type = type; + drag.id = id; + drag.fingers = drag_gesture_handle_properties (&drag, + attr_count, + attrs); + + if (drag.fingers == binding->touches) + { + binding->start (reg->window, + ((IdoGestureEvent*)&drag)); + } } - else if (type == IDO_GESTURE_PINCH1 || - type == IDO_GESTURE_PINCH2 || - type == IDO_GESTURE_PINCH3 || - type == IDO_GESTURE_PINCH4 || - type == IDO_GESTURE_PINCH5) + else if (type == IDO_GESTURE_PINCH) { IdoEventGesturePinch pinch; - pinch.type = type; - pinch.id = id; - - pinch_gesture_handle_properties (&pinch, - attr_count, - attrs); - - binding->start (reg->window, - ((IdoGestureEvent*)&pinch)); + pinch.type = type; + pinch.id = id; + pinch.fingers = pinch_gesture_handle_properties (&pinch, + attr_count, + attrs); + + if (pinch.fingers == binding->touches) + { + binding->start (reg->window, + ((IdoGestureEvent*)&pinch)); + } } - else if (type == IDO_GESTURE_ROTATE1 || - type == IDO_GESTURE_ROTATE2 || - type == IDO_GESTURE_ROTATE3 || - type == IDO_GESTURE_ROTATE4 || - type == IDO_GESTURE_ROTATE5) + else if (type == IDO_GESTURE_ROTATE) { IdoEventGestureRotate rotate; - rotate.type = type; - rotate.id = id; - - rotate_gesture_handle_properties (&rotate, - attr_count, - attrs); - - binding->start (reg->window, - ((IdoGestureEvent*)&rotate)); + rotate.type = type; + rotate.id = id; + rotate.fingers = rotate_gesture_handle_properties (&rotate, + attr_count, + attrs); + + if (rotate.fingers == binding->touches) + { + binding->start (reg->window, + ((IdoGestureEvent*)&rotate)); + } } return; @@ -424,59 +443,53 @@ gesture_update (void *cookie, if (binding->type == type) { - if (type == IDO_GESTURE_DRAG1 || - type == IDO_GESTURE_DRAG2 || - type == IDO_GESTURE_DRAG3 || - type == IDO_GESTURE_DRAG4 || - type == IDO_GESTURE_DRAG5) + if (type == IDO_GESTURE_DRAG) { IdoEventGestureDrag drag; - drag.type = type; - drag.id = id; - - drag_gesture_handle_properties (&drag, - attr_count, - attrs); - - binding->update (reg->window, - ((IdoGestureEvent*)&drag)); + drag.type = type; + drag.id = id; + drag.fingers = drag_gesture_handle_properties (&drag, + attr_count, + attrs); + + if (drag.fingers == binding->touches) + { + binding->update (reg->window, + ((IdoGestureEvent*)&drag)); + } } - else if (type == IDO_GESTURE_PINCH1 || - type == IDO_GESTURE_PINCH2 || - type == IDO_GESTURE_PINCH3 || - type == IDO_GESTURE_PINCH4 || - type == IDO_GESTURE_PINCH5) + else if (type == IDO_GESTURE_PINCH) { IdoEventGesturePinch pinch; - pinch.type = type; - pinch.id = id; - - pinch_gesture_handle_properties (&pinch, - attr_count, - attrs); - - binding->update (reg->window, - ((IdoGestureEvent*)&pinch)); + pinch.type = type; + pinch.id = id; + pinch.fingers = pinch_gesture_handle_properties (&pinch, + attr_count, + attrs); + + if (pinch.fingers == binding->touches) + { + binding->update (reg->window, + ((IdoGestureEvent*)&pinch)); + } } - else if (type == IDO_GESTURE_ROTATE1 || - type == IDO_GESTURE_ROTATE2 || - type == IDO_GESTURE_ROTATE3 || - type == IDO_GESTURE_ROTATE4 || - type == IDO_GESTURE_ROTATE5) + else if (type == IDO_GESTURE_ROTATE) { IdoEventGestureRotate rotate; - rotate.type = type; - rotate.id = id; - - rotate_gesture_handle_properties (&rotate, - attr_count, - attrs); - - binding->update (reg->window, - ((IdoGestureEvent*)&rotate)); + rotate.type = type; + rotate.id = id; + rotate.fingers = rotate_gesture_handle_properties (&rotate, + attr_count, + attrs); + + if (rotate.fingers == binding->touches) + { + binding->update (reg->window, + ((IdoGestureEvent*)&rotate)); + } } } } @@ -498,59 +511,53 @@ gesture_finish (void *cookie, if (binding->type == type) { - if (type == IDO_GESTURE_DRAG1 || - type == IDO_GESTURE_DRAG2 || - type == IDO_GESTURE_DRAG3 || - type == IDO_GESTURE_DRAG4 || - type == IDO_GESTURE_DRAG5) + if (type == IDO_GESTURE_DRAG) { IdoEventGestureDrag drag; - drag.type = type; - drag.id = id; - - drag_gesture_handle_properties (&drag, - attr_count, - attrs); - - binding->end (reg->window, - ((IdoGestureEvent*)&drag)); + drag.type = type; + drag.id = id; + drag.fingers = drag_gesture_handle_properties (&drag, + attr_count, + attrs); + + if (drag.fingers == binding->touches) + { + binding->end (reg->window, + ((IdoGestureEvent*)&drag)); + } } - else if (type == IDO_GESTURE_PINCH1 || - type == IDO_GESTURE_PINCH2 || - type == IDO_GESTURE_PINCH3 || - type == IDO_GESTURE_PINCH4 || - type == IDO_GESTURE_PINCH5) + else if (type == IDO_GESTURE_PINCH) { IdoEventGesturePinch pinch; - pinch.type = type; - pinch.id = id; - - pinch_gesture_handle_properties (&pinch, - attr_count, - attrs); - - binding->end (reg->window, - ((IdoGestureEvent*)&pinch)); + pinch.type = type; + pinch.id = id; + pinch.fingers = pinch_gesture_handle_properties (&pinch, + attr_count, + attrs); + + if (pinch.fingers == binding->touches) + { + binding->end (reg->window, + ((IdoGestureEvent*)&pinch)); + } } - else if (type == IDO_GESTURE_ROTATE1 || - type == IDO_GESTURE_ROTATE2 || - type == IDO_GESTURE_ROTATE3 || - type == IDO_GESTURE_ROTATE4 || - type == IDO_GESTURE_ROTATE5) + else if (type == IDO_GESTURE_ROTATE) { IdoEventGestureRotate rotate; - rotate.type = type; - rotate.id = id; - - rotate_gesture_handle_properties (&rotate, - attr_count, - attrs); - - binding->end (reg->window, - ((IdoGestureEvent*)&rotate)); + rotate.type = type; + rotate.id = id; + rotate.fingers = rotate_gesture_handle_properties (&rotate, + attr_count, + attrs); + + if (rotate.fingers == binding->touches) + { + binding->end (reg->window, + ((IdoGestureEvent*)&rotate)); + } } } } @@ -589,6 +596,7 @@ ido_gesture_manager_get (void) * ido_gesture_manager_register_window: * @window: A #GtkWindow to register the gesture event for. * @gesture_type: The type of gesture event to register. + * @touch_points: Number of touch points for this gesture. * @start: Called when a user initiates a gesture. * @update: Called each time the user updates the gesture. * @end: Called when the user ends the gesture. @@ -602,6 +610,7 @@ void ido_gesture_manager_register_window (IdoGestureManager *manager, GtkWindow *window, IdoGestureType gesture_type, + gint touch_points, IdoGestureCallback start, IdoGestureCallback update, IdoGestureCallback end) @@ -673,12 +682,11 @@ ido_gesture_manager_register_window (IdoGestureManager *manager, /* XXX - check for duplicates in reg->bindings first */ binding = g_new0 (IdoGestureBinding, 1); - g_print (" *** Adding binding type %d\n", (gint)gesture_type); - - binding->type = gesture_type; - binding->start = start; - binding->update = update; - binding->end = end; + binding->type = gesture_type; + binding->touches = touch_points; + binding->start = start; + binding->update = update; + binding->end = end; reg->bindings = g_list_append (reg->bindings, binding); diff --git a/src/idogesturemanager.h b/src/idogesturemanager.h index bc3ad33..87e5fe8 100644 --- a/src/idogesturemanager.h +++ b/src/idogesturemanager.h @@ -47,31 +47,9 @@ typedef struct _IdoEventGesturePinch IdoEventGesturePinch; typedef struct _IdoEventGestureRotate IdoEventGestureRotate; typedef enum { - IDO_GESTURE_DRAG1, - IDO_GESTURE_PINCH1, - IDO_GESTURE_ROTATE1, - - IDO_GESTURE_DRAG2, - IDO_GESTURE_PINCH2, - IDO_GESTURE_ROTATE2, - - IDO_GESTURE_DRAG3, - IDO_GESTURE_PINCH3, - IDO_GESTURE_ROTATE3, - - IDO_GESTURE_DRAG4, - IDO_GESTURE_PINCH4, - IDO_GESTURE_ROTATE4, - - IDO_GESTURE_DRAG5, - IDO_GESTURE_PINCH5, - IDO_GESTURE_ROTATE5, - - IDO_GESTURE_TAP1, - IDO_GESTURE_TAP2, - IDO_GESTURE_TAP3, - IDO_GESTURE_TAP4, - IDO_GESTURE_TAP5 + IDO_GESTURE_DRAG, + IDO_GESTURE_PINCH, + IDO_GESTURE_ROTATE } IdoGestureType; struct _IdoEventGestureDrag @@ -153,6 +131,7 @@ IdoGestureManager *ido_gesture_manager_get (void); void ido_gesture_manager_register_window (IdoGestureManager *manager, GtkWindow *window, IdoGestureType gesture_type, + gint touch_points, IdoGestureCallback start, IdoGestureCallback update, IdoGestureCallback end); |