gesture-action: Add API for cancelling a gesture

and getters for sequences and devices of current points. It can be
used for accepting and rejecting sequences for system-wide gestures.

https://bugzilla.gnome.org/show_bug.cgi?id=683090
This commit is contained in:
Tomeu Vizoso 2012-08-31 12:50:12 +02:00
parent 38b82cb22c
commit 2ef148a2c9
3 changed files with 126 additions and 26 deletions

View File

@ -185,8 +185,11 @@ cancel_gesture (ClutterGestureAction *action)
priv->in_gesture = FALSE;
g_signal_handler_disconnect (priv->stage, priv->stage_capture_id);
priv->stage_capture_id = 0;
if (priv->stage_capture_id != 0)
{
g_signal_handler_disconnect (priv->stage, priv->stage_capture_id);
priv->stage_capture_id = 0;
}
actor = clutter_actor_meta_get_actor (CLUTTER_ACTOR_META (action));
g_signal_emit (action, gesture_signals[GESTURE_CANCEL], 0, actor);
@ -800,3 +803,82 @@ clutter_gesture_action_set_n_touch_points (ClutterGestureAction *action,
}
}
}
/**
* clutter_gesture_action_get_n_current_points:
* @action: a #ClutterGestureAction
*
* Retrieves the number of points currently active.
*
* Return value: the number of points currently active.
*
* Since: 1.12
*/
guint
clutter_gesture_action_get_n_current_points (ClutterGestureAction *action)
{
g_return_val_if_fail (CLUTTER_IS_GESTURE_ACTION (action), 0);
return action->priv->points->len;
}
/**
* clutter_gesture_action_get_sequence:
* @action: a #ClutterGestureAction
* @point: index of a point currently active
*
* Retrieves the #ClutterEventSequence of a touch point.
*
* Return value: (transfer none): the #ClutterEventSequence of a touch point.
*
* Since: 1.12
*/
ClutterEventSequence *
clutter_gesture_action_get_sequence (ClutterGestureAction *action,
guint point)
{
g_return_val_if_fail (CLUTTER_IS_GESTURE_ACTION (action), NULL);
g_return_val_if_fail (action->priv->points->len > point, NULL);
return g_array_index (action->priv->points, GesturePoint, point).sequence;
}
/**
* clutter_gesture_action_get_device:
* @action: a #ClutterGestureAction
* @point: index of a point currently active
*
* Retrieves the #ClutterInputDevice of a touch point.
*
* Return value: (transfer none): the #ClutterInputDevice of a touch point.
*
* Since: 1.12
*/
ClutterInputDevice *
clutter_gesture_action_get_device (ClutterGestureAction *action,
guint point)
{
g_return_val_if_fail (CLUTTER_IS_GESTURE_ACTION (action), NULL);
g_return_val_if_fail (action->priv->points->len > point, NULL);
return g_array_index (action->priv->points, GesturePoint, point).device;
}
/**
* clutter_gesture_action_cancel:
* @action: a #ClutterGestureAction
*
* Cancel a #ClutterGestureAction before it begins
*
* Since: 1.12
*/
void
clutter_gesture_action_cancel (ClutterGestureAction *action)
{
g_return_if_fail (CLUTTER_IS_GESTURE_ACTION (action));
g_return_if_fail (!action->priv->in_gesture);
cancel_gesture (action);
g_array_set_size (action->priv->points, 0);
}

View File

@ -100,33 +100,47 @@ struct _ClutterGestureActionClass
GType clutter_gesture_action_get_type (void) G_GNUC_CONST;
ClutterAction * clutter_gesture_action_new (void);
ClutterAction * clutter_gesture_action_new (void);
gint clutter_gesture_action_get_n_touch_points (ClutterGestureAction *action);
void clutter_gesture_action_set_n_touch_points (ClutterGestureAction *action,
gint nb_points);
void clutter_gesture_action_get_press_coords (ClutterGestureAction *action,
guint device,
gfloat *press_x,
gfloat *press_y);
void clutter_gesture_action_get_motion_coords (ClutterGestureAction *action,
guint device,
gfloat *motion_x,
gfloat *motion_y);
gint clutter_gesture_action_get_n_touch_points (ClutterGestureAction *action);
void clutter_gesture_action_set_n_touch_points (ClutterGestureAction *action,
gint nb_points);
void clutter_gesture_action_get_press_coords (ClutterGestureAction *action,
guint device,
gfloat *press_x,
gfloat *press_y);
void clutter_gesture_action_get_motion_coords (ClutterGestureAction *action,
guint device,
gfloat *motion_x,
gfloat *motion_y);
CLUTTER_AVAILABLE_IN_1_12
gfloat clutter_gesture_action_get_motion_delta (ClutterGestureAction *action,
guint device,
gfloat *delta_x,
gfloat *delta_y);
void clutter_gesture_action_get_release_coords (ClutterGestureAction *action,
guint device,
gfloat *release_x,
gfloat *release_y);
gfloat clutter_gesture_action_get_motion_delta (ClutterGestureAction *action,
guint device,
gfloat *delta_x,
gfloat *delta_y);
void clutter_gesture_action_get_release_coords (ClutterGestureAction *action,
guint device,
gfloat *release_x,
gfloat *release_y);
CLUTTER_AVAILABLE_IN_1_12
gfloat clutter_gesture_action_get_velocity (ClutterGestureAction *action,
guint device,
gfloat *velocity_x,
gfloat *velocity_y);
gfloat clutter_gesture_action_get_velocity (ClutterGestureAction *action,
guint device,
gfloat *velocity_x,
gfloat *velocity_y);
CLUTTER_AVAILABLE_IN_1_12
guint clutter_gesture_action_get_n_current_points (ClutterGestureAction *action);
CLUTTER_AVAILABLE_IN_1_12
ClutterEventSequence * clutter_gesture_action_get_sequence (ClutterGestureAction *action,
guint point);
CLUTTER_AVAILABLE_IN_1_12
ClutterInputDevice * clutter_gesture_action_get_device (ClutterGestureAction *action,
guint point);
CLUTTER_AVAILABLE_IN_1_12
void clutter_gesture_action_cancel (ClutterGestureAction *action);
G_END_DECLS

View File

@ -733,11 +733,15 @@ clutter_gdk_set_stage_foreign
clutter_geometry_get_type
clutter_geometry_intersects
clutter_geometry_union
clutter_gesture_action_cancel
clutter_gesture_action_get_device
clutter_gesture_action_get_motion_coords
clutter_gesture_action_get_motion_delta
clutter_gesture_action_get_n_current_points
clutter_gesture_action_get_n_touch_points
clutter_gesture_action_get_press_coords
clutter_gesture_action_get_release_coords
clutter_gesture_action_get_sequence
clutter_gesture_action_get_type
clutter_gesture_action_get_velocity
clutter_gesture_action_set_n_touch_points