clutter: Move emitting events to ClutterActions to the stage
A fairly small refactor, move the emission of events to actions from clutter_actor_event() to stage level. We do this because in the future we'll need to know on stage level whether events were handled by an actor or by an action. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2342>
This commit is contained in:
parent
c6b3c90e41
commit
d795710a14
@ -11842,38 +11842,6 @@ 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
|
||||
@ -11893,7 +11861,6 @@ clutter_actor_event (ClutterActor *actor,
|
||||
const ClutterEvent *event,
|
||||
gboolean capture)
|
||||
{
|
||||
ClutterEventPhase phase;
|
||||
gboolean retval = FALSE;
|
||||
gint signal_num = -1;
|
||||
GQuark detail = 0;
|
||||
@ -11903,11 +11870,6 @@ 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:
|
||||
@ -11991,7 +11953,6 @@ clutter_actor_event (ClutterActor *actor,
|
||||
g_signal_emit (actor, actor_signals[signal_num], 0, event, &retval);
|
||||
}
|
||||
|
||||
handled:
|
||||
g_object_unref (actor);
|
||||
|
||||
if (event->type == CLUTTER_ENTER || event->type == CLUTTER_LEAVE)
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include "clutter-stage.h"
|
||||
#include "deprecated/clutter-container.h"
|
||||
|
||||
#include "clutter-action-private.h"
|
||||
#include "clutter-actor-private.h"
|
||||
#include "clutter-backend-private.h"
|
||||
#include "clutter-cairo.h"
|
||||
@ -3423,7 +3424,8 @@ create_crossing_event (ClutterStage *stage,
|
||||
typedef enum
|
||||
{
|
||||
EVENT_NOT_HANDLED,
|
||||
EVENT_HANDLED_BY_ACTOR
|
||||
EVENT_HANDLED_BY_ACTOR,
|
||||
EVENT_HANDLED_BY_ACTION
|
||||
} EventHandledState;
|
||||
|
||||
static EventHandledState
|
||||
@ -3431,11 +3433,26 @@ emit_event (const ClutterEvent *event,
|
||||
GPtrArray *actors)
|
||||
{
|
||||
int i;
|
||||
gboolean action_handled_event = FALSE;
|
||||
|
||||
/* Capture: from top-level downwards */
|
||||
for (i = actors->len - 1; i >= 0; i--)
|
||||
{
|
||||
ClutterActor *actor = g_ptr_array_index (actors, i);
|
||||
const GList *l;
|
||||
|
||||
for (l = clutter_actor_peek_actions (actor); l; l = l->next)
|
||||
{
|
||||
ClutterAction *action = l->data;
|
||||
|
||||
if (clutter_actor_meta_get_enabled (CLUTTER_ACTOR_META (action)) &&
|
||||
clutter_action_get_phase (action) == CLUTTER_PHASE_CAPTURE &&
|
||||
clutter_action_handle_event (action, event))
|
||||
action_handled_event = TRUE;
|
||||
}
|
||||
|
||||
if (action_handled_event)
|
||||
return EVENT_HANDLED_BY_ACTION;
|
||||
|
||||
if (clutter_actor_event (actor, event, TRUE))
|
||||
return EVENT_HANDLED_BY_ACTOR;
|
||||
@ -3445,6 +3462,20 @@ emit_event (const ClutterEvent *event,
|
||||
for (i = 0; i < actors->len; i++)
|
||||
{
|
||||
ClutterActor *actor = g_ptr_array_index (actors, i);
|
||||
const GList *l;
|
||||
|
||||
for (l = clutter_actor_peek_actions (actor); l; l = l->next)
|
||||
{
|
||||
ClutterAction *action = l->data;
|
||||
|
||||
if (clutter_actor_meta_get_enabled (CLUTTER_ACTOR_META (action)) &&
|
||||
clutter_action_get_phase (action) == CLUTTER_PHASE_BUBBLE &&
|
||||
clutter_action_handle_event (action, event))
|
||||
action_handled_event = TRUE;
|
||||
}
|
||||
|
||||
if (action_handled_event)
|
||||
return EVENT_HANDLED_BY_ACTION;
|
||||
|
||||
if (clutter_actor_event (actor, event, FALSE))
|
||||
return EVENT_HANDLED_BY_ACTOR;
|
||||
|
Loading…
x
Reference in New Issue
Block a user