2008-03-31 Matthew Allum <mallum@openedhand.com>

* README:
        Add notes on new multistage feature.

        * clutter/clutter-stage-manager.c:
        Dont ref contained stages.

        * clutter/clutter-stage.c:
        Automatically remove stage from stage manager on finalisation.
        Cleans up warnings when a stage is destroyed.

        * clutter/clutter-backend.h:
        * clutter/glx/clutter-backend-glx.c:
        Minor formatting cleanups.

        * clutter/glx/clutter-stage-glx.c:
        * configure.ac:
        * clutter/clutter-version.h.in:
        Add a general CLUTTER_STAGE_TYPE define, should be useful for
        evntual stage subclassing and creating with g_object_new()
This commit is contained in:
Matthew Allum
2008-03-31 17:15:02 +00:00
parent e88c8b4ce1
commit 244eedb5bd
9 changed files with 78 additions and 5 deletions

View File

@ -62,7 +62,7 @@ struct _ClutterBackendClass
gboolean (* post_parse) (ClutterBackend *backend,
GError **error);
ClutterActor *(* create_stage) (ClutterBackend *backend,
GError **error);
GError **error);
void (* init_events) (ClutterBackend *backend);
void (* init_features) (ClutterBackend *backend);
void (* add_options) (ClutterBackend *backend,

View File

@ -245,7 +245,12 @@ _clutter_stage_manager_add_stage (ClutterStageManager *stage_manager,
return;
}
g_object_ref_sink (stage);
/* Refing currently disabled as
* - adding/removing internal to clutter and only stage does this
* - stage removes from manager in finalize (and how can it with ref)
* - Maybe a safer way
* g_object_ref_sink (stage);
*/
stage_manager->stages = g_slist_append (stage_manager->stages, stage);
if (!default_stage)
@ -278,5 +283,5 @@ _clutter_stage_manager_remove_stage (ClutterStageManager *stage_manager,
g_signal_emit (stage_manager, manager_signals[STAGE_REMOVED], 0, stage);
g_object_unref (stage);
/* g_object_unref (stage); */
}

View File

@ -245,6 +245,25 @@ clutter_stage_get_property (GObject *object,
}
}
static void
clutter_stage_dispose (GObject *object)
{
G_OBJECT_CLASS (clutter_stage_parent_class)->dispose (object);
}
static void
clutter_stage_finalize (GObject *object)
{
ClutterStage *stage = CLUTTER_STAGE(object);
ClutterStageManager *stage_manager = clutter_stage_manager_get_default ();
_clutter_stage_manager_remove_stage (stage_manager, stage);
G_OBJECT_CLASS (clutter_stage_parent_class)->finalize (object);
}
static void
clutter_stage_class_init (ClutterStageClass *klass)
{
@ -253,6 +272,8 @@ clutter_stage_class_init (ClutterStageClass *klass)
gobject_class->set_property = clutter_stage_set_property;
gobject_class->get_property = clutter_stage_get_property;
gobject_class->dispose = clutter_stage_dispose;
gobject_class->finalize = clutter_stage_finalize;
actor_class->paint = clutter_stage_paint;
actor_class->pick = clutter_stage_pick;

View File

@ -112,6 +112,15 @@
*/
#define CLUTTER_COGL "@CLUTTER_COGL@"
/**
* CLUTTER_STAGE_TYPE:
*
* The default GObject type for the Clutter stage.
*
* Since 0.8
*/
#define CLUTTER_STAGE_TYPE @CLUTTER_STAGE_TYPE@
/**
* CLUTTER_NO_FPU:
*
@ -122,4 +131,5 @@
*/
#define CLUTTER_NO_FPU CLUTTER_NO_FPU_MACRO_WAS_REMOVED
#endif /* __CLUTTER_VERSION_H__ */

View File

@ -45,6 +45,7 @@
#include "../clutter-main.h"
#include "../clutter-debug.h"
#include "../clutter-private.h"
#include "../clutter-version.h"
#include "cogl.h"
@ -388,7 +389,7 @@ clutter_backend_glx_redraw (ClutterBackend *backend, ClutterStage *stage)
}
}
ClutterActor*
static ClutterActor*
clutter_backend_glx_create_stage (ClutterBackend *backend,
GError **error)
{
@ -396,7 +397,7 @@ clutter_backend_glx_create_stage (ClutterBackend *backend,
ClutterStageX11 *stage_x11;
ClutterActor *stage;
stage = g_object_new (CLUTTER_TYPE_STAGE_GLX, NULL);
stage = g_object_new (CLUTTER_STAGE_TYPE, NULL);
/* copy backend data into the stage */
stage_x11 = CLUTTER_STAGE_X11 (stage);

View File

@ -56,6 +56,8 @@ clutter_stage_glx_unrealize (ClutterActor *actor)
ClutterStageX11 *stage_x11 = CLUTTER_STAGE_X11 (actor);
ClutterStageGLX *stage_glx = CLUTTER_STAGE_GLX (actor);
/* Note unrealize should free up any backend stage related resources */
gboolean was_offscreen;
CLUTTER_MARK();