Clean up the private flags for ClutterActor

Provide macros to quickly query a flag, and remove all namespacing
except the initial 'CLUTTER'.
This commit is contained in:
Emmanuele Bassi 2010-07-21 16:10:46 +01:00
parent 0dfbf010b8
commit eae4561929
13 changed files with 98 additions and 107 deletions

View File

@ -676,11 +676,11 @@ clutter_actor_verify_map_state (ClutterActor *self)
/* all bets are off during reparent when we're potentially realized, /* all bets are off during reparent when we're potentially realized,
* but should not be according to invariants * but should not be according to invariants
*/ */
if (!(CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_ACTOR_IN_REPARENT)) if (!CLUTTER_ACTOR_IN_REPARENT (self))
{ {
if (priv->parent_actor == NULL) if (priv->parent_actor == NULL)
{ {
if (CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_ACTOR_IS_TOPLEVEL) if (CLUTTER_ACTOR_IS_TOPLEVEL (self))
{ {
} }
else else
@ -706,14 +706,14 @@ clutter_actor_verify_map_state (ClutterActor *self)
/* remaining bets are off during reparent when we're potentially /* remaining bets are off during reparent when we're potentially
* mapped, but should not be according to invariants * mapped, but should not be according to invariants
*/ */
if (!(CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_ACTOR_IN_REPARENT)) if (!CLUTTER_ACTOR_IN_REPARENT (self))
{ {
if (priv->parent_actor == NULL) if (priv->parent_actor == NULL)
{ {
if (CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_ACTOR_IS_TOPLEVEL) if (CLUTTER_ACTOR_IS_TOPLEVEL (self))
{ {
if (!CLUTTER_ACTOR_IS_VISIBLE (self) && if (!CLUTTER_ACTOR_IS_VISIBLE (self) &&
!(CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_ACTOR_IN_DESTRUCTION)) !CLUTTER_ACTOR_IN_DESTRUCTION (self))
{ {
g_warning ("Toplevel actor '%s' is mapped " g_warning ("Toplevel actor '%s' is mapped "
"but not visible", "but not visible",
@ -759,8 +759,7 @@ clutter_actor_verify_map_state (ClutterActor *self)
get_actor_debug_name (priv->parent_actor)); get_actor_debug_name (priv->parent_actor));
} }
if (!(CLUTTER_PRIVATE_FLAGS (priv->parent_actor) & if (!CLUTTER_ACTOR_IS_TOPLEVEL (priv->parent_actor))
CLUTTER_ACTOR_IS_TOPLEVEL))
{ {
if (!CLUTTER_ACTOR_IS_MAPPED (priv->parent_actor)) if (!CLUTTER_ACTOR_IS_MAPPED (priv->parent_actor))
g_warning ("Actor '%s' is mapped but its non-toplevel " g_warning ("Actor '%s' is mapped but its non-toplevel "
@ -805,7 +804,7 @@ clutter_actor_update_map_state (ClutterActor *self,
was_mapped = CLUTTER_ACTOR_IS_MAPPED (self); was_mapped = CLUTTER_ACTOR_IS_MAPPED (self);
if (CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_ACTOR_IS_TOPLEVEL) if (CLUTTER_ACTOR_IS_TOPLEVEL (self))
{ {
/* the mapped flag on top-level actors must be set by the /* the mapped flag on top-level actors must be set by the
* per-backend implementation because it might be asynchronous. * per-backend implementation because it might be asynchronous.
@ -855,7 +854,7 @@ clutter_actor_update_map_state (ClutterActor *self,
if (CLUTTER_ACTOR_IS_MAPPED (self) && if (CLUTTER_ACTOR_IS_MAPPED (self) &&
!CLUTTER_ACTOR_IS_VISIBLE (self) && !CLUTTER_ACTOR_IS_VISIBLE (self) &&
!(CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_ACTOR_IN_DESTRUCTION)) !CLUTTER_ACTOR_IN_DESTRUCTION (self))
{ {
g_warning ("Clutter toplevel of type '%s' is not visible, but " g_warning ("Clutter toplevel of type '%s' is not visible, but "
"it is somehow still mapped", "it is somehow still mapped",
@ -914,8 +913,7 @@ clutter_actor_update_map_state (ClutterActor *self,
gboolean parent_is_visible_realized_toplevel; gboolean parent_is_visible_realized_toplevel;
parent_is_visible_realized_toplevel = parent_is_visible_realized_toplevel =
(((CLUTTER_PRIVATE_FLAGS (parent) & (CLUTTER_ACTOR_IS_TOPLEVEL (parent) &&
CLUTTER_ACTOR_IS_TOPLEVEL) != 0) &&
CLUTTER_ACTOR_IS_VISIBLE (parent) && CLUTTER_ACTOR_IS_VISIBLE (parent) &&
CLUTTER_ACTOR_IS_REALIZED (parent)); CLUTTER_ACTOR_IS_REALIZED (parent));
@ -967,11 +965,8 @@ clutter_actor_update_map_state (ClutterActor *self,
*/ */
/* Unmap */ /* Unmap */
if (!should_be_mapped && if (!should_be_mapped && !CLUTTER_ACTOR_IN_REPARENT (self))
!(CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_ACTOR_IN_REPARENT)) clutter_actor_set_mapped (self, FALSE);
{
clutter_actor_set_mapped (self, FALSE);
}
/* Realize */ /* Realize */
if (must_be_realized) if (must_be_realized)
@ -981,8 +976,7 @@ clutter_actor_update_map_state (ClutterActor *self,
g_assert (!(must_be_realized && !may_be_realized)); g_assert (!(must_be_realized && !may_be_realized));
/* Unrealize */ /* Unrealize */
if (!may_be_realized && if (!may_be_realized && !CLUTTER_ACTOR_IN_REPARENT (self))
!(CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_ACTOR_IN_REPARENT))
clutter_actor_unrealize_not_hiding (self); clutter_actor_unrealize_not_hiding (self);
/* Map */ /* Map */
@ -1078,7 +1072,7 @@ clutter_actor_real_unmap (ClutterActor *self)
g_object_notify (G_OBJECT (self), "mapped"); g_object_notify (G_OBJECT (self), "mapped");
/* relinquish keyboard focus if we were unmapped while owning it */ /* relinquish keyboard focus if we were unmapped while owning it */
if (!(CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_ACTOR_IS_TOPLEVEL)) if (!CLUTTER_ACTOR_IS_TOPLEVEL (self))
{ {
ClutterActor *stage; ClutterActor *stage;
@ -1353,7 +1347,7 @@ clutter_actor_realize (ClutterActor *self)
if (priv->parent_actor != NULL) if (priv->parent_actor != NULL)
clutter_actor_realize (priv->parent_actor); clutter_actor_realize (priv->parent_actor);
if (CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_ACTOR_IS_TOPLEVEL) if (CLUTTER_ACTOR_IS_TOPLEVEL (self))
{ {
/* toplevels can be realized at any time */ /* toplevels can be realized at any time */
} }
@ -1762,7 +1756,7 @@ clutter_actor_queue_redraw_with_origin (ClutterActor *self,
ClutterActor *origin) ClutterActor *origin)
{ {
/* no point in queuing a redraw on a destroyed actor */ /* no point in queuing a redraw on a destroyed actor */
if (CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_ACTOR_IN_DESTRUCTION) if (CLUTTER_ACTOR_IN_DESTRUCTION (self))
return; return;
/* NB: We can't bail out early here if the actor is hidden in case /* NB: We can't bail out early here if the actor is hidden in case
@ -1786,7 +1780,7 @@ clutter_actor_real_queue_redraw (ClutterActor *self,
: "same actor"); : "same actor");
/* no point in queuing a redraw on a destroyed actor */ /* no point in queuing a redraw on a destroyed actor */
if (CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_ACTOR_IN_DESTRUCTION) if (CLUTTER_ACTOR_IN_DESTRUCTION (self))
return; return;
/* If the actor isn't visible, we still had to emit the signal /* If the actor isn't visible, we still had to emit the signal
@ -1831,7 +1825,7 @@ clutter_actor_real_queue_relayout (ClutterActor *self)
ClutterActorPrivate *priv = self->priv; ClutterActorPrivate *priv = self->priv;
/* no point in queueing a redraw on a destroyed actor */ /* no point in queueing a redraw on a destroyed actor */
if (CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_ACTOR_IN_DESTRUCTION) if (CLUTTER_ACTOR_IN_DESTRUCTION (self))
return; return;
priv->needs_width_request = TRUE; priv->needs_width_request = TRUE;
@ -2661,7 +2655,7 @@ clutter_actor_paint (ClutterActor *self)
* actors with 0 opacity to be a NOP... */ * actors with 0 opacity to be a NOP... */
if (context->pick_mode == CLUTTER_PICK_NONE && if (context->pick_mode == CLUTTER_PICK_NONE &&
/* ignore top-levels, since they might be transparent */ /* ignore top-levels, since they might be transparent */
!(CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_ACTOR_IS_TOPLEVEL) && !CLUTTER_ACTOR_IS_TOPLEVEL (self) &&
/* If the actor is being painted from a clone then check the /* If the actor is being painted from a clone then check the
clone's opacity instead */ clone's opacity instead */
(priv->opacity_parent ? priv->opacity_parent->priv : priv)->opacity == 0) (priv->opacity_parent ? priv->opacity_parent->priv : priv)->opacity == 0)
@ -2677,7 +2671,7 @@ clutter_actor_paint (ClutterActor *self)
return; return;
/* mark that we are in the paint process */ /* mark that we are in the paint process */
CLUTTER_SET_PRIVATE_FLAGS (self, CLUTTER_ACTOR_IN_PAINT); CLUTTER_SET_PRIVATE_FLAGS (self, CLUTTER_IN_PAINT);
cogl_push_matrix(); cogl_push_matrix();
@ -2743,7 +2737,7 @@ clutter_actor_paint (ClutterActor *self)
cogl_pop_matrix(); cogl_pop_matrix();
/* paint sequence complete */ /* paint sequence complete */
CLUTTER_UNSET_PRIVATE_FLAGS (self, CLUTTER_ACTOR_IN_PAINT); CLUTTER_UNSET_PRIVATE_FLAGS (self, CLUTTER_IN_PAINT);
} }
/* internal helper function set the rotation angle without affecting /* internal helper function set the rotation angle without affecting
@ -3351,7 +3345,7 @@ clutter_actor_dispose (GObject *object)
* is an internal child and has been marked as such * is an internal child and has been marked as such
*/ */
if (CLUTTER_IS_CONTAINER (parent) && if (CLUTTER_IS_CONTAINER (parent) &&
!(CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_ACTOR_INTERNAL_CHILD)) !CLUTTER_ACTOR_IS_INTERNAL_CHILD (self))
{ {
clutter_container_remove_actor (CLUTTER_CONTAINER (parent), self); clutter_container_remove_actor (CLUTTER_CONTAINER (parent), self);
} }
@ -3362,7 +3356,7 @@ clutter_actor_dispose (GObject *object)
/* parent should be gone */ /* parent should be gone */
g_assert (priv->parent_actor == NULL); g_assert (priv->parent_actor == NULL);
if (!(CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_ACTOR_IS_TOPLEVEL)) if (!CLUTTER_ACTOR_IS_TOPLEVEL (self))
{ {
/* can't be mapped or realized with no parent */ /* can't be mapped or realized with no parent */
g_assert (!CLUTTER_ACTOR_IS_MAPPED (self)); g_assert (!CLUTTER_ACTOR_IS_MAPPED (self));
@ -4900,19 +4894,19 @@ clutter_actor_destroy (ClutterActor *self)
g_object_ref (self); g_object_ref (self);
/* avoid recursion while destroying */ /* avoid recursion while destroying */
if (!(CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_ACTOR_IN_DESTRUCTION)) if (!CLUTTER_ACTOR_IN_DESTRUCTION (self))
{ {
CLUTTER_SET_PRIVATE_FLAGS (self, CLUTTER_ACTOR_IN_DESTRUCTION); CLUTTER_SET_PRIVATE_FLAGS (self, CLUTTER_IN_DESTRUCTION);
/* if we are destroying we want to unrealize ourselves /* if we are destroying we want to unrealize ourselves
* first before the dispose run removes the parent * first before the dispose run removes the parent
*/ */
if (!(CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_ACTOR_IS_TOPLEVEL)) if (!CLUTTER_ACTOR_IS_TOPLEVEL (self))
clutter_actor_update_map_state (self, MAP_STATE_MAKE_UNREALIZED); clutter_actor_update_map_state (self, MAP_STATE_MAKE_UNREALIZED);
g_object_run_dispose (G_OBJECT (self)); g_object_run_dispose (G_OBJECT (self));
CLUTTER_UNSET_PRIVATE_FLAGS (self, CLUTTER_ACTOR_IN_DESTRUCTION); CLUTTER_UNSET_PRIVATE_FLAGS (self, CLUTTER_IN_DESTRUCTION);
} }
g_object_unref (self); g_object_unref (self);
@ -5036,8 +5030,8 @@ _clutter_actor_queue_redraw_with_clip (ClutterActor *self,
* avoid needlessly traversing the actors ancestors to derive an * avoid needlessly traversing the actors ancestors to derive an
* incorrect modelview matrix.) * incorrect modelview matrix.)
*/ */
if ((CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_ACTOR_SYNC_MATRICES) && if ((CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_SYNC_MATRICES) &&
!(CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_STAGE_IN_RESIZE)) !CLUTTER_STAGE_IN_RESIZE (self))
{ {
clutter_actor_queue_redraw (self); clutter_actor_queue_redraw (self);
return; return;
@ -5094,8 +5088,7 @@ clutter_actor_queue_relayout (ClutterActor *self)
return; /* save some cpu cycles */ return; /* save some cpu cycles */
#if CLUTTER_ENABLE_DEBUG #if CLUTTER_ENABLE_DEBUG
if (!(CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_ACTOR_IS_TOPLEVEL) && if (!CLUTTER_ACTOR_IS_TOPLEVEL (self) && CLUTTER_ACTOR_IN_RELAYOUT (self))
(CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_ACTOR_IN_RELAYOUT))
{ {
g_warning ("The actor '%s' is currently inside an allocation " g_warning ("The actor '%s' is currently inside an allocation "
"cycle; calling clutter_actor_queue_relayout() is " "cycle; calling clutter_actor_queue_relayout() is "
@ -5553,12 +5546,12 @@ clutter_actor_allocate (ClutterActor *self,
if (child_moved) if (child_moved)
flags |= CLUTTER_ABSOLUTE_ORIGIN_CHANGED; flags |= CLUTTER_ABSOLUTE_ORIGIN_CHANGED;
CLUTTER_SET_PRIVATE_FLAGS (self, CLUTTER_ACTOR_IN_RELAYOUT); CLUTTER_SET_PRIVATE_FLAGS (self, CLUTTER_IN_RELAYOUT);
klass = CLUTTER_ACTOR_GET_CLASS (self); klass = CLUTTER_ACTOR_GET_CLASS (self);
klass->allocate (self, box, flags); klass->allocate (self, box, flags);
CLUTTER_UNSET_PRIVATE_FLAGS (self, CLUTTER_ACTOR_IN_RELAYOUT); CLUTTER_UNSET_PRIVATE_FLAGS (self, CLUTTER_IN_RELAYOUT);
} }
/** /**
@ -5727,7 +5720,7 @@ clutter_actor_set_min_width (ClutterActor *self,
* then we ignore the passed value and we override it with * then we ignore the passed value and we override it with
* the stage implementation's preferred size. * the stage implementation's preferred size.
*/ */
if ((CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_ACTOR_IS_TOPLEVEL) && if (CLUTTER_ACTOR_IS_TOPLEVEL (self) &&
clutter_feature_available (CLUTTER_FEATURE_STAGE_STATIC)) clutter_feature_available (CLUTTER_FEATURE_STAGE_STATIC))
return; return;
@ -5762,7 +5755,7 @@ clutter_actor_set_min_height (ClutterActor *self,
* then we ignore the passed value and we override it with * then we ignore the passed value and we override it with
* the stage implementation's preferred size. * the stage implementation's preferred size.
*/ */
if ((CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_ACTOR_IS_TOPLEVEL) && if (CLUTTER_ACTOR_IS_TOPLEVEL (self) &&
clutter_feature_available (CLUTTER_FEATURE_STAGE_STATIC)) clutter_feature_available (CLUTTER_FEATURE_STAGE_STATIC))
return; return;
@ -5796,7 +5789,7 @@ clutter_actor_set_natural_width (ClutterActor *self,
* then we ignore the passed value and we override it with * then we ignore the passed value and we override it with
* the stage implementation's preferred size. * the stage implementation's preferred size.
*/ */
if ((CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_ACTOR_IS_TOPLEVEL) && if (CLUTTER_ACTOR_IS_TOPLEVEL (self) &&
clutter_feature_available (CLUTTER_FEATURE_STAGE_STATIC)) clutter_feature_available (CLUTTER_FEATURE_STAGE_STATIC))
return; return;
@ -5831,7 +5824,7 @@ clutter_actor_set_natural_height (ClutterActor *self,
* then we ignore the passed value and we override it with * then we ignore the passed value and we override it with
* the stage implementation's preferred size. * the stage implementation's preferred size.
*/ */
if ((CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_ACTOR_IS_TOPLEVEL) && if (CLUTTER_ACTOR_IS_TOPLEVEL (self) &&
clutter_feature_available (CLUTTER_FEATURE_STAGE_STATIC)) clutter_feature_available (CLUTTER_FEATURE_STAGE_STATIC))
return; return;
@ -6002,7 +5995,7 @@ clutter_actor_set_width_internal (ClutterActor *self,
* width to be resized to, so we should not be setting it * width to be resized to, so we should not be setting it
* along with the :natural-width * along with the :natural-width
*/ */
if (!(CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_ACTOR_IS_TOPLEVEL)) if (!CLUTTER_ACTOR_IS_TOPLEVEL (self))
clutter_actor_set_min_width (self, width); clutter_actor_set_min_width (self, width);
clutter_actor_set_natural_width (self, width); clutter_actor_set_natural_width (self, width);
@ -6010,7 +6003,7 @@ clutter_actor_set_width_internal (ClutterActor *self,
else else
{ {
/* we only unset the :natural-width for the Stage */ /* we only unset the :natural-width for the Stage */
if (!(CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_ACTOR_IS_TOPLEVEL)) if (!CLUTTER_ACTOR_IS_TOPLEVEL (self))
clutter_actor_set_min_width_set (self, FALSE); clutter_actor_set_min_width_set (self, FALSE);
clutter_actor_set_natural_width_set (self, FALSE); clutter_actor_set_natural_width_set (self, FALSE);
@ -6027,7 +6020,7 @@ clutter_actor_set_height_internal (ClutterActor *self,
if (height >= 0) if (height >= 0)
{ {
/* see the comment above in set_width_internal() */ /* see the comment above in set_width_internal() */
if (!(CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_ACTOR_IS_TOPLEVEL)) if (!CLUTTER_ACTOR_IS_TOPLEVEL (self))
clutter_actor_set_min_height (self, height); clutter_actor_set_min_height (self, height);
clutter_actor_set_natural_height (self, height); clutter_actor_set_natural_height (self, height);
@ -6035,7 +6028,7 @@ clutter_actor_set_height_internal (ClutterActor *self,
else else
{ {
/* see the comment above in set_width_internal() */ /* see the comment above in set_width_internal() */
if (!(CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_ACTOR_IS_TOPLEVEL)) if (!CLUTTER_ACTOR_IS_TOPLEVEL (self))
clutter_actor_set_min_height_set (self, FALSE); clutter_actor_set_min_height_set (self, FALSE);
clutter_actor_set_natural_height_set (self, FALSE); clutter_actor_set_natural_height_set (self, FALSE);
@ -6829,7 +6822,7 @@ clutter_actor_get_paint_opacity_internal (ClutterActor *self)
* case of ClutterStage:use-alpha being TRUE we want the rest * case of ClutterStage:use-alpha being TRUE we want the rest
* of the scene to be painted * of the scene to be painted
*/ */
if (CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_ACTOR_IS_TOPLEVEL) if (CLUTTER_ACTOR_IS_TOPLEVEL (self))
return 255; return 255;
if (priv->opacity_parent != NULL) if (priv->opacity_parent != NULL)
@ -7351,13 +7344,13 @@ clutter_actor_set_parent (ClutterActor *self,
return; return;
} }
if (CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_ACTOR_IS_TOPLEVEL) if (CLUTTER_ACTOR_IS_TOPLEVEL (self))
{ {
g_warning ("Cannot set a parent on a toplevel actor\n"); g_warning ("Cannot set a parent on a toplevel actor\n");
return; return;
} }
if (CLUTTER_PRIVATE_FLAGS (parent) & CLUTTER_ACTOR_IN_DESTRUCTION) if (CLUTTER_ACTOR_IN_DESTRUCTION (self))
{ {
g_warning ("Cannot set a parent currently being destroyed"); g_warning ("Cannot set a parent currently being destroyed");
return; return;
@ -7370,10 +7363,10 @@ clutter_actor_set_parent (ClutterActor *self,
* the flag on the actor * the flag on the actor
*/ */
if (parent->priv->internal_child) if (parent->priv->internal_child)
CLUTTER_SET_PRIVATE_FLAGS (self, CLUTTER_ACTOR_INTERNAL_CHILD); CLUTTER_SET_PRIVATE_FLAGS (self, CLUTTER_INTERNAL_CHILD);
/* clutter_actor_reparent() will emit ::parent-set for us */ /* clutter_actor_reparent() will emit ::parent-set for us */
if (!(CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_ACTOR_IN_REPARENT)) if (!CLUTTER_ACTOR_IN_REPARENT (self))
g_signal_emit (self, actor_signals[PARENT_SET], 0, NULL); g_signal_emit (self, actor_signals[PARENT_SET], 0, NULL);
/* If parent is mapped or realized, we need to also be mapped or /* If parent is mapped or realized, we need to also be mapped or
@ -7488,7 +7481,7 @@ clutter_actor_unparent (ClutterActor *self)
priv->parent_actor = NULL; priv->parent_actor = NULL;
/* clutter_actor_reparent() will emit ::parent-set for us */ /* clutter_actor_reparent() will emit ::parent-set for us */
if (!(CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_ACTOR_IN_REPARENT)) if (!CLUTTER_ACTOR_IN_REPARENT (self))
g_signal_emit (self, actor_signals[PARENT_SET], 0, old_parent); g_signal_emit (self, actor_signals[PARENT_SET], 0, old_parent);
/* Queue a redraw on old_parent only if we were painted in the first /* Queue a redraw on old_parent only if we were painted in the first
@ -7525,13 +7518,13 @@ clutter_actor_reparent (ClutterActor *self,
g_return_if_fail (CLUTTER_IS_ACTOR (new_parent)); g_return_if_fail (CLUTTER_IS_ACTOR (new_parent));
g_return_if_fail (self != new_parent); g_return_if_fail (self != new_parent);
if (CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_ACTOR_IS_TOPLEVEL) if (CLUTTER_ACTOR_IS_TOPLEVEL (self))
{ {
g_warning ("Cannot set a parent on a toplevel actor"); g_warning ("Cannot set a parent on a toplevel actor");
return; return;
} }
if (CLUTTER_PRIVATE_FLAGS (new_parent) & CLUTTER_ACTOR_IN_DESTRUCTION) if (CLUTTER_ACTOR_IN_DESTRUCTION (self))
{ {
g_warning ("Cannot set a parent currently being destroyed"); g_warning ("Cannot set a parent currently being destroyed");
return; return;
@ -7543,7 +7536,7 @@ clutter_actor_reparent (ClutterActor *self,
{ {
ClutterActor *old_parent; ClutterActor *old_parent;
CLUTTER_SET_PRIVATE_FLAGS (self, CLUTTER_ACTOR_IN_REPARENT); CLUTTER_SET_PRIVATE_FLAGS (self, CLUTTER_IN_REPARENT);
old_parent = priv->parent_actor; old_parent = priv->parent_actor;
@ -7553,7 +7546,7 @@ clutter_actor_reparent (ClutterActor *self,
* child and not an internal one * child and not an internal one
*/ */
if (CLUTTER_IS_CONTAINER (priv->parent_actor) && if (CLUTTER_IS_CONTAINER (priv->parent_actor) &&
!(CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_ACTOR_INTERNAL_CHILD)) !CLUTTER_ACTOR_IS_INTERNAL_CHILD (self))
{ {
ClutterContainer *parent = CLUTTER_CONTAINER (priv->parent_actor); ClutterContainer *parent = CLUTTER_CONTAINER (priv->parent_actor);
@ -7574,7 +7567,7 @@ clutter_actor_reparent (ClutterActor *self,
g_object_unref (self); g_object_unref (self);
CLUTTER_UNSET_PRIVATE_FLAGS (self, CLUTTER_ACTOR_IN_REPARENT); CLUTTER_UNSET_PRIVATE_FLAGS (self, CLUTTER_IN_REPARENT);
/* the IN_REPARENT flag suspends state updates */ /* the IN_REPARENT flag suspends state updates */
clutter_actor_update_map_state (self, MAP_STATE_CHECK); clutter_actor_update_map_state (self, MAP_STATE_CHECK);
@ -9803,7 +9796,7 @@ clutter_actor_is_scaled (ClutterActor *self)
static ClutterActor * static ClutterActor *
clutter_actor_get_stage_internal (ClutterActor *actor) clutter_actor_get_stage_internal (ClutterActor *actor)
{ {
while (actor && !(CLUTTER_PRIVATE_FLAGS (actor) & CLUTTER_ACTOR_IS_TOPLEVEL)) while (actor && !CLUTTER_ACTOR_IS_TOPLEVEL (actor))
actor = actor->priv->parent_actor; actor = actor->priv->parent_actor;
return actor; return actor;

View File

@ -432,7 +432,7 @@ _clutter_backend_ensure_context (ClutterBackend *backend,
if (current_context_stage) if (current_context_stage)
{ {
CLUTTER_SET_PRIVATE_FLAGS (current_context_stage, CLUTTER_SET_PRIVATE_FLAGS (current_context_stage,
CLUTTER_ACTOR_SYNC_MATRICES); CLUTTER_SYNC_MATRICES);
} }
} }
else else

View File

@ -96,7 +96,7 @@ enum
#ifdef CLUTTER_ENABLE_DEBUG #ifdef CLUTTER_ENABLE_DEBUG
#define clutter_warn_if_paint_fail(obj) G_STMT_START { \ #define clutter_warn_if_paint_fail(obj) G_STMT_START { \
if (CLUTTER_PRIVATE_FLAGS ((obj)) & CLUTTER_ACTOR_IN_PAINT) { \ if (CLUTTER_ACTOR_IN_PAINT (obj)) { \
g_warning ("%s should not be called during the paint sequence " \ g_warning ("%s should not be called during the paint sequence " \
"of a ClutterCairoTexture as it will likely cause " \ "of a ClutterCairoTexture as it will likely cause " \
"performance issues.", G_STRFUNC); \ "performance issues.", G_STRFUNC); \

View File

@ -236,12 +236,12 @@ _clutter_stage_maybe_relayout (ClutterActor *stage)
0 /* no application private data */); 0 /* no application private data */);
/* avoid reentrancy */ /* avoid reentrancy */
if (!(CLUTTER_PRIVATE_FLAGS (stage) & CLUTTER_ACTOR_IN_RELAYOUT)) if (!CLUTTER_ACTOR_IN_RELAYOUT (stage))
{ {
CLUTTER_TIMER_START (_clutter_uprof_context, relayout_timer); CLUTTER_TIMER_START (_clutter_uprof_context, relayout_timer);
CLUTTER_NOTE (ACTOR, "Recomputing layout"); CLUTTER_NOTE (ACTOR, "Recomputing layout");
CLUTTER_SET_PRIVATE_FLAGS (stage, CLUTTER_ACTOR_IN_RELAYOUT); CLUTTER_SET_PRIVATE_FLAGS (stage, CLUTTER_IN_RELAYOUT);
natural_width = natural_height = 0; natural_width = natural_height = 0;
clutter_actor_get_preferred_size (stage, clutter_actor_get_preferred_size (stage,
@ -259,7 +259,7 @@ _clutter_stage_maybe_relayout (ClutterActor *stage)
clutter_actor_allocate (stage, &box, CLUTTER_ALLOCATION_NONE); clutter_actor_allocate (stage, &box, CLUTTER_ALLOCATION_NONE);
CLUTTER_UNSET_PRIVATE_FLAGS (stage, CLUTTER_ACTOR_IN_RELAYOUT); CLUTTER_UNSET_PRIVATE_FLAGS (stage, CLUTTER_IN_RELAYOUT);
CLUTTER_TIMER_STOP (_clutter_uprof_context, relayout_timer); CLUTTER_TIMER_STOP (_clutter_uprof_context, relayout_timer);
} }
} }
@ -267,8 +267,8 @@ _clutter_stage_maybe_relayout (ClutterActor *stage)
void void
_clutter_stage_maybe_setup_viewport (ClutterStage *stage) _clutter_stage_maybe_setup_viewport (ClutterStage *stage)
{ {
if ((CLUTTER_PRIVATE_FLAGS (stage) & CLUTTER_ACTOR_SYNC_MATRICES) && if ((CLUTTER_PRIVATE_FLAGS (stage) & CLUTTER_SYNC_MATRICES) &&
!(CLUTTER_PRIVATE_FLAGS (stage) & CLUTTER_STAGE_IN_RESIZE)) !CLUTTER_STAGE_IN_RESIZE (stage))
{ {
ClutterPerspective perspective; ClutterPerspective perspective;
gfloat width, height; gfloat width, height;
@ -288,7 +288,7 @@ _clutter_stage_maybe_setup_viewport (ClutterStage *stage)
perspective.z_near, perspective.z_near,
perspective.z_far); perspective.z_far);
CLUTTER_UNSET_PRIVATE_FLAGS (stage, CLUTTER_ACTOR_SYNC_MATRICES); CLUTTER_UNSET_PRIVATE_FLAGS (stage, CLUTTER_SYNC_MATRICES);
} }
} }

View File

@ -56,32 +56,44 @@ G_BEGIN_DECLS
typedef struct _ClutterMainContext ClutterMainContext; typedef struct _ClutterMainContext ClutterMainContext;
typedef enum { #define CLUTTER_PRIVATE_FLAGS(a) (((ClutterActor *) (a))->private_flags)
CLUTTER_ACTOR_UNUSED_FLAG = 0, #define CLUTTER_SET_PRIVATE_FLAGS(a,f) (CLUTTER_PRIVATE_FLAGS (a) |= (f))
#define CLUTTER_UNSET_PRIVATE_FLAGS(a,f) (CLUTTER_PRIVATE_FLAGS (a) &= ~(f))
CLUTTER_ACTOR_IN_DESTRUCTION = 1 << 0, #define CLUTTER_ACTOR_IS_TOPLEVEL(a) ((CLUTTER_PRIVATE_FLAGS (a) & CLUTTER_IS_TOPLEVEL) != FALSE)
CLUTTER_ACTOR_IS_TOPLEVEL = 1 << 1, #define CLUTTER_ACTOR_IS_INTERNAL_CHILD(a) ((CLUTTER_PRIVATE_FLAGS (a) & CLUTTER_INTERNAL_CHILD) != FALSE)
CLUTTER_ACTOR_IN_REPARENT = 1 << 2, #define CLUTTER_ACTOR_IN_DESTRUCTION(a) ((CLUTTER_PRIVATE_FLAGS (a) & CLUTTER_IN_DESTRUCTION) != FALSE)
#define CLUTTER_ACTOR_IN_REPARENT(a) ((CLUTTER_PRIVATE_FLAGS (a) & CLUTTER_IN_REPARENT) != FALSE)
#define CLUTTER_ACTOR_IN_PAINT(a) ((CLUTTER_PRIVATE_FLAGS (a) & CLUTTER_IN_PAINT) != FALSE)
#define CLUTTER_ACTOR_IN_RELAYOUT(a) ((CLUTTER_PRIVATE_FLAGS (a) & CLUTTER_IN_RELAYOUT) != FALSE)
#define CLUTTER_STAGE_IN_RESIZE(a) ((CLUTTER_PRIVATE_FLAGS (a) & CLUTTER_IN_RESIZE) != FALSE)
typedef enum {
CLUTTER_ACTOR_UNUSED_FLAG = 0,
CLUTTER_IN_DESTRUCTION = 1 << 0,
CLUTTER_IS_TOPLEVEL = 1 << 1,
CLUTTER_IN_REPARENT = 1 << 2,
/* Used by the stage to indicate GL viewport / perspective etc needs /* Used by the stage to indicate GL viewport / perspective etc needs
* (re)setting. * (re)setting.
*/ */
CLUTTER_ACTOR_SYNC_MATRICES = 1 << 3, CLUTTER_SYNC_MATRICES = 1 << 3,
/* Used to avoid recursion */ /* Used to avoid recursion */
CLUTTER_ACTOR_IN_PAINT = 1 << 4, CLUTTER_IN_PAINT = 1 << 4,
/* Used to avoid recursion */ /* Used to avoid recursion */
CLUTTER_ACTOR_IN_RELAYOUT = 1 << 5, CLUTTER_IN_RELAYOUT = 1 << 5,
/* Used by the stage if resizing is an asynchronous operation (like on /* Used by the stage if resizing is an asynchronous operation (like on
* X11) to delay queueing relayouts until we got a notification from the * X11) to delay queueing relayouts until we got a notification from the
* event handling * event handling
*/ */
CLUTTER_STAGE_IN_RESIZE = 1 << 6, CLUTTER_IN_RESIZE = 1 << 6,
/* a flag for internal children of Containers */ /* a flag for internal children of Containers */
CLUTTER_ACTOR_INTERNAL_CHILD = 1 << 7 CLUTTER_INTERNAL_CHILD = 1 << 7
} ClutterPrivateFlags; } ClutterPrivateFlags;
struct _ClutterInputDevice struct _ClutterInputDevice
@ -184,10 +196,6 @@ gboolean _clutter_context_is_initialized (void);
PangoContext *_clutter_context_create_pango_context (ClutterMainContext *self); PangoContext *_clutter_context_create_pango_context (ClutterMainContext *self);
PangoContext *_clutter_context_get_pango_context (ClutterMainContext *self); PangoContext *_clutter_context_get_pango_context (ClutterMainContext *self);
#define CLUTTER_PRIVATE_FLAGS(a) (((ClutterActor *) (a))->private_flags)
#define CLUTTER_SET_PRIVATE_FLAGS(a,f) (CLUTTER_PRIVATE_FLAGS (a) |= (f))
#define CLUTTER_UNSET_PRIVATE_FLAGS(a,f) (CLUTTER_PRIVATE_FLAGS (a) &= ~(f))
#define CLUTTER_PARAM_READABLE \ #define CLUTTER_PARAM_READABLE \
G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB
#define CLUTTER_PARAM_WRITABLE \ #define CLUTTER_PARAM_WRITABLE \

View File

@ -376,7 +376,7 @@ clutter_stage_realize (ClutterActor *self)
* first paint (which will likely occur before the ConfigureNotify * first paint (which will likely occur before the ConfigureNotify
* is received) * is received)
*/ */
CLUTTER_SET_PRIVATE_FLAGS (self, CLUTTER_ACTOR_SYNC_MATRICES); CLUTTER_SET_PRIVATE_FLAGS (self, CLUTTER_SYNC_MATRICES);
g_assert (priv->impl != NULL); g_assert (priv->impl != NULL);
is_realized = _clutter_stage_window_realize (priv->impl); is_realized = _clutter_stage_window_realize (priv->impl);
@ -771,12 +771,8 @@ gboolean
_clutter_stage_has_full_redraw_queued (ClutterStage *stage) _clutter_stage_has_full_redraw_queued (ClutterStage *stage)
{ {
ClutterStageWindow *stage_window = _clutter_stage_get_window (stage); ClutterStageWindow *stage_window = _clutter_stage_get_window (stage);
gboolean in_destruction;
in_destruction = if (CLUTTER_ACTOR_IN_DESTRUCTION (stage) || stage_window == NULL)
((CLUTTER_PRIVATE_FLAGS (stage) & CLUTTER_ACTOR_IN_DESTRUCTION) != FALSE);
if (in_destruction || stage_window == NULL)
return FALSE; return FALSE;
if (stage->priv->redraw_pending && if (stage->priv->redraw_pending &&
@ -1319,7 +1315,7 @@ clutter_stage_init (ClutterStage *self)
ClutterBackend *backend; ClutterBackend *backend;
/* a stage is a top-level object */ /* a stage is a top-level object */
CLUTTER_SET_PRIVATE_FLAGS (self, CLUTTER_ACTOR_IS_TOPLEVEL); CLUTTER_SET_PRIVATE_FLAGS (self, CLUTTER_IS_TOPLEVEL);
self->priv = priv = CLUTTER_STAGE_GET_PRIVATE (self); self->priv = priv = CLUTTER_STAGE_GET_PRIVATE (self);
@ -1472,7 +1468,7 @@ clutter_stage_set_perspective (ClutterStage *stage,
/* this will cause the viewport to be reset; see /* this will cause the viewport to be reset; see
* clutter_maybe_setup_viewport() inside clutter-main.c * clutter_maybe_setup_viewport() inside clutter-main.c
*/ */
CLUTTER_SET_PRIVATE_FLAGS (stage, CLUTTER_ACTOR_SYNC_MATRICES); CLUTTER_SET_PRIVATE_FLAGS (stage, CLUTTER_SYNC_MATRICES);
} }
/** /**
@ -2284,7 +2280,7 @@ clutter_stage_ensure_viewport (ClutterStage *stage)
{ {
g_return_if_fail (CLUTTER_IS_STAGE (stage)); g_return_if_fail (CLUTTER_IS_STAGE (stage));
CLUTTER_SET_PRIVATE_FLAGS (stage, CLUTTER_ACTOR_SYNC_MATRICES); CLUTTER_SET_PRIVATE_FLAGS (stage, CLUTTER_SYNC_MATRICES);
clutter_actor_queue_redraw (CLUTTER_ACTOR (stage)); clutter_actor_queue_redraw (CLUTTER_ACTOR (stage));
} }
@ -2583,7 +2579,7 @@ _clutter_stage_get_pending_swaps (ClutterStage *stage)
{ {
ClutterStageWindow *stage_window; ClutterStageWindow *stage_window;
if (CLUTTER_PRIVATE_FLAGS (stage) & CLUTTER_ACTOR_IN_DESTRUCTION) if (CLUTTER_ACTOR_IN_DESTRUCTION (stage))
return 0; return 0;
stage_window = _clutter_stage_get_window (stage); stage_window = _clutter_stage_get_window (stage);

View File

@ -398,7 +398,7 @@ clutter_backend_egl_ensure_context (ClutterBackend *backend,
ClutterStageWindow *impl; ClutterStageWindow *impl;
if (stage == NULL || if (stage == NULL ||
(CLUTTER_PRIVATE_FLAGS (stage) & CLUTTER_ACTOR_IN_DESTRUCTION) || CLUTTER_ACTOR_IN_DESTRUCTION (stage) ||
((impl = _clutter_stage_get_window (stage)) == NULL)) ((impl = _clutter_stage_get_window (stage)) == NULL))
{ {
CLUTTER_NOTE (BACKEND, "Clearing EGL context"); CLUTTER_NOTE (BACKEND, "Clearing EGL context");

View File

@ -665,7 +665,7 @@ clutter_backend_glx_ensure_context (ClutterBackend *backend,
* implementation attached to it then we clear the GL context * implementation attached to it then we clear the GL context
*/ */
if (stage == NULL || if (stage == NULL ||
(CLUTTER_PRIVATE_FLAGS (stage) & CLUTTER_ACTOR_IN_DESTRUCTION) || CLUTTER_ACTOR_IN_DESTRUCTION (stage) ||
((impl = _clutter_stage_get_window (stage)) == NULL)) ((impl = _clutter_stage_get_window (stage)) == NULL))
{ {
ClutterBackendX11 *backend_x11; ClutterBackendX11 *backend_x11;

View File

@ -157,7 +157,7 @@ clutter_stage_osx_state_update (ClutterStageOSX *self,
clutter_actor_set_size (CLUTTER_ACTOR (self->stage_osx->wrapper), clutter_actor_set_size (CLUTTER_ACTOR (self->stage_osx->wrapper),
(int)aSize.width, (int)aSize.height); (int)aSize.width, (int)aSize.height);
CLUTTER_SET_PRIVATE_FLAGS(self->stage_osx->wrapper, CLUTTER_ACTOR_SYNC_MATRICES); CLUTTER_SET_PRIVATE_FLAGS (self->stage_osx->wrapper, CLUTTER_SYNC_MATRICES);
} }
/* Simply forward all events that reach our view to clutter. */ /* Simply forward all events that reach our view to clutter. */
@ -407,7 +407,7 @@ clutter_stage_osx_resize (ClutterStageWindow *stage_window,
CLUTTER_OSX_POOL_RELEASE (); CLUTTER_OSX_POOL_RELEASE ();
/* make sure that the viewport is updated */ /* make sure that the viewport is updated */
CLUTTER_SET_PRIVATE_FLAGS (self->wrapper, CLUTTER_ACTOR_SYNC_MATRICES); CLUTTER_SET_PRIVATE_FLAGS (self->wrapper, CLUTTER_SYNC_MATRICES);
} }
/*************************************************************************/ /*************************************************************************/
@ -499,8 +499,6 @@ clutter_stage_osx_init (ClutterStageOSX *self)
{ {
self->requisition_width = 640; self->requisition_width = 640;
self->requisition_height = 480; self->requisition_height = 480;
CLUTTER_SET_PRIVATE_FLAGS(self, CLUTTER_ACTOR_IS_TOPLEVEL);
} }
static void static void

View File

@ -426,7 +426,7 @@ clutter_backend_win32_ensure_context (ClutterBackend *backend,
ClutterStageWindow *impl; ClutterStageWindow *impl;
if (stage == NULL || if (stage == NULL ||
(CLUTTER_PRIVATE_FLAGS (stage) & CLUTTER_ACTOR_IN_DESTRUCTION) || !CLUTTER_ACTOR_IN_DESTRUCTION (stage) ||
((impl = _clutter_stage_get_window (stage)) == NULL)) ((impl = _clutter_stage_get_window (stage)) == NULL))
{ {
CLUTTER_NOTE (MULTISTAGE, "Clearing all context"); CLUTTER_NOTE (MULTISTAGE, "Clearing all context");

View File

@ -192,7 +192,7 @@ clutter_stage_win32_resize (ClutterStageWindow *stage_window,
} }
CLUTTER_SET_PRIVATE_FLAGS (stage_win32->wrapper, CLUTTER_SET_PRIVATE_FLAGS (stage_win32->wrapper,
CLUTTER_ACTOR_SYNC_MATRICES); CLUTTER_SYNC_MATRICES);
} }
} }
@ -349,7 +349,7 @@ clutter_stage_win32_set_fullscreen (ClutterStageWindow *stage_window,
} }
CLUTTER_SET_PRIVATE_FLAGS (stage_win32->wrapper, CLUTTER_SET_PRIVATE_FLAGS (stage_win32->wrapper,
CLUTTER_ACTOR_SYNC_MATRICES); CLUTTER_SYNC_MATRICES);
} }
/* Report the state change */ /* Report the state change */
@ -553,8 +553,6 @@ clutter_stage_win32_init (ClutterStageWin32 *stage)
stage->wtitle = NULL; stage->wtitle = NULL;
stage->is_cursor_visible = TRUE; stage->is_cursor_visible = TRUE;
stage->wrapper = NULL; stage->wrapper = NULL;
CLUTTER_SET_PRIVATE_FLAGS (stage, CLUTTER_ACTOR_IS_TOPLEVEL);
} }
static void static void

View File

@ -582,7 +582,7 @@ event_translate (ClutterBackend *backend,
xevent->xconfigure.height); xevent->xconfigure.height);
CLUTTER_UNSET_PRIVATE_FLAGS (stage_x11->wrapper, CLUTTER_UNSET_PRIVATE_FLAGS (stage_x11->wrapper,
CLUTTER_STAGE_IN_RESIZE); CLUTTER_IN_RESIZE);
/* the resize process is complete, so we can ask the stage /* the resize process is complete, so we can ask the stage
* to set up the GL viewport with the new size * to set up the GL viewport with the new size

View File

@ -275,7 +275,7 @@ clutter_stage_x11_resize (ClutterStageWindow *stage_window,
height); height);
CLUTTER_SET_PRIVATE_FLAGS (stage_x11->wrapper, CLUTTER_SET_PRIVATE_FLAGS (stage_x11->wrapper,
CLUTTER_STAGE_IN_RESIZE); CLUTTER_IN_RESIZE);
XResizeWindow (backend_x11->xdpy, XResizeWindow (backend_x11->xdpy,
stage_x11->xwin, stage_x11->xwin,
@ -436,7 +436,7 @@ clutter_stage_x11_set_fullscreen (ClutterStageWindow *stage_window,
CLUTTER_NOTE (BACKEND, "%ssetting fullscreen", is_fullscreen ? "" : "un"); CLUTTER_NOTE (BACKEND, "%ssetting fullscreen", is_fullscreen ? "" : "un");
CLUTTER_SET_PRIVATE_FLAGS (stage, CLUTTER_ACTOR_SYNC_MATRICES); CLUTTER_SET_PRIVATE_FLAGS (stage, CLUTTER_SYNC_MATRICES);
if (is_fullscreen) if (is_fullscreen)
{ {
@ -711,8 +711,6 @@ clutter_stage_x11_init (ClutterStageX11 *stage)
stage->title = NULL; stage->title = NULL;
stage->wrapper = NULL; stage->wrapper = NULL;
CLUTTER_SET_PRIVATE_FLAGS (stage, CLUTTER_ACTOR_IS_TOPLEVEL);
} }
static void static void
@ -890,7 +888,7 @@ clutter_x11_set_stage_foreign (ClutterStage *stage,
backend_x11 = CLUTTER_BACKEND_X11 (backend); backend_x11 = CLUTTER_BACKEND_X11 (backend);
g_return_val_if_fail (CLUTTER_IS_STAGE (stage), FALSE); g_return_val_if_fail (CLUTTER_IS_STAGE (stage), FALSE);
g_return_val_if_fail (!(CLUTTER_PRIVATE_FLAGS (stage) & CLUTTER_ACTOR_IN_DESTRUCTION), FALSE); g_return_val_if_fail (!CLUTTER_ACTOR_IN_DESTRUCTION (stage), FALSE);
g_return_val_if_fail (xwindow != None, FALSE); g_return_val_if_fail (xwindow != None, FALSE);
actor = CLUTTER_ACTOR (stage); actor = CLUTTER_ACTOR (stage);