From 988cac1dfb7cae1a6516c0062aeb6ff28bde5d07 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 17 Jun 2008 12:39:37 +0000 Subject: [PATCH] 2008-06-17 Emmanuele Bassi * clutter/clutter-actor.c: (clutter_actor_set_parent): Do not emit ::parent-set when reparenting. (clutter_actor_unparent): Ditto, as above. (clutter_actor_reparent): Emit ::parent-set with the old parent and set the IN_REPARENT flag unconditionally. --- ChangeLog | 11 ++++++++++ clutter/clutter-actor.c | 45 +++++++++++++++++++---------------------- 2 files changed, 32 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index 62d86f1ce..59d599dff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2008-06-17 Emmanuele Bassi + + * clutter/clutter-actor.c: + (clutter_actor_set_parent): Do not emit ::parent-set when + reparenting. + + (clutter_actor_unparent): Ditto, as above. + + (clutter_actor_reparent): Emit ::parent-set with the old + parent and set the IN_REPARENT flag unconditionally. + 2008-06-17 Emmanuele Bassi * doc/clutter-actor-invariants.txt: Document the flags, the diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c index 200265953..e430f53ae 100644 --- a/clutter/clutter-actor.c +++ b/clutter/clutter-actor.c @@ -5580,7 +5580,10 @@ clutter_actor_set_parent (ClutterActor *self, g_object_ref_sink (self); priv->parent_actor = parent; - g_signal_emit (self, actor_signals[PARENT_SET], 0, NULL); + + /* clutter_actor_reparent() will emit ::parent-set for us */ + if (!(CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_ACTOR_IN_REPARENT)) + g_signal_emit (self, actor_signals[PARENT_SET], 0, NULL); /* the invariant is: if the parent is realized, the we must be * realized after set_parent(). the call to clutter_actor_show() @@ -5677,7 +5680,9 @@ clutter_actor_unparent (ClutterActor *self) if (CLUTTER_ACTOR_IS_VISIBLE (self)) clutter_actor_queue_redraw (self); - g_signal_emit (self, actor_signals[PARENT_SET], 0, old_parent); + /* clutter_actor_reparent() will emit ::parent-set for us */ + if (!(CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_ACTOR_IN_REPARENT)) + g_signal_emit (self, actor_signals[PARENT_SET], 0, old_parent); /* remove the reference we acquired in clutter_actor_set_parent() */ g_object_unref (self); @@ -5716,43 +5721,35 @@ clutter_actor_reparent (ClutterActor *self, { ClutterActor *old_parent; - /* if the actor and the parent have already been realized, - * mark the actor as reparenting, so that clutter_actor_unparent() - * just hides the actor instead of unrealize it. - */ - if (CLUTTER_ACTOR_IS_REALIZED (self) && - CLUTTER_ACTOR_IS_REALIZED (new_parent)) - { - CLUTTER_SET_PRIVATE_FLAGS (self, CLUTTER_ACTOR_IN_REPARENT); - } + CLUTTER_SET_PRIVATE_FLAGS (self, CLUTTER_ACTOR_IN_REPARENT); old_parent = priv->parent_actor; g_object_ref (self); - /* XXX: below assumes only containers can reparent, which is - * a fair assumption given that composited actors will not call - * or need clutter_actor_reparent() for internal children. - */ if (CLUTTER_IS_CONTAINER (priv->parent_actor)) - clutter_container_remove_actor (CLUTTER_CONTAINER (priv->parent_actor), - self); + { + ClutterContainer *parent = CLUTTER_CONTAINER (priv->parent_actor); + + clutter_container_remove_actor (parent, self); + } else - priv->parent_actor = NULL; + clutter_actor_unparent (self); if (CLUTTER_IS_CONTAINER (new_parent)) clutter_container_add_actor (CLUTTER_CONTAINER (new_parent), self); else - priv->parent_actor = new_parent; + clutter_actor_set_parent (self, new_parent); + + /* we emit the ::parent-set signal once */ + g_signal_emit (self, actor_signals[PARENT_SET], 0, old_parent); g_object_unref (self); - if (CLUTTER_PRIVATE_FLAGS (self) & CLUTTER_ACTOR_IN_REPARENT) - { - CLUTTER_UNSET_PRIVATE_FLAGS (self, CLUTTER_ACTOR_IN_REPARENT); + CLUTTER_UNSET_PRIVATE_FLAGS (self, CLUTTER_ACTOR_IN_REPARENT); - clutter_actor_queue_redraw (self); - } + if (CLUTTER_ACTOR_IS_VISIBLE (self)) + clutter_actor_queue_redraw (self); } } /**