summaryrefslogtreecommitdiff
path: root/clutter
diff options
context:
space:
mode:
authorJonas Dreßler <verdre@v0yd.nl>2022-04-04 11:42:22 +0200
committerMarge Bot <marge-bot@gnome.org>2023-02-03 12:10:22 +0000
commit9d1c212a0485148c6ef0b504775309c7c3ade5dd (patch)
treed951539c969ab218bb1e6e8bd1339683b8504a34 /clutter
parentcf2d44d2c2c3c9c8a199a71ec009ba95170d40aa (diff)
downloadmutter-9d1c212a0485148c6ef0b504775309c7c3ade5dd.tar.gz
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>
Diffstat (limited to 'clutter')
-rw-r--r--clutter/clutter/clutter-click-action.c14
-rw-r--r--clutter/clutter/clutter-gesture-action.c33
2 files changed, 47 insertions, 0 deletions
diff --git a/clutter/clutter/clutter-click-action.c b/clutter/clutter/clutter-click-action.c
index 7af3f2e18..4e6b53630 100644
--- a/clutter/clutter/clutter-click-action.c
+++ b/clutter/clutter/clutter-click-action.c
@@ -424,6 +424,19 @@ clutter_click_action_handle_event (ClutterAction *action,
}
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
clutter_click_action_set_actor (ClutterActorMeta *meta,
ClutterActor *actor)
{
@@ -530,6 +543,7 @@ clutter_click_action_class_init (ClutterClickActionClass *klass)
ClutterActionClass *action_class = CLUTTER_ACTION_CLASS (klass);
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_enabled = clutter_click_action_set_enabled;
diff --git a/clutter/clutter/clutter-gesture-action.c b/clutter/clutter/clutter-gesture-action.c
index a09084aa8..d48e68358 100644
--- a/clutter/clutter/clutter-gesture-action.c
+++ b/clutter/clutter/clutter-gesture-action.c
@@ -513,6 +513,38 @@ clutter_gesture_action_handle_event (ClutterAction *action,
}
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
clutter_gesture_action_set_enabled (ClutterActorMeta *meta,
gboolean is_enabled)
{
@@ -642,6 +674,7 @@ clutter_gesture_action_class_init (ClutterGestureActionClass *klass)
meta_class->set_enabled = clutter_gesture_action_set_enabled;
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_progress = default_event_handler;