From ee33357fd5d08be824a5ecb3161a79568afa4e5c Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 18 Feb 2010 16:58:29 +0000 Subject: [PATCH] stage: Only clutter_stage_get_default() creates the default stage The introduction of the StageManager in 0.8 implied that the first Stage instance to be created was automatically assigned the status of "default stage". This was all well and good, since the default stage was created behind the curtains by the initialization sequence. Now that the initialization sequence does not create a default stage any longer, it means that the first stage created using clutter_stage_new() gets to be the default, and all special and warm and fuzzy - which also means that the first stage created by clutter_stage_new() cannot be destroyed or handled as any other stage. Whoopsie. Let's go back to the old semantics: the stage created by the first invocation of clutter_stage_get_default() is the default stage, and nothing else can be set as default. One day we'll be able to break the API and the whole default stage business will be a thing of the past. --- clutter/clutter-private.h | 10 ++++++---- clutter/clutter-stage-manager.c | 32 +++++++++++++++++++++++++------- clutter/clutter-stage.c | 1 + 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/clutter/clutter-private.h b/clutter/clutter-private.h index fab17d6ec..5800334c5 100644 --- a/clutter/clutter-private.h +++ b/clutter/clutter-private.h @@ -216,10 +216,12 @@ void _clutter_input_device_set_actor (ClutterInputDevice *device, ClutterActor *_clutter_input_device_update (ClutterInputDevice *device); /* stage manager */ -void _clutter_stage_manager_add_stage (ClutterStageManager *stage_manager, - ClutterStage *stage); -void _clutter_stage_manager_remove_stage (ClutterStageManager *stage_manager, - ClutterStage *stage); +void _clutter_stage_manager_add_stage (ClutterStageManager *stage_manager, + ClutterStage *stage); +void _clutter_stage_manager_remove_stage (ClutterStageManager *stage_manager, + ClutterStage *stage); +void _clutter_stage_manager_set_default_stage (ClutterStageManager *stage_manager, + ClutterStage *stage); /* stage */ void _clutter_stage_set_window (ClutterStage *stage, diff --git a/clutter/clutter-stage-manager.c b/clutter/clutter-stage-manager.c index 2ce63f617..0a1fda6f2 100644 --- a/clutter/clutter-stage-manager.c +++ b/clutter/clutter-stage-manager.c @@ -212,6 +212,31 @@ clutter_stage_manager_set_default_stage (ClutterStageManager *stage_manager, { } +/* + * _clutter_stage_manager_set_default_stage: + * @stage_manager: a #ClutterStageManager + * @stage: a #ClutterStage + * + * Sets @stage as the default stage + * + * A no-op if there already is a default stage + * + * This is called by clutter_stage_get_default() and should be removed + * along with #ClutterStageManager:default-stage when we stop having + * the default stage + */ +void +_clutter_stage_manager_set_default_stage (ClutterStageManager *stage_manager, + ClutterStage *stage) +{ + if (G_UNLIKELY (default_stage == NULL)) + { + default_stage = stage; + + g_object_notify (G_OBJECT (stage_manager), "default-stage"); + } +} + /** * clutter_stage_manager_get_default_stage: * @stage_manager: a #ClutterStageManager @@ -281,13 +306,6 @@ _clutter_stage_manager_add_stage (ClutterStageManager *stage_manager, stage_manager->stages = g_slist_append (stage_manager->stages, stage); - if (G_UNLIKELY (default_stage == NULL)) - { - default_stage = stage; - - g_object_notify (G_OBJECT (stage_manager), "default-stage"); - } - g_signal_emit (stage_manager, manager_signals[STAGE_ADDED], 0, stage); } diff --git a/clutter/clutter-stage.c b/clutter/clutter-stage.c index 9d1daa7db..0b08509eb 100644 --- a/clutter/clutter-stage.c +++ b/clutter/clutter-stage.c @@ -1217,6 +1217,7 @@ clutter_stage_get_default (void) * reference will be claimed by the stage manager. */ stage = g_object_new (CLUTTER_TYPE_STAGE, NULL); + _clutter_stage_manager_set_default_stage (stage_manager, stage); /* the default stage is realized by default */ clutter_actor_realize (CLUTTER_ACTOR (stage));