mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 01:20:42 -05:00
clutter: Add handle_event vfunc to ClutterAction
This will be the entry point for events into these actions. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2024>
This commit is contained in:
parent
0e57fd42e3
commit
7885f6dbcc
@ -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 */
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user