From f1ebfe30cee518811454b2bea6558bcfd19a5eb7 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Mon, 14 Nov 2011 15:43:20 +0000 Subject: [PATCH 1/2] stage-manager: Store the stage manager into the main context Use the main context to store the stage manager singleton, instead of a static pointer inside clutter-stage-manager.c. --- clutter/clutter-private.h | 4 ++++ clutter/clutter-stage-manager.c | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/clutter/clutter-private.h b/clutter/clutter-private.h index 017d54e7a..8c8f602f3 100644 --- a/clutter/clutter-private.h +++ b/clutter/clutter-private.h @@ -40,6 +40,7 @@ #include "clutter-layout-manager.h" #include "clutter-master-clock.h" #include "clutter-settings.h" +#include "clutter-stage-manager.h" #include "clutter-stage.h" G_BEGIN_DECLS @@ -124,6 +125,9 @@ struct _ClutterMainContext /* the main windowing system backend */ ClutterBackend *backend; + /* the object holding all the stage instances */ + ClutterStageManager *stage_manager; + /* the main event queue */ GQueue *events_queue; diff --git a/clutter/clutter-stage-manager.c b/clutter/clutter-stage-manager.c index 26e58ccd9..a6005944f 100644 --- a/clutter/clutter-stage-manager.c +++ b/clutter/clutter-stage-manager.c @@ -178,12 +178,12 @@ clutter_stage_manager_init (ClutterStageManager *stage_manager) ClutterStageManager * clutter_stage_manager_get_default (void) { - static ClutterStageManager *stage_manager = NULL; + ClutterMainContext *context = _clutter_context_get_default (); - if (G_UNLIKELY (stage_manager == NULL)) - stage_manager = g_object_new (CLUTTER_TYPE_STAGE_MANAGER, NULL); + if (G_UNLIKELY (context->stage_manager == NULL)) + context->stage_manager = g_object_new (CLUTTER_TYPE_STAGE_MANAGER, NULL); - return stage_manager; + return context->stage_manager; } /** From b281f2090a8fb042cb471611eab54c26ceba8074 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Mon, 14 Nov 2011 17:04:14 +0000 Subject: [PATCH 2/2] Store the master clock pointer in the main context Let's try and move all singletons into ClutterMainContext. --- clutter/clutter-master-clock.c | 10 ++++------ clutter/clutter-private.h | 3 +++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/clutter/clutter-master-clock.c b/clutter/clutter-master-clock.c index 21a86d579..2f2debda4 100644 --- a/clutter/clutter-master-clock.c +++ b/clutter/clutter-master-clock.c @@ -95,8 +95,6 @@ static gboolean clutter_clock_dispatch (GSource *source, GSourceFunc callback, gpointer user_data); -static ClutterMasterClock *default_clock = NULL; - static GSourceFuncs clock_funcs = { clutter_clock_prepare, clutter_clock_check, @@ -461,12 +459,12 @@ clutter_master_clock_init (ClutterMasterClock *self) ClutterMasterClock * _clutter_master_clock_get_default (void) { - if (G_LIKELY (default_clock != NULL)) - return default_clock; + ClutterMainContext *context = _clutter_context_get_default (); - default_clock = g_object_new (CLUTTER_TYPE_MASTER_CLOCK, NULL); + if (G_UNLIKELY (context->master_clock == NULL)) + context->master_clock = g_object_new (CLUTTER_TYPE_MASTER_CLOCK, NULL); - return default_clock; + return context->master_clock; } /* diff --git a/clutter/clutter-private.h b/clutter/clutter-private.h index 8c8f602f3..30ea65fa3 100644 --- a/clutter/clutter-private.h +++ b/clutter/clutter-private.h @@ -128,6 +128,9 @@ struct _ClutterMainContext /* the object holding all the stage instances */ ClutterStageManager *stage_manager; + /* the clock driving all the frame operations */ + ClutterMasterClock *master_clock; + /* the main event queue */ GQueue *events_queue;