mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 23:50:41 -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,
|
void clutter_action_set_phase (ClutterAction *action,
|
||||||
ClutterEventPhase phase);
|
ClutterEventPhase phase);
|
||||||
|
|
||||||
|
gboolean clutter_action_handle_event (ClutterAction *action,
|
||||||
|
const ClutterEvent *event);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* CLUTTER_ACTION_PRIVATE_H */
|
#endif /* CLUTTER_ACTION_PRIVATE_H */
|
||||||
|
@ -58,9 +58,17 @@ struct _ClutterActionPrivate
|
|||||||
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (ClutterAction, clutter_action,
|
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (ClutterAction, clutter_action,
|
||||||
CLUTTER_TYPE_ACTOR_META)
|
CLUTTER_TYPE_ACTOR_META)
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
clutter_action_handle_event_default (ClutterAction *action,
|
||||||
|
const ClutterEvent *event)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
clutter_action_class_init (ClutterActionClass *klass)
|
clutter_action_class_init (ClutterActionClass *klass)
|
||||||
{
|
{
|
||||||
|
klass->handle_event = clutter_action_handle_event_default;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -89,3 +97,10 @@ clutter_action_get_phase (ClutterAction *action)
|
|||||||
|
|
||||||
return priv->phase;
|
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 >*/
|
/*< private >*/
|
||||||
ClutterActorMetaClass parent_class;
|
ClutterActorMetaClass parent_class;
|
||||||
|
|
||||||
|
gboolean (* handle_event) (ClutterAction *action,
|
||||||
|
const ClutterEvent *event);
|
||||||
|
|
||||||
void (* _clutter_action1) (void);
|
void (* _clutter_action1) (void);
|
||||||
void (* _clutter_action2) (void);
|
void (* _clutter_action2) (void);
|
||||||
void (* _clutter_action3) (void);
|
void (* _clutter_action3) (void);
|
||||||
|
@ -12230,6 +12230,38 @@ clutter_actor_set_child_at_index (ClutterActor *self,
|
|||||||
* Event handling
|
* 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:
|
* clutter_actor_event:
|
||||||
* @actor: a #ClutterActor
|
* @actor: a #ClutterActor
|
||||||
@ -12251,6 +12283,7 @@ clutter_actor_event (ClutterActor *actor,
|
|||||||
const ClutterEvent *event,
|
const ClutterEvent *event,
|
||||||
gboolean capture)
|
gboolean capture)
|
||||||
{
|
{
|
||||||
|
ClutterEventPhase phase;
|
||||||
gboolean retval = FALSE;
|
gboolean retval = FALSE;
|
||||||
gint signal_num = -1;
|
gint signal_num = -1;
|
||||||
GQuark detail = 0;
|
GQuark detail = 0;
|
||||||
@ -12260,6 +12293,11 @@ clutter_actor_event (ClutterActor *actor,
|
|||||||
|
|
||||||
g_object_ref (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)
|
switch (event->type)
|
||||||
{
|
{
|
||||||
case CLUTTER_NOTHING:
|
case CLUTTER_NOTHING:
|
||||||
@ -12342,6 +12380,7 @@ clutter_actor_event (ClutterActor *actor,
|
|||||||
g_signal_emit (actor, actor_signals[signal_num], 0, event, &retval);
|
g_signal_emit (actor, actor_signals[signal_num], 0, event, &retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handled:
|
||||||
g_object_unref (actor);
|
g_object_unref (actor);
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
|
Loading…
Reference in New Issue
Block a user