diff --git a/clutter/clutter/clutter-action-private.h b/clutter/clutter/clutter-action-private.h
new file mode 100644
index 000000000..638609b00
--- /dev/null
+++ b/clutter/clutter/clutter-action-private.h
@@ -0,0 +1,41 @@
+/*
+ * Clutter.
+ *
+ * An OpenGL based 'interactive canvas' library.
+ *
+ * Copyright (C) 2021 Red Hat Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see .
+ *
+ * Author:
+ * Carlos Garnacho
+ */
+
+#ifndef CLUTTER_ACTION_PRIVATE_H
+#define CLUTTER_ACTION_PRIVATE_H
+
+#if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
+#error "Only can be included directly."
+#endif
+
+#include
+
+G_BEGIN_DECLS
+
+void clutter_action_set_phase (ClutterAction *action,
+ ClutterEventPhase phase);
+
+G_END_DECLS
+
+#endif /* CLUTTER_ACTION_PRIVATE_H */
diff --git a/clutter/clutter/clutter-action.c b/clutter/clutter/clutter-action.c
index a3410f184..edf376048 100644
--- a/clutter/clutter/clutter-action.c
+++ b/clutter/clutter/clutter-action.c
@@ -44,11 +44,19 @@
#include "clutter-build-config.h"
#include "clutter-action.h"
-
+#include "clutter-action-private.h"
#include "clutter-debug.h"
#include "clutter-private.h"
-G_DEFINE_ABSTRACT_TYPE (ClutterAction, clutter_action, CLUTTER_TYPE_ACTOR_META);
+typedef struct _ClutterActionPrivate ClutterActionPrivate;
+
+struct _ClutterActionPrivate
+{
+ ClutterEventPhase phase;
+};
+
+G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (ClutterAction, clutter_action,
+ CLUTTER_TYPE_ACTOR_META)
static void
clutter_action_class_init (ClutterActionClass *klass)
@@ -59,3 +67,25 @@ static void
clutter_action_init (ClutterAction *self)
{
}
+
+void
+clutter_action_set_phase (ClutterAction *action,
+ ClutterEventPhase phase)
+{
+ ClutterActionPrivate *priv;
+
+ priv = clutter_action_get_instance_private (action);
+ priv->phase = phase;
+}
+
+ClutterEventPhase
+clutter_action_get_phase (ClutterAction *action)
+{
+ ClutterActionPrivate *priv;
+
+ g_return_val_if_fail (CLUTTER_IS_ACTION (action), CLUTTER_PHASE_CAPTURE);
+
+ priv = clutter_action_get_instance_private (action);
+
+ return priv->phase;
+}
diff --git a/clutter/clutter/clutter-action.h b/clutter/clutter/clutter-action.h
index 8e5ea6c30..8624ce932 100644
--- a/clutter/clutter/clutter-action.h
+++ b/clutter/clutter/clutter-action.h
@@ -70,6 +70,11 @@ void clutter_actor_add_action_with_name (ClutterActor *self,
const gchar *name,
ClutterAction *action);
CLUTTER_EXPORT
+void clutter_actor_add_action_full (ClutterActor *self,
+ const char *name,
+ ClutterEventPhase phase,
+ ClutterAction *action);
+CLUTTER_EXPORT
void clutter_actor_remove_action (ClutterActor *self,
ClutterAction *action);
CLUTTER_EXPORT
@@ -86,6 +91,8 @@ void clutter_actor_clear_actions (ClutterActor *self);
CLUTTER_EXPORT
gboolean clutter_actor_has_actions (ClutterActor *self);
+ClutterEventPhase clutter_action_get_phase (ClutterAction *action);
+
G_END_DECLS
#endif /* __CLUTTER_ACTION_H__ */
diff --git a/clutter/clutter/clutter-actor.c b/clutter/clutter/clutter-actor.c
index 1e495c5b3..d9c19c569 100644
--- a/clutter/clutter/clutter-actor.c
+++ b/clutter/clutter/clutter-actor.c
@@ -613,6 +613,7 @@
#include "clutter-actor-private.h"
#include "clutter-action.h"
+#include "clutter-action-private.h"
#include "clutter-actor-meta-private.h"
#include "clutter-animatable.h"
#include "clutter-color-static.h"
@@ -14665,6 +14666,27 @@ clutter_actor_has_allocation (ClutterActor *self)
!priv->needs_allocation;
}
+static void
+clutter_actor_add_action_internal (ClutterActor *self,
+ ClutterAction *action,
+ ClutterEventPhase phase)
+{
+ ClutterActorPrivate *priv;
+
+ priv = self->priv;
+
+ if (priv->actions == NULL)
+ {
+ priv->actions = g_object_new (CLUTTER_TYPE_META_GROUP, NULL);
+ priv->actions->actor = self;
+ }
+
+ clutter_action_set_phase (action, phase);
+ _clutter_meta_group_add_meta (priv->actions, CLUTTER_ACTOR_META (action));
+
+ g_object_notify_by_pspec (G_OBJECT (self), obj_props[PROP_ACTIONS]);
+}
+
/**
* clutter_actor_add_action:
* @self: a #ClutterActor
@@ -14684,22 +14706,10 @@ void
clutter_actor_add_action (ClutterActor *self,
ClutterAction *action)
{
- ClutterActorPrivate *priv;
-
g_return_if_fail (CLUTTER_IS_ACTOR (self));
g_return_if_fail (CLUTTER_IS_ACTION (action));
- priv = self->priv;
-
- if (priv->actions == NULL)
- {
- priv->actions = g_object_new (CLUTTER_TYPE_META_GROUP, NULL);
- priv->actions->actor = self;
- }
-
- _clutter_meta_group_add_meta (priv->actions, CLUTTER_ACTOR_META (action));
-
- g_object_notify_by_pspec (G_OBJECT (self), obj_props[PROP_ACTIONS]);
+ clutter_actor_add_action_internal (self, action, CLUTTER_PHASE_BUBBLE);
}
/**
@@ -14733,6 +14743,22 @@ clutter_actor_add_action_with_name (ClutterActor *self,
clutter_actor_add_action (self, action);
}
+void
+clutter_actor_add_action_full (ClutterActor *self,
+ const char *name,
+ ClutterEventPhase phase,
+ ClutterAction *action)
+{
+ g_return_if_fail (CLUTTER_IS_ACTOR (self));
+ g_return_if_fail (name != NULL);
+ g_return_if_fail (CLUTTER_IS_ACTION (action));
+ g_return_if_fail (phase == CLUTTER_PHASE_BUBBLE ||
+ phase == CLUTTER_PHASE_CAPTURE);
+
+ clutter_actor_meta_set_name (CLUTTER_ACTOR_META (action), name);
+ clutter_actor_add_action_internal (self, action, phase);
+}
+
/**
* clutter_actor_remove_action:
* @self: a #ClutterActor
diff --git a/clutter/clutter/clutter-enums.h b/clutter/clutter/clutter-enums.h
index a184d2d6f..0c889d148 100644
--- a/clutter/clutter/clutter-enums.h
+++ b/clutter/clutter/clutter-enums.h
@@ -1616,6 +1616,12 @@ typedef enum
CLUTTER_PREEDIT_RESET_COMMIT,
} ClutterPreeditResetMode;
+typedef enum
+{
+ CLUTTER_PHASE_CAPTURE,
+ CLUTTER_PHASE_BUBBLE,
+} ClutterEventPhase;
+
G_END_DECLS
#endif /* __CLUTTER_ENUMS_H__ */