clutter: Add information about event phase in ClutterActions
These will stick to a single phase, instead of juggling capture and bubble event handlers to do whatever they want. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2024>
This commit is contained in:
parent
2fc40da1cb
commit
0e57fd42e3
41
clutter/clutter/clutter-action-private.h
Normal file
41
clutter/clutter/clutter-action-private.h
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* Author:
|
||||||
|
* Carlos Garnacho <carlosg@gnome.org>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CLUTTER_ACTION_PRIVATE_H
|
||||||
|
#define CLUTTER_ACTION_PRIVATE_H
|
||||||
|
|
||||||
|
#if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
|
||||||
|
#error "Only <clutter/clutter.h> can be included directly."
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <clutter/clutter-action.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
void clutter_action_set_phase (ClutterAction *action,
|
||||||
|
ClutterEventPhase phase);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* CLUTTER_ACTION_PRIVATE_H */
|
@ -44,11 +44,19 @@
|
|||||||
#include "clutter-build-config.h"
|
#include "clutter-build-config.h"
|
||||||
|
|
||||||
#include "clutter-action.h"
|
#include "clutter-action.h"
|
||||||
|
#include "clutter-action-private.h"
|
||||||
#include "clutter-debug.h"
|
#include "clutter-debug.h"
|
||||||
#include "clutter-private.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
|
static void
|
||||||
clutter_action_class_init (ClutterActionClass *klass)
|
clutter_action_class_init (ClutterActionClass *klass)
|
||||||
@ -59,3 +67,25 @@ static void
|
|||||||
clutter_action_init (ClutterAction *self)
|
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;
|
||||||
|
}
|
||||||
|
@ -70,6 +70,11 @@ void clutter_actor_add_action_with_name (ClutterActor *self,
|
|||||||
const gchar *name,
|
const gchar *name,
|
||||||
ClutterAction *action);
|
ClutterAction *action);
|
||||||
CLUTTER_EXPORT
|
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,
|
void clutter_actor_remove_action (ClutterActor *self,
|
||||||
ClutterAction *action);
|
ClutterAction *action);
|
||||||
CLUTTER_EXPORT
|
CLUTTER_EXPORT
|
||||||
@ -86,6 +91,8 @@ void clutter_actor_clear_actions (ClutterActor *self);
|
|||||||
CLUTTER_EXPORT
|
CLUTTER_EXPORT
|
||||||
gboolean clutter_actor_has_actions (ClutterActor *self);
|
gboolean clutter_actor_has_actions (ClutterActor *self);
|
||||||
|
|
||||||
|
ClutterEventPhase clutter_action_get_phase (ClutterAction *action);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __CLUTTER_ACTION_H__ */
|
#endif /* __CLUTTER_ACTION_H__ */
|
||||||
|
@ -613,6 +613,7 @@
|
|||||||
#include "clutter-actor-private.h"
|
#include "clutter-actor-private.h"
|
||||||
|
|
||||||
#include "clutter-action.h"
|
#include "clutter-action.h"
|
||||||
|
#include "clutter-action-private.h"
|
||||||
#include "clutter-actor-meta-private.h"
|
#include "clutter-actor-meta-private.h"
|
||||||
#include "clutter-animatable.h"
|
#include "clutter-animatable.h"
|
||||||
#include "clutter-color-static.h"
|
#include "clutter-color-static.h"
|
||||||
@ -14665,6 +14666,27 @@ clutter_actor_has_allocation (ClutterActor *self)
|
|||||||
!priv->needs_allocation;
|
!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:
|
* clutter_actor_add_action:
|
||||||
* @self: a #ClutterActor
|
* @self: a #ClutterActor
|
||||||
@ -14684,22 +14706,10 @@ void
|
|||||||
clutter_actor_add_action (ClutterActor *self,
|
clutter_actor_add_action (ClutterActor *self,
|
||||||
ClutterAction *action)
|
ClutterAction *action)
|
||||||
{
|
{
|
||||||
ClutterActorPrivate *priv;
|
|
||||||
|
|
||||||
g_return_if_fail (CLUTTER_IS_ACTOR (self));
|
g_return_if_fail (CLUTTER_IS_ACTOR (self));
|
||||||
g_return_if_fail (CLUTTER_IS_ACTION (action));
|
g_return_if_fail (CLUTTER_IS_ACTION (action));
|
||||||
|
|
||||||
priv = self->priv;
|
clutter_actor_add_action_internal (self, action, CLUTTER_PHASE_BUBBLE);
|
||||||
|
|
||||||
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]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -14733,6 +14743,22 @@ clutter_actor_add_action_with_name (ClutterActor *self,
|
|||||||
clutter_actor_add_action (self, action);
|
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:
|
* clutter_actor_remove_action:
|
||||||
* @self: a #ClutterActor
|
* @self: a #ClutterActor
|
||||||
|
@ -1616,6 +1616,12 @@ typedef enum
|
|||||||
CLUTTER_PREEDIT_RESET_COMMIT,
|
CLUTTER_PREEDIT_RESET_COMMIT,
|
||||||
} ClutterPreeditResetMode;
|
} ClutterPreeditResetMode;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
CLUTTER_PHASE_CAPTURE,
|
||||||
|
CLUTTER_PHASE_BUBBLE,
|
||||||
|
} ClutterEventPhase;
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __CLUTTER_ENUMS_H__ */
|
#endif /* __CLUTTER_ENUMS_H__ */
|
||||||
|
Loading…
Reference in New Issue
Block a user