clutter/actions: Implement new sequence_cancelled vfunc
Now that we have more robust API to get notified about points that got cancelled, make use of it to cancel ClutterGestureActions and ClutterClickActions. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2342>
This commit is contained in:
parent
cf2d44d2c2
commit
9d1c212a04
@ -423,6 +423,19 @@ clutter_click_action_handle_event (ClutterAction *action,
|
|||||||
return priv->is_held ? CLUTTER_EVENT_STOP : CLUTTER_EVENT_PROPAGATE;
|
return priv->is_held ? CLUTTER_EVENT_STOP : CLUTTER_EVENT_PROPAGATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
clutter_click_action_sequence_cancelled (ClutterAction *action,
|
||||||
|
ClutterInputDevice *device,
|
||||||
|
ClutterEventSequence *sequence)
|
||||||
|
{
|
||||||
|
ClutterClickAction *self = CLUTTER_CLICK_ACTION (action);
|
||||||
|
ClutterClickActionPrivate *priv =
|
||||||
|
clutter_click_action_get_instance_private (self);
|
||||||
|
|
||||||
|
if (priv->press_device == device && priv->press_sequence == sequence)
|
||||||
|
clutter_click_action_release (self);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
clutter_click_action_set_actor (ClutterActorMeta *meta,
|
clutter_click_action_set_actor (ClutterActorMeta *meta,
|
||||||
ClutterActor *actor)
|
ClutterActor *actor)
|
||||||
@ -530,6 +543,7 @@ clutter_click_action_class_init (ClutterClickActionClass *klass)
|
|||||||
ClutterActionClass *action_class = CLUTTER_ACTION_CLASS (klass);
|
ClutterActionClass *action_class = CLUTTER_ACTION_CLASS (klass);
|
||||||
|
|
||||||
action_class->handle_event = clutter_click_action_handle_event;
|
action_class->handle_event = clutter_click_action_handle_event;
|
||||||
|
action_class->sequence_cancelled = clutter_click_action_sequence_cancelled;
|
||||||
|
|
||||||
meta_class->set_actor = clutter_click_action_set_actor;
|
meta_class->set_actor = clutter_click_action_set_actor;
|
||||||
meta_class->set_enabled = clutter_click_action_set_enabled;
|
meta_class->set_enabled = clutter_click_action_set_enabled;
|
||||||
|
@ -512,6 +512,38 @@ clutter_gesture_action_handle_event (ClutterAction *action,
|
|||||||
CLUTTER_EVENT_PROPAGATE;
|
CLUTTER_EVENT_PROPAGATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
clutter_gesture_action_sequence_cancelled (ClutterAction *action,
|
||||||
|
ClutterInputDevice *device,
|
||||||
|
ClutterEventSequence *sequence)
|
||||||
|
{
|
||||||
|
ClutterGestureAction *self = CLUTTER_GESTURE_ACTION (action);
|
||||||
|
ClutterGestureActionPrivate *priv =
|
||||||
|
clutter_gesture_action_get_instance_private (self);
|
||||||
|
int i, position = -1;
|
||||||
|
|
||||||
|
for (i = 0; i < priv->points->len; i++)
|
||||||
|
{
|
||||||
|
if ((g_array_index (priv->points, GesturePoint, i).device == device) &&
|
||||||
|
(g_array_index (priv->points, GesturePoint, i).sequence == sequence))
|
||||||
|
{
|
||||||
|
position = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (position == -1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (priv->in_gesture)
|
||||||
|
{
|
||||||
|
priv->in_gesture = FALSE;
|
||||||
|
cancel_gesture (self);
|
||||||
|
}
|
||||||
|
|
||||||
|
gesture_unregister_point (self, position);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
clutter_gesture_action_set_enabled (ClutterActorMeta *meta,
|
clutter_gesture_action_set_enabled (ClutterActorMeta *meta,
|
||||||
gboolean is_enabled)
|
gboolean is_enabled)
|
||||||
@ -642,6 +674,7 @@ clutter_gesture_action_class_init (ClutterGestureActionClass *klass)
|
|||||||
meta_class->set_enabled = clutter_gesture_action_set_enabled;
|
meta_class->set_enabled = clutter_gesture_action_set_enabled;
|
||||||
|
|
||||||
action_class->handle_event = clutter_gesture_action_handle_event;
|
action_class->handle_event = clutter_gesture_action_handle_event;
|
||||||
|
action_class->sequence_cancelled = clutter_gesture_action_sequence_cancelled;
|
||||||
|
|
||||||
klass->gesture_begin = default_event_handler;
|
klass->gesture_begin = default_event_handler;
|
||||||
klass->gesture_progress = default_event_handler;
|
klass->gesture_progress = default_event_handler;
|
||||||
|
Loading…
Reference in New Issue
Block a user