[mutter/wip/carlosg/sanitize-gestures: 1/8] clutter: Add handle_event vfunc to ClutterAction
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/sanitize-gestures: 1/8] clutter: Add handle_event vfunc to ClutterAction
- Date: Thu, 28 Oct 2021 22:27:53 +0000 (UTC)
commit 7fc921bfb30fc9163a0e52a8b00f8f1973dad84d
Author: Carlos Garnacho <carlosg gnome org>
Date: Fri Jul 16 18:45:09 2021 +0200
clutter: Add handle_event vfunc to ClutterAction
This will be the entry point for events into these actions.
clutter/clutter/clutter-action-private.h | 3 +++
clutter/clutter/clutter-action.c | 15 ++++++++++++
clutter/clutter/clutter-action.h | 3 +++
clutter/clutter/clutter-actor.c | 39 ++++++++++++++++++++++++++++++++
4 files changed, 60 insertions(+)
---
diff --git a/clutter/clutter/clutter-action-private.h b/clutter/clutter/clutter-action-private.h
index 638609b004..510c21cd85 100644
--- a/clutter/clutter/clutter-action-private.h
+++ b/clutter/clutter/clutter-action-private.h
@@ -36,6 +36,9 @@ G_BEGIN_DECLS
void clutter_action_set_phase (ClutterAction *action,
ClutterEventPhase phase);
+gboolean clutter_action_handle_event (ClutterAction *action,
+ const ClutterEvent *event);
+
G_END_DECLS
#endif /* CLUTTER_ACTION_PRIVATE_H */
diff --git a/clutter/clutter/clutter-action.c b/clutter/clutter/clutter-action.c
index edf3760489..50eda35f25 100644
--- a/clutter/clutter/clutter-action.c
+++ b/clutter/clutter/clutter-action.c
@@ -58,9 +58,17 @@ struct _ClutterActionPrivate
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (ClutterAction, clutter_action,
CLUTTER_TYPE_ACTOR_META)
+static gboolean
+clutter_action_handle_event_default (ClutterAction *action,
+ const ClutterEvent *event)
+{
+ return FALSE;
+}
+
static void
clutter_action_class_init (ClutterActionClass *klass)
{
+ klass->handle_event = clutter_action_handle_event_default;
}
static void
@@ -89,3 +97,10 @@ clutter_action_get_phase (ClutterAction *action)
return priv->phase;
}
+
+gboolean
+clutter_action_handle_event (ClutterAction *action,
+ const ClutterEvent *event)
+{
+ return CLUTTER_ACTION_GET_CLASS (action)->handle_event (action, event);
+}
diff --git a/clutter/clutter/clutter-action.h b/clutter/clutter/clutter-action.h
index 8624ce9326..d38d2c63c3 100644
--- a/clutter/clutter/clutter-action.h
+++ b/clutter/clutter/clutter-action.h
@@ -51,6 +51,9 @@ struct _ClutterActionClass
/*< private >*/
ClutterActorMetaClass parent_class;
+ gboolean (* handle_event) (ClutterAction *action,
+ const ClutterEvent *event);
+
void (* _clutter_action1) (void);
void (* _clutter_action2) (void);
void (* _clutter_action3) (void);
diff --git a/clutter/clutter/clutter-actor.c b/clutter/clutter/clutter-actor.c
index d9c19c569f..6cbec0b70c 100644
--- a/clutter/clutter/clutter-actor.c
+++ b/clutter/clutter/clutter-actor.c
@@ -12230,6 +12230,38 @@ clutter_actor_set_child_at_index (ClutterActor *self,
* Event handling
*/
+static gboolean
+clutter_actor_run_actions (ClutterActor *self,
+ const ClutterEvent *event,
+ ClutterEventPhase phase)
+{
+ ClutterActorPrivate *priv;
+ const GList *actions, *l;
+ gboolean retval = CLUTTER_EVENT_PROPAGATE;
+
+ priv = self->priv;
+ if (!priv->actions)
+ return CLUTTER_EVENT_PROPAGATE;
+
+ actions = _clutter_meta_group_peek_metas (priv->actions);
+
+ for (l = actions; l; l = l->next)
+ {
+ ClutterAction *action = l->data;
+ ClutterEventPhase action_phase;
+
+ action_phase = clutter_action_get_phase (action);
+
+ if (action_phase == phase)
+ {
+ if (clutter_action_handle_event (action, event))
+ retval = CLUTTER_EVENT_STOP;
+ }
+ }
+
+ return retval;
+}
+
/**
* clutter_actor_event:
* @actor: a #ClutterActor
@@ -12251,6 +12283,7 @@ clutter_actor_event (ClutterActor *actor,
const ClutterEvent *event,
gboolean capture)
{
+ ClutterEventPhase phase;
gboolean retval = FALSE;
gint signal_num = -1;
GQuark detail = 0;
@@ -12260,6 +12293,11 @@ clutter_actor_event (ClutterActor *actor,
g_object_ref (actor);
+ phase = capture ? CLUTTER_PHASE_CAPTURE : CLUTTER_PHASE_BUBBLE;
+ retval = clutter_actor_run_actions (actor, event, phase);
+ if (retval)
+ goto handled;
+
switch (event->type)
{
case CLUTTER_NOTHING:
@@ -12342,6 +12380,7 @@ clutter_actor_event (ClutterActor *actor,
g_signal_emit (actor, actor_signals[signal_num], 0, event, &retval);
}
+ handled:
g_object_unref (actor);
return retval;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]