diff --git a/README.in b/README.in index 2335d21ea..433de68b2 100644 --- a/README.in +++ b/README.in @@ -289,6 +289,12 @@ features). Release Notes for Clutter 1.10 ------------------------------------------------------------------------------- +• The "default stage" has been deprecated; since the 1.0 release, the default + stage creation was deferred to the call to clutter_stage_get_default(), and + the preferred way for getting a ClutterStage was calling clutter_stage_new() + instead. On platforms that do not support multiple stages, attempting to + create more than one stage will lead to an error, and Clutter will abort. + • Clutter can support multiple backends in the same shared library. Only one windowing or input backend can be used at run time. As a result of this change, the shared library name used by Clutter has changed from: diff --git a/clutter/cally/cally-actor.c b/clutter/cally/cally-actor.c index b3bf24f70..73b972fc7 100644 --- a/clutter/cally/cally-actor.c +++ b/clutter/cally/cally-actor.c @@ -551,14 +551,12 @@ cally_actor_ref_state_set (AtkObject *obj) atk_state_set_add_state (state_set, ATK_STATE_FOCUSABLE); stage = CLUTTER_STAGE (clutter_actor_get_stage (actor)); - /* If for any reason this actor doesn't have a stage - associated, we try the default one as fallback */ - if (stage == NULL) - stage = CLUTTER_STAGE (clutter_stage_get_default ()); - - focus_actor = clutter_stage_get_key_focus (stage); - if (focus_actor == actor) - atk_state_set_add_state (state_set, ATK_STATE_FOCUSED); + if (stage != NULL) + { + focus_actor = clutter_stage_get_key_focus (stage); + if (focus_actor == actor) + atk_state_set_add_state (state_set, ATK_STATE_FOCUSED); + } } return state_set; diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c index 5a66c16ae..3c2040681 100644 --- a/clutter/clutter-actor.c +++ b/clutter/clutter-actor.c @@ -12575,7 +12575,7 @@ _clutter_actor_foreach_child (ClutterActor *self, /* For debugging purposes this gives us a simple way to print out * the scenegraph e.g in gdb using: * [| - * _clutter_actor_traverse (clutter_stage_get_default (), + * _clutter_actor_traverse (stage, * 0, * _clutter_debug_print_actor_cb, * NULL, diff --git a/clutter/clutter-backend.c b/clutter/clutter-backend.c index fe9cba798..1851d1da0 100644 --- a/clutter/clutter-backend.c +++ b/clutter/clutter-backend.c @@ -684,14 +684,11 @@ _clutter_backend_create_stage (ClutterBackend *backend, GError **error) { ClutterBackendClass *klass; - ClutterStageManager *stage_manager; ClutterStageWindow *stage_window; g_assert (CLUTTER_IS_BACKEND (backend)); g_assert (CLUTTER_IS_STAGE (wrapper)); - stage_manager = clutter_stage_manager_get_default (); - klass = CLUTTER_BACKEND_GET_CLASS (backend); if (klass->create_stage != NULL) stage_window = klass->create_stage (backend, wrapper, error); @@ -702,8 +699,6 @@ _clutter_backend_create_stage (ClutterBackend *backend, return NULL; g_assert (CLUTTER_IS_STAGE_WINDOW (stage_window)); - _clutter_stage_set_window (wrapper, stage_window); - _clutter_stage_manager_add_stage (stage_manager, wrapper); return stage_window; } diff --git a/clutter/clutter-script-parser.c b/clutter/clutter-script-parser.c index dd36ac944..625f20493 100644 --- a/clutter/clutter-script-parser.c +++ b/clutter/clutter-script-parser.c @@ -43,6 +43,8 @@ #include "clutter-script-private.h" #include "clutter-scriptable.h" +#include "clutter-stage-manager.h" + #include "clutter-private.h" static void clutter_script_parser_object_end (JsonParser *parser, @@ -1966,7 +1968,9 @@ _clutter_script_construct_object (ClutterScript *script, if (oinfo->is_stage && oinfo->is_stage_default) { + ClutterStageManager *manager = clutter_stage_manager_get_default (); GList *properties = oinfo->properties; + ClutterStage *default_stage; /* the default stage is a complex beast: we cannot create it using * g_object_newv() but we need clutter_script_construct_parameters() @@ -1981,7 +1985,8 @@ _clutter_script_construct_object (ClutterScript *script, properties, ¶ms); - oinfo->object = G_OBJECT (clutter_stage_get_default ()); + default_stage = clutter_stage_manager_get_default_stage (manager); + oinfo->object = G_OBJECT (default_stage); for (i = 0; i < params->len; i++) { diff --git a/clutter/clutter-stage.c b/clutter/clutter-stage.c index 416ca4f7c..60370f1c8 100644 --- a/clutter/clutter-stage.c +++ b/clutter/clutter-stage.c @@ -30,11 +30,6 @@ * #ClutterStage is a top level 'window' on which child actors are placed * and manipulated. * - * Clutter creates a default stage upon initialization, which can be retrieved - * using clutter_stage_get_default(). Clutter always provides the default - * stage, unless the backend is unable to create one. The stage returned - * by clutter_stage_get_default() is guaranteed to always be the same. - * * Backends might provide support for multiple stages. The support for this * feature can be checked at run-time using the clutter_feature_available() * function and the %CLUTTER_FEATURE_STAGE_MULTIPLE flag. If the backend used @@ -281,6 +276,23 @@ queue_full_redraw (ClutterStage *stage) _clutter_stage_window_add_redraw_clip (stage_window, NULL); } +static gboolean +stage_is_default (ClutterStage *stage) +{ + ClutterStageManager *stage_manager; + ClutterStageWindow *impl; + + stage_manager = clutter_stage_manager_get_default (); + if (stage != clutter_stage_manager_get_default_stage (stage_manager)) + return FALSE; + + impl = _clutter_stage_get_window (stage); + if (impl != _clutter_stage_get_default_window ()) + return FALSE; + + return TRUE; +} + static void clutter_stage_allocate (ClutterActor *self, const ClutterActorBox *box, @@ -1477,7 +1489,7 @@ static gboolean clutter_stage_real_delete_event (ClutterStage *stage, ClutterEvent *event) { - if (clutter_stage_is_default (stage)) + if (stage_is_default (stage)) clutter_main_quit (); else clutter_actor_destroy (CLUTTER_ACTOR (stage)); @@ -1497,6 +1509,45 @@ clutter_stage_real_apply_transform (ClutterActor *stage, cogl_matrix_multiply (matrix, matrix, &priv->view); } +static void +clutter_stage_constructed (GObject *gobject) +{ + ClutterStage *self = CLUTTER_STAGE (gobject); + ClutterStageManager *stage_manager; + + stage_manager = clutter_stage_manager_get_default (); + + _clutter_stage_manager_add_stage (stage_manager, self); + + /* if this stage has been created on a backend that does not + * support multiple stages then it becomes the default stage + * as well; any other attempt at creating a ClutterStage will + * fail. + */ + if (!clutter_feature_available (CLUTTER_FEATURE_STAGE_MULTIPLE)) + { + if (G_UNLIKELY (clutter_stage_manager_get_default_stage (stage_manager) != NULL)) + { + g_error ("Unable to create another stage: the backend of " + "type '%s' does not support multiple stages. Use " + "clutter_stage_get_default() instead to access the " + "stage singleton.", + G_OBJECT_TYPE_NAME (clutter_get_default_backend ())); + } + + /* This will take care of automatically adding the stage to the + * stage manager and setting it as the default. Its floating + * reference will be claimed by the stage manager. + */ + _clutter_stage_manager_set_default_stage (stage_manager, self); + + /* the default stage is realized by default */ + clutter_actor_realize (CLUTTER_ACTOR (self)); + } + + G_OBJECT_CLASS (clutter_stage_parent_class)->constructed (gobject); +} + static void clutter_stage_set_property (GObject *object, guint prop_id, @@ -1696,6 +1747,7 @@ clutter_stage_class_init (ClutterStageClass *klass) ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass); GParamSpec *pspec; + gobject_class->constructed = clutter_stage_constructed; gobject_class->set_property = clutter_stage_set_property; gobject_class->get_property = clutter_stage_get_property; gobject_class->dispose = clutter_stage_dispose; @@ -2037,8 +2089,10 @@ static void clutter_stage_init (ClutterStage *self) { ClutterStagePrivate *priv; + ClutterStageWindow *impl; ClutterBackend *backend; cairo_rectangle_int_t geom; + GError *error; /* a stage is a top-level object */ CLUTTER_SET_PRIVATE_FLAGS (self, CLUTTER_IS_TOPLEVEL); @@ -2047,25 +2101,31 @@ clutter_stage_init (ClutterStage *self) CLUTTER_NOTE (BACKEND, "Creating stage from the default backend"); backend = clutter_get_default_backend (); - priv->impl = _clutter_backend_create_stage (backend, self, NULL); - if (!priv->impl) - { - g_warning ("Unable to create a new stage, falling back to the " - "default stage."); - priv->impl = _clutter_stage_get_default_window (); - /* at this point we must have a default stage, or we're screwed */ - g_assert (priv->impl != NULL); + error = NULL; + impl = _clutter_backend_create_stage (backend, self, &error); + if (G_UNLIKELY (impl == NULL)) + { + if (error != NULL) + { + g_critical ("Unable to create a new stage implementation: %s", + error->message); + g_error_free (error); + } + else + g_critical ("Unable to create a new stage implementation."); } + _clutter_stage_set_window (self, impl); + priv->event_queue = g_queue_new (); - priv->is_fullscreen = FALSE; - priv->is_user_resizable = FALSE; - priv->is_cursor_visible = TRUE; - priv->use_fog = FALSE; + priv->is_fullscreen = FALSE; + priv->is_user_resizable = FALSE; + priv->is_cursor_visible = TRUE; + priv->use_fog = FALSE; priv->throttle_motion_events = TRUE; - priv->min_size_changed = FALSE; + priv->min_size_changed = FALSE; /* XXX - we need to keep the invariant that calling * clutter_set_motion_event_enabled() before the stage creation @@ -2133,16 +2193,29 @@ clutter_stage_init (ClutterStage *self) /** * clutter_stage_get_default: * - * Returns the main stage. The default #ClutterStage is a singleton, - * so the stage will be created the first time this function is - * called (typically, inside clutter_init()); all the subsequent - * calls to clutter_stage_get_default() will return the same instance. + * Retrieves a #ClutterStage singleton. * - * Clutter guarantess the existence of the default stage. + * This function is not as useful as it sounds, and will most likely + * by deprecated in the future. Application code should only create + * a #ClutterStage instance using clutter_stage_new(), and manage the + * lifetime of the stage manually. + * + * The default stage singleton has a platform-specific behaviour: on + * platforms without the %CLUTTER_FEATURE_STAGE_MULTIPLE feature flag + * set, the first #ClutterStage instance will also be set to be the + * default stage instance, and this function will always return a + * pointer to it. + * + * On platforms with the %CLUTTER_FEATURE_STAGE_MULTIPLE feature flag + * set, the default stage will be created by the first call to this + * function, and every following call will return the same pointer to + * it. * * Return value: (transfer none) (type Clutter.Stage): the main - * #ClutterStage. You should never destroy or unref the returned + * #ClutterStage. You should never destroy or unref the returned * actor. + * + * Deprecated: 1.10: Use clutter_stage_new() instead. */ ClutterActor * clutter_stage_get_default (void) @@ -3149,16 +3222,6 @@ G_DEFINE_BOXED_TYPE (ClutterFog, clutter_fog, clutter_fog_copy, clutter_fog_free ClutterActor * clutter_stage_new (void) { - if (!clutter_feature_available (CLUTTER_FEATURE_STAGE_MULTIPLE)) - { - g_warning ("Unable to create a new stage: the %s backend does not " - "support multiple stages.", - CLUTTER_FLAVOUR); - return NULL; - } - - /* The stage manager will grab the floating reference when the stage - is added to it in the constructor */ return g_object_new (CLUTTER_TYPE_STAGE, NULL); } @@ -3453,24 +3516,17 @@ clutter_stage_queue_redraw (ClutterStage *stage) * Return value: %TRUE if the passed stage is the default one * * Since: 0.8 + * + * Deprecated: 1.10: Track the stage pointer inside your application + * code, or use clutter_actor_get_stage() to retrieve the stage for + * a given actor. */ gboolean clutter_stage_is_default (ClutterStage *stage) { - ClutterStageManager *stage_manager; - ClutterStageWindow *impl; - g_return_val_if_fail (CLUTTER_IS_STAGE (stage), FALSE); - stage_manager = clutter_stage_manager_get_default (); - if (stage != clutter_stage_manager_get_default_stage (stage_manager)) - return FALSE; - - impl = _clutter_stage_get_window (stage); - if (impl != _clutter_stage_get_default_window ()) - return FALSE; - - return TRUE; + return stage_is_default (stage); } void @@ -3480,7 +3536,7 @@ _clutter_stage_set_window (ClutterStage *stage, g_return_if_fail (CLUTTER_IS_STAGE (stage)); g_return_if_fail (CLUTTER_IS_STAGE_WINDOW (stage_window)); - if (stage->priv->impl) + if (stage->priv->impl != NULL) g_object_unref (stage->priv->impl); stage->priv->impl = stage_window; diff --git a/clutter/clutter-stage.h b/clutter/clutter-stage.h index 4606d5200..6ca0f71de 100644 --- a/clutter/clutter-stage.h +++ b/clutter/clutter-stage.h @@ -146,7 +146,6 @@ GType clutter_perspective_get_type (void) G_GNUC_CONST; GType clutter_fog_get_type (void) G_GNUC_CONST; GType clutter_stage_get_type (void) G_GNUC_CONST; -ClutterActor *clutter_stage_get_default (void); ClutterActor *clutter_stage_new (void); void clutter_stage_set_color (ClutterStage *stage, @@ -194,7 +193,6 @@ void clutter_stage_set_key_focus (ClutterStage *stage, ClutterActor * clutter_stage_get_key_focus (ClutterStage *stage); void clutter_stage_ensure_current (ClutterStage *stage); void clutter_stage_queue_redraw (ClutterStage *stage); -gboolean clutter_stage_is_default (ClutterStage *stage); void clutter_stage_ensure_viewport (ClutterStage *stage); void clutter_stage_ensure_redraw (ClutterStage *stage); diff --git a/clutter/deprecated/clutter-stage.h b/clutter/deprecated/clutter-stage.h index 98d16da76..8d1951afa 100644 --- a/clutter/deprecated/clutter-stage.h +++ b/clutter/deprecated/clutter-stage.h @@ -40,6 +40,12 @@ G_BEGIN_DECLS #endif /* CLUTTER_DISABLE_DEPRECATED */ +CLUTTER_DEPRECATED_FOR(clutter_stage_new) +ClutterActor * clutter_stage_get_default (void); + +CLUTTER_DEPRECATED +gboolean clutter_stage_is_default (ClutterStage *stage); + G_END_DECLS #endif /* __CLUTTER_STAGE_DEPRECATED_H__ */ diff --git a/clutter/evdev/clutter-device-manager-evdev.c b/clutter/evdev/clutter-device-manager-evdev.c index 26079f1d2..caa135551 100644 --- a/clutter/evdev/clutter-device-manager-evdev.c +++ b/clutter/evdev/clutter-device-manager-evdev.c @@ -44,6 +44,7 @@ #include "clutter-input-device-evdev.h" #include "clutter-main.h" #include "clutter-private.h" +#include "clutter-stage-manager.h" #include "clutter-xkb-utils.h" #include "clutter-device-manager-evdev.h" @@ -268,9 +269,14 @@ clutter_event_dispatch (GSource *g_source, ClutterEvent *event; gint len, i, dx = 0, dy = 0; uint32_t _time; + ClutterStageManager *stage_manager; + ClutterStage *default_stage; clutter_threads_enter (); + stage_manager = clutter_stage_manager_get_default (); + default_stage = clutter_stage_manager_get_default_stage (stage_manager); + /* Don't queue more events if we haven't finished handling the previous batch */ if (!clutter_events_pending ()) @@ -303,6 +309,10 @@ clutter_event_dispatch (GSource *g_source, goto out; } + /* Drop events if we don't have any stage to forward them to */ + if (!default_stage) + goto out; + for (i = 0; i < len / sizeof (ev[0]); i++) { struct input_event *e = &ev[i]; @@ -530,7 +540,6 @@ evdev_add_device (ClutterDeviceManagerEvdev *manager_evdev, ClutterDeviceManager *manager = (ClutterDeviceManager *) manager_evdev; ClutterInputDeviceType type = CLUTTER_EXTENSION_DEVICE; ClutterInputDevice *device; - ClutterActor *stage; const gchar *device_file, *sysfs_path, *device_name; device_file = g_udev_device_get_device_file (udev_device); @@ -573,10 +582,6 @@ evdev_add_device (ClutterDeviceManagerEvdev *manager_evdev, "enabled", TRUE, NULL); - /* Always associate the device to the default stage */ - stage = clutter_stage_get_default (); - _clutter_input_device_set_stage (device, CLUTTER_STAGE (stage)); - _clutter_device_manager_add_device (manager, device); CLUTTER_NOTE (EVENT, "Added device %s, type %d, sysfs %s", diff --git a/doc/cookbook/examples/animations-looping-animator.c b/doc/cookbook/examples/animations-looping-animator.c index 892ddaf16..eb926ea75 100644 --- a/doc/cookbook/examples/animations-looping-animator.c +++ b/doc/cookbook/examples/animations-looping-animator.c @@ -29,7 +29,7 @@ main (int argc, if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_actor_set_size (stage, 300, 200); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); diff --git a/doc/cookbook/examples/animations-looping-implicit.c b/doc/cookbook/examples/animations-looping-implicit.c index 0b23495c0..4ea03b258 100644 --- a/doc/cookbook/examples/animations-looping-implicit.c +++ b/doc/cookbook/examples/animations-looping-implicit.c @@ -39,7 +39,7 @@ main (int argc, if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_actor_set_size (stage, 300, 200); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); diff --git a/doc/cookbook/examples/animations-looping-state.c b/doc/cookbook/examples/animations-looping-state.c index de39233e6..43edb59cd 100644 --- a/doc/cookbook/examples/animations-looping-state.c +++ b/doc/cookbook/examples/animations-looping-state.c @@ -40,7 +40,7 @@ main (int argc, if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_actor_set_size (stage, 300, 200); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); diff --git a/doc/cookbook/examples/animations-moving-animator.c b/doc/cookbook/examples/animations-moving-animator.c index 03de11201..b13d57c12 100644 --- a/doc/cookbook/examples/animations-moving-animator.c +++ b/doc/cookbook/examples/animations-moving-animator.c @@ -79,7 +79,7 @@ if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) state->animator = clutter_animator_new (); clutter_animator_set_duration (state->animator, 500); - state->stage = clutter_stage_get_default (); + state->stage = clutter_stage_new (); clutter_actor_set_size (state->stage, 400, 350); clutter_stage_set_color (CLUTTER_STAGE (state->stage), &stage_color); g_signal_connect (state->stage, diff --git a/doc/cookbook/examples/animations-moving-implicit.c b/doc/cookbook/examples/animations-moving-implicit.c index d1e57dae4..79083e6ab 100644 --- a/doc/cookbook/examples/animations-moving-implicit.c +++ b/doc/cookbook/examples/animations-moving-implicit.c @@ -47,7 +47,7 @@ main (int argc, if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_actor_set_size (stage, 500, 500); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); diff --git a/doc/cookbook/examples/animations-moving-state.c b/doc/cookbook/examples/animations-moving-state.c index a76edabde..12086165b 100644 --- a/doc/cookbook/examples/animations-moving-state.c +++ b/doc/cookbook/examples/animations-moving-state.c @@ -30,7 +30,7 @@ main (int argc, if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_actor_set_size (stage, 650, 500); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); diff --git a/doc/cookbook/examples/animations-rotating.c b/doc/cookbook/examples/animations-rotating.c index 8c6237b2a..411d5b849 100644 --- a/doc/cookbook/examples/animations-rotating.c +++ b/doc/cookbook/examples/animations-rotating.c @@ -42,7 +42,7 @@ main (int argc, char *argv[]) if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); texture = clutter_texture_new (); diff --git a/doc/cookbook/examples/animations-scaling-zoom.c b/doc/cookbook/examples/animations-scaling-zoom.c index b78fccc8a..aa051c4bb 100644 --- a/doc/cookbook/examples/animations-scaling-zoom.c +++ b/doc/cookbook/examples/animations-scaling-zoom.c @@ -109,7 +109,7 @@ main (int argc, if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_actor_set_size (stage, STAGE_SIDE, STAGE_SIDE); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); diff --git a/doc/cookbook/examples/animations-scaling.c b/doc/cookbook/examples/animations-scaling.c index fe69bde16..8fd5946e1 100644 --- a/doc/cookbook/examples/animations-scaling.c +++ b/doc/cookbook/examples/animations-scaling.c @@ -117,7 +117,7 @@ main (int argc, if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_actor_set_size (stage, 350, 350); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); diff --git a/doc/cookbook/examples/events-buttons-click.c b/doc/cookbook/examples/events-buttons-click.c index 263aa89dc..f94bc7938 100644 --- a/doc/cookbook/examples/events-buttons-click.c +++ b/doc/cookbook/examples/events-buttons-click.c @@ -26,7 +26,7 @@ main (int argc, if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_actor_set_size (stage, 400, 400); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); diff --git a/doc/cookbook/examples/events-buttons-lasso.c b/doc/cookbook/examples/events-buttons-lasso.c index c5597f9b5..16d37c6ac 100644 --- a/doc/cookbook/examples/events-buttons-lasso.c +++ b/doc/cookbook/examples/events-buttons-lasso.c @@ -125,7 +125,7 @@ main (int argc, if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_actor_set_size (stage, 320, 240); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); diff --git a/doc/cookbook/examples/events-buttons.c b/doc/cookbook/examples/events-buttons.c index 92129a01d..87f456fc1 100644 --- a/doc/cookbook/examples/events-buttons.c +++ b/doc/cookbook/examples/events-buttons.c @@ -60,7 +60,7 @@ main (int argc, if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_actor_set_size (stage, 400, 400); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); diff --git a/doc/cookbook/examples/events-mouse-scroll.c b/doc/cookbook/examples/events-mouse-scroll.c index 785e6c293..07cc0cb99 100644 --- a/doc/cookbook/examples/events-mouse-scroll.c +++ b/doc/cookbook/examples/events-mouse-scroll.c @@ -78,8 +78,9 @@ main (int argc, char *argv[]) if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_actor_set_size (stage, STAGE_WIDTH, STAGE_HEIGHT); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); /* the scrollable actor */ texture = clutter_texture_new (); diff --git a/doc/cookbook/examples/events-pointer-motion-crossing.c b/doc/cookbook/examples/events-pointer-motion-crossing.c index 0d21001a1..03852bb9a 100644 --- a/doc/cookbook/examples/events-pointer-motion-crossing.c +++ b/doc/cookbook/examples/events-pointer-motion-crossing.c @@ -37,7 +37,7 @@ main (int argc, char *argv[]) if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); clutter_stage_set_title (CLUTTER_STAGE (stage), "btn"); diff --git a/doc/cookbook/examples/events-pointer-motion-scribbler.c b/doc/cookbook/examples/events-pointer-motion-scribbler.c index 9337c0047..4d5168dc9 100644 --- a/doc/cookbook/examples/events-pointer-motion-scribbler.c +++ b/doc/cookbook/examples/events-pointer-motion-scribbler.c @@ -115,9 +115,10 @@ main (int argc, char *argv[]) cogl_path_new (); context->cogl_path = cogl_get_path (); - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_actor_set_size (stage, 400, 400); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); rect = clutter_rectangle_new_with_color (&actor_color); clutter_actor_set_size (rect, 300, 300); diff --git a/doc/cookbook/examples/events-pointer-motion-stacked.c b/doc/cookbook/examples/events-pointer-motion-stacked.c index 7a3d13866..f92fa0298 100644 --- a/doc/cookbook/examples/events-pointer-motion-stacked.c +++ b/doc/cookbook/examples/events-pointer-motion-stacked.c @@ -53,9 +53,10 @@ main (int argc, char *argv[]) if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_actor_set_size (stage, 300, 300); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); r1 = clutter_rectangle_new_with_color (&red); clutter_actor_set_size (r1, 150, 150); diff --git a/doc/cookbook/examples/events-pointer-motion.c b/doc/cookbook/examples/events-pointer-motion.c index 355f9c15b..0a96bd7f1 100644 --- a/doc/cookbook/examples/events-pointer-motion.c +++ b/doc/cookbook/examples/events-pointer-motion.c @@ -32,9 +32,10 @@ main (int argc, char *argv[]) if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_actor_set_size (stage, 400, 400); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); rectangle = clutter_rectangle_new_with_color (&rectangle_color); clutter_actor_set_size (rectangle, 300, 300); diff --git a/doc/cookbook/examples/layouts-bind-constraint-allocation.c b/doc/cookbook/examples/layouts-bind-constraint-allocation.c index 7d38dd539..a48733135 100644 --- a/doc/cookbook/examples/layouts-bind-constraint-allocation.c +++ b/doc/cookbook/examples/layouts-bind-constraint-allocation.c @@ -38,7 +38,7 @@ main (int argc, char *argv[]) if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_actor_set_size (stage, 400, 400); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); diff --git a/doc/cookbook/examples/layouts-box-menu.c b/doc/cookbook/examples/layouts-box-menu.c index e76c4a829..136f95ff3 100644 --- a/doc/cookbook/examples/layouts-box-menu.c +++ b/doc/cookbook/examples/layouts-box-menu.c @@ -91,7 +91,7 @@ main (int argc, if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_actor_set_size (stage, 400, 400); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); diff --git a/doc/cookbook/examples/layouts-box-property-effects.c b/doc/cookbook/examples/layouts-box-property-effects.c index 6557d5d3f..b712b91ec 100644 --- a/doc/cookbook/examples/layouts-box-property-effects.c +++ b/doc/cookbook/examples/layouts-box-property-effects.c @@ -322,7 +322,7 @@ main (int argc, state->expand = FALSE; state->x_align = CLUTTER_BOX_ALIGNMENT_START; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_actor_set_size (stage, STAGE_SIDE, STAGE_SIDE); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); diff --git a/doc/cookbook/examples/layouts-box.c b/doc/cookbook/examples/layouts-box.c index e489f8f1f..9b2b40b7c 100644 --- a/doc/cookbook/examples/layouts-box.c +++ b/doc/cookbook/examples/layouts-box.c @@ -21,7 +21,7 @@ main (int argc, if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_actor_set_size (stage, 400, 400); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); diff --git a/doc/cookbook/examples/layouts-stacking-diff-sized-actors.c b/doc/cookbook/examples/layouts-stacking-diff-sized-actors.c index b302a2384..45f47e181 100644 --- a/doc/cookbook/examples/layouts-stacking-diff-sized-actors.c +++ b/doc/cookbook/examples/layouts-stacking-diff-sized-actors.c @@ -17,8 +17,9 @@ main (int argc, char *argv[]) if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_actor_set_size (stage, 400, 400); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_START, CLUTTER_BIN_ALIGNMENT_START); diff --git a/doc/cookbook/examples/layouts-stacking.c b/doc/cookbook/examples/layouts-stacking.c index f68f25b20..4fda817e0 100644 --- a/doc/cookbook/examples/layouts-stacking.c +++ b/doc/cookbook/examples/layouts-stacking.c @@ -28,8 +28,9 @@ main (int argc, char *argv[]) if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_actor_set_size (stage, STAGE_SIDE, STAGE_SIDE); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER, CLUTTER_BIN_ALIGNMENT_CENTER); diff --git a/doc/cookbook/examples/textures-crossfade-cogl.c b/doc/cookbook/examples/textures-crossfade-cogl.c index b01e508b7..6c111b1f5 100644 --- a/doc/cookbook/examples/textures-crossfade-cogl.c +++ b/doc/cookbook/examples/textures-crossfade-cogl.c @@ -149,7 +149,7 @@ main (int argc, char *argv[]) * assign the material we created earlier to the Texture for painting * it */ - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_stage_set_title (CLUTTER_STAGE (stage), "cross-fade"); clutter_actor_set_size (stage, 400, 300); clutter_actor_show (stage); diff --git a/doc/cookbook/examples/textures-crossfade-slideshow.c b/doc/cookbook/examples/textures-crossfade-slideshow.c index 983a66a56..1a8b3ef58 100644 --- a/doc/cookbook/examples/textures-crossfade-slideshow.c +++ b/doc/cookbook/examples/textures-crossfade-slideshow.c @@ -125,7 +125,7 @@ main (int argc, char *argv[]) if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); clutter_stage_set_title (CLUTTER_STAGE (stage), "cross-fade"); clutter_actor_set_size (stage, stage_side, stage_side); diff --git a/doc/cookbook/examples/textures-crossfade.c b/doc/cookbook/examples/textures-crossfade.c index aa62d46c0..6fbd53adf 100644 --- a/doc/cookbook/examples/textures-crossfade.c +++ b/doc/cookbook/examples/textures-crossfade.c @@ -85,7 +85,7 @@ main (int argc, char *argv[]) if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_stage_set_title (CLUTTER_STAGE (stage), "cross-fade"); clutter_actor_set_size (stage, 400, 300); clutter_actor_show (stage); diff --git a/doc/cookbook/examples/textures-split-go.c b/doc/cookbook/examples/textures-split-go.c index f6922b784..540bc7d0d 100644 --- a/doc/cookbook/examples/textures-split-go.c +++ b/doc/cookbook/examples/textures-split-go.c @@ -117,9 +117,10 @@ main (int argc, if (clutter_init (NULL, NULL) != CLUTTER_INIT_SUCCESS) return 1; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_actor_get_size (stage, &stage_width, &stage_height); clutter_stage_set_title (CLUTTER_STAGE (stage), "Animate sub-textures"); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); /* Load smiley.png, creating a new ClutterTexture, get its size and the * Cogl texture handle */ diff --git a/doc/cookbook/examples/textures-sub-texture.c b/doc/cookbook/examples/textures-sub-texture.c index 9b2af8554..95fa263f1 100644 --- a/doc/cookbook/examples/textures-sub-texture.c +++ b/doc/cookbook/examples/textures-sub-texture.c @@ -12,8 +12,9 @@ main (int argc, char **argv) return 1; /* Get the default stage */ - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_stage_set_title (CLUTTER_STAGE (stage), "Sub-texture"); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); /* Create a new ClutterTexture that shows smiley.png */ image = clutter_texture_new_from_file ("smiley.png", NULL); diff --git a/doc/reference/clutter/clutter-animation-tutorial.xml b/doc/reference/clutter/clutter-animation-tutorial.xml index 8860aa41e..7340dc49d 100644 --- a/doc/reference/clutter/clutter-animation-tutorial.xml +++ b/doc/reference/clutter/clutter-animation-tutorial.xml @@ -302,7 +302,8 @@ main (int argc, char *argv[]) if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); actor = clutter_texture_new_from_file ("ohpowers.png", NULL); clutter_container_add_actor (CLUTTER_CONTAINER (stage), actor); diff --git a/tests/accessibility/cally-atkcomponent-example.c b/tests/accessibility/cally-atkcomponent-example.c index 7d4ebcd08..79a816bde 100644 --- a/tests/accessibility/cally-atkcomponent-example.c +++ b/tests/accessibility/cally-atkcomponent-example.c @@ -45,11 +45,14 @@ main (int argc, char *argv[]) cally_util_a11y_init (&argc, &argv); - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); + clutter_stage_set_title (CLUTTER_STAGE (stage), "Cally - AtkComponent Test"); clutter_stage_set_color (CLUTTER_STAGE (stage), CLUTTER_COLOR_White); clutter_actor_set_size (stage, WIDTH, HEIGHT); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); + button1 = clutter_rectangle_new_with_color (CLUTTER_COLOR_Yellow); clutter_actor_set_size (button1, SIZE, SIZE); diff --git a/tests/accessibility/cally-atkeditabletext-example.c b/tests/accessibility/cally-atkeditabletext-example.c index d13913819..433ee9270 100644 --- a/tests/accessibility/cally-atkeditabletext-example.c +++ b/tests/accessibility/cally-atkeditabletext-example.c @@ -148,15 +148,14 @@ _create_button (const gchar *text) ClutterActor *button = NULL; ClutterActor *rectangle = NULL; ClutterActor *label = NULL; - ClutterColor color_rect = { 0x00, 0xff, 0xff, 0xff }; - ClutterColor color_label = { 0x00, 0x00, 0x00, 0xff }; button = clutter_group_new (); - rectangle = clutter_rectangle_new_with_color (&color_rect); + rectangle = clutter_rectangle_new_with_color (CLUTTER_COLOR_Magenta); clutter_actor_set_size (rectangle, 375, 35); label = clutter_text_new_full ("Sans Bold 32px", - text, &color_label); + text, + CLUTTER_COLOR_Black); clutter_container_add_actor (CLUTTER_CONTAINER (button), rectangle); clutter_container_add_actor (CLUTTER_CONTAINER (button), label); clutter_actor_set_reactive (button, TRUE); @@ -164,33 +163,30 @@ _create_button (const gchar *text) return button; } - static void make_ui (ClutterActor *stage) { - ClutterColor color_stage = { 0x00, 0x00, 0x00, 0xff }; - ClutterColor color_text = { 0xff, 0x00, 0x00, 0xff }; - ClutterColor color_sel = { 0x00, 0xff, 0x00, 0x55 }; ClutterActor *button = NULL; - clutter_stage_set_color (CLUTTER_STAGE (stage), &color_stage); + clutter_stage_set_title (CLUTTER_STAGE (stage), "Cally - AtkEditable Test"); + clutter_stage_set_color (CLUTTER_STAGE (stage), CLUTTER_COLOR_White); clutter_actor_set_size (stage, WIDTH, HEIGHT); /* text */ text_actor = clutter_text_new_full ("Sans Bold 32px", "Lorem ipsum dolor sit amet", - &color_text); + CLUTTER_COLOR_Red); clutter_container_add_actor (CLUTTER_CONTAINER (stage), text_actor); /* text_editable */ text_editable_actor = clutter_text_new_full ("Sans Bold 32px", "consectetur adipisicing elit", - &color_text); + CLUTTER_COLOR_Red); clutter_actor_set_position (text_editable_actor, 0, 100); clutter_text_set_editable (CLUTTER_TEXT (text_editable_actor), TRUE); clutter_text_set_selectable (CLUTTER_TEXT (text_editable_actor), TRUE); clutter_text_set_selection_color (CLUTTER_TEXT (text_editable_actor), - &color_sel); + CLUTTER_COLOR_Green); clutter_text_set_activatable (CLUTTER_TEXT (text_editable_actor), TRUE); clutter_text_set_line_wrap (CLUTTER_TEXT (text_editable_actor), TRUE); @@ -256,7 +252,8 @@ main (int argc, char *argv[]) cally_util_a11y_init (&argc, &argv); - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); make_ui (stage); diff --git a/tests/accessibility/cally-atkevents-example.c b/tests/accessibility/cally-atkevents-example.c index ca0a00678..4a55c9f64 100644 --- a/tests/accessibility/cally-atkevents-example.c +++ b/tests/accessibility/cally-atkevents-example.c @@ -88,7 +88,6 @@ make_ui (ClutterActor *stage) ClutterActor *editable = NULL; ClutterActor *rectangle = NULL; ClutterActor *label = NULL; - ClutterColor color_text = { 0xff, 0x00, 0x00, 0xff }; ClutterColor color_sel = { 0x00, 0xff, 0x00, 0x55 }; ClutterColor color_label = { 0x00, 0xff, 0x55, 0xff }; ClutterColor color_rect = { 0x00, 0xff, 0xff, 0x55 }; @@ -111,7 +110,7 @@ make_ui (ClutterActor *stage) /* editable */ editable = clutter_text_new_full ("Sans Bold 32px", "ddd", - &color_text); + CLUTTER_COLOR_Red); clutter_actor_set_position (editable, 150, editable_geom_y); clutter_actor_set_size (editable, 500, 75); clutter_text_set_editable (CLUTTER_TEXT (editable), TRUE); @@ -138,8 +137,8 @@ make_ui (ClutterActor *stage) int main (int argc, char *argv[]) { - ClutterActor *stage = NULL; - Data data1, data2,data3; + ClutterActor *stage, *stage_main; + Data data1, data2, data3; guint id_2 = 0; g_set_application_name ("AtkText"); @@ -171,14 +170,19 @@ main (int argc, char *argv[]) atk_add_global_event_listener (window_event_listener, "Atk:AtkWindow:activate"); atk_add_global_event_listener (window_event_listener, "Atk:AtkWindow:deactivate"); - stage = clutter_stage_get_default (); - make_ui (stage); + stage_main = clutter_stage_new (); + clutter_stage_set_title (CLUTTER_STAGE (stage_main), "Cally - AtkEvents/1"); + g_signal_connect (stage_main, "destroy", G_CALLBACK (clutter_main_quit), NULL); + make_ui (stage_main); - clutter_actor_show_all (stage); + clutter_actor_show_all (stage_main); if (clutter_feature_available (CLUTTER_FEATURE_STAGE_MULTIPLE)) { stage = clutter_stage_new (); + clutter_stage_set_title (CLUTTER_STAGE (stage), "Cally - AtkEvents/2"); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); + make_ui (stage); clutter_actor_show_all (stage); } diff --git a/tests/accessibility/cally-atktext-example.c b/tests/accessibility/cally-atktext-example.c index 4d6099dc4..f7218ce60 100644 --- a/tests/accessibility/cally-atktext-example.c +++ b/tests/accessibility/cally-atktext-example.c @@ -237,13 +237,12 @@ make_ui (ClutterActor *stage) G_CALLBACK (button_press_cb), NULL); clutter_container_add_actor (CLUTTER_CONTAINER (stage), button); - } int main (int argc, char *argv[]) { - ClutterActor *stage = NULL; + ClutterActor *stage; g_set_application_name ("AtkText"); @@ -252,7 +251,9 @@ main (int argc, char *argv[]) cally_util_a11y_init (&argc, &argv); - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); + clutter_stage_set_title (CLUTTER_STAGE (stage), "Cally - AtkText Test"); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); make_ui (stage); diff --git a/tests/accessibility/cally-clone-example.c b/tests/accessibility/cally-clone-example.c index 04137c2a6..9cc2d6856 100644 --- a/tests/accessibility/cally-clone-example.c +++ b/tests/accessibility/cally-clone-example.c @@ -93,7 +93,7 @@ make_ui (ClutterActor *stage) int main (int argc, char *argv[]) { - ClutterActor *stage = NULL; + ClutterActor *stage; g_set_application_name ("Clone Example"); @@ -102,7 +102,10 @@ main (int argc, char *argv[]) cally_util_a11y_init (&argc, &argv); - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); + clutter_stage_set_title (CLUTTER_STAGE (stage), "Cally - Clone Test"); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); + make_ui (stage); clutter_actor_show_all (stage); diff --git a/tests/conform/test-actor-invariants.c b/tests/conform/test-actor-invariants.c index 5c3e2d034..0ecdb73f8 100644 --- a/tests/conform/test-actor-invariants.c +++ b/tests/conform/test-actor-invariants.c @@ -44,7 +44,7 @@ test_realized (TestConformSimpleFixture *fixture, ClutterActor *actor; ClutterActor *stage; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); actor = clutter_rectangle_new (); @@ -60,7 +60,7 @@ test_realized (TestConformSimpleFixture *fixture, g_assert (!(CLUTTER_ACTOR_IS_MAPPED (actor))); g_assert (!(CLUTTER_ACTOR_IS_VISIBLE (actor))); - clutter_actor_destroy (actor); + clutter_actor_destroy (stage); } void @@ -70,7 +70,7 @@ test_mapped (TestConformSimpleFixture *fixture, ClutterActor *actor; ClutterActor *stage; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_actor_show (stage); actor = clutter_rectangle_new (); @@ -85,8 +85,7 @@ test_mapped (TestConformSimpleFixture *fixture, g_assert (CLUTTER_ACTOR_IS_MAPPED (actor)); g_assert (CLUTTER_ACTOR_IS_VISIBLE (actor)); - clutter_actor_destroy (actor); - clutter_actor_hide (stage); + clutter_actor_destroy (stage); } void @@ -96,7 +95,7 @@ test_realize_not_recursive (TestConformSimpleFixture *fixture, ClutterActor *actor, *group; ClutterActor *stage; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_actor_show (stage); group = clutter_group_new (); @@ -126,8 +125,7 @@ test_realize_not_recursive (TestConformSimpleFixture *fixture, g_assert (!(CLUTTER_ACTOR_IS_MAPPED (actor))); g_assert (!(CLUTTER_ACTOR_IS_VISIBLE (actor))); - clutter_actor_destroy (group); - clutter_actor_hide (stage); + clutter_actor_destroy (stage); } void @@ -137,7 +135,7 @@ test_map_recursive (TestConformSimpleFixture *fixture, ClutterActor *actor, *group; ClutterActor *stage; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_actor_show (stage); group = clutter_group_new (); @@ -177,8 +175,7 @@ test_map_recursive (TestConformSimpleFixture *fixture, g_assert (CLUTTER_ACTOR_IS_VISIBLE (group)); g_assert (CLUTTER_ACTOR_IS_VISIBLE (actor)); - clutter_actor_destroy (group); - clutter_actor_hide (stage); + clutter_actor_destroy (stage); } void @@ -189,7 +186,7 @@ test_show_on_set_parent (TestConformSimpleFixture *fixture, gboolean show_on_set_parent; ClutterActor *stage; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); group = clutter_group_new (); @@ -227,6 +224,7 @@ test_show_on_set_parent (TestConformSimpleFixture *fixture, clutter_actor_destroy (actor); clutter_actor_destroy (group); + clutter_actor_destroy (stage); } void @@ -238,7 +236,7 @@ test_clone_no_map (TestConformSimpleFixture *fixture, ClutterActor *actor; ClutterActor *clone; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_actor_show (stage); group = clutter_group_new (); @@ -262,8 +260,7 @@ test_clone_no_map (TestConformSimpleFixture *fixture, clutter_actor_destroy (CLUTTER_ACTOR (clone)); clutter_actor_destroy (CLUTTER_ACTOR (group)); - - clutter_actor_hide (stage); + clutter_actor_destroy (stage); } void @@ -331,3 +328,20 @@ test_contains (TestConformSimpleFixture *fixture, ==, expected_results[x * 10 + y]); } + +void +default_stage (TestConformSimpleFixture *fixture, + gconstpointer data) +{ + ClutterActor *stage, *def_stage; + + stage = clutter_stage_new (); + def_stage = clutter_stage_get_default (); + + if (clutter_feature_available (CLUTTER_FEATURE_STAGE_MULTIPLE)) + g_assert (stage != def_stage); + else + g_assert (stage == def_stage); + + g_assert (CLUTTER_ACTOR_IS_REALIZED (def_stage)); +} diff --git a/tests/conform/test-anchors.c b/tests/conform/test-anchors.c index 8592a0640..238c39008 100644 --- a/tests/conform/test-anchors.c +++ b/tests/conform/test-anchors.c @@ -677,7 +677,7 @@ actor_anchors (void) TestState state; ClutterActor *stage; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); state.rect = clutter_rectangle_new (); clutter_container_add (CLUTTER_CONTAINER (stage), state.rect, NULL); @@ -699,6 +699,6 @@ actor_anchors (void) g_idle_remove_by_data (&state); - clutter_actor_destroy (state.rect); + clutter_actor_destroy (stage); } diff --git a/tests/conform/test-cally-text.c b/tests/conform/test-cally-text.c index ef17055b0..32d7afb70 100644 --- a/tests/conform/test-cally-text.c +++ b/tests/conform/test-cally-text.c @@ -279,7 +279,7 @@ cally_text (void) memset (&data, 0, sizeof (data)); - data.stage = clutter_stage_get_default (); + data.stage = clutter_stage_new (); data.default_attributes = default_attributes; data.run_attributes = build_attribute_set ("fg-color", "0,0,0", NULL); @@ -294,9 +294,8 @@ cally_text (void) data.extents_height = 17; clutter_actor_set_position (data.label, 20, 100); - memset (&data1, 0, sizeof (data1)); - data1.stage = clutter_stage_get_default (); + data1.stage = data.stage; data1.default_attributes = default_attributes; data1.run_attributes = build_attribute_set ("bg-color", "0,65535,0", "fg-color", "65535,65535,0", @@ -314,11 +313,12 @@ cally_text (void) clutter_actor_set_position (data1.label, 20, 200); data.next = &data1; - clutter_actor_show (data.stage); clutter_threads_add_idle ((GSourceFunc) do_tests, &data); clutter_main (); + clutter_actor_destroy (data.stage); + if (g_test_verbose ()) g_print ("\nOverall result: "); diff --git a/tests/conform/test-clutter-cairo-texture.c b/tests/conform/test-clutter-cairo-texture.c index a6b73c83b..4c87fcb93 100644 --- a/tests/conform/test-clutter-cairo-texture.c +++ b/tests/conform/test-clutter-cairo-texture.c @@ -169,7 +169,7 @@ test_clutter_cairo_texture (TestConformSimpleFixture *fixture, unsigned int paint_handler; state.frame = 0; - state.stage = clutter_stage_get_default (); + state.stage = clutter_stage_new (); state.progress = TEST_BEFORE_DRAW_FIRST_FRAME; state.ct = clutter_cairo_texture_new (BLOCK_SIZE * 2, BLOCK_SIZE); @@ -192,5 +192,7 @@ test_clutter_cairo_texture (TestConformSimpleFixture *fixture, if (g_test_verbose ()) g_print ("OK\n"); + + clutter_actor_destroy (state.stage); } diff --git a/tests/conform/test-clutter-texture.c b/tests/conform/test-clutter-texture.c index df0162c02..c13db2254 100644 --- a/tests/conform/test-clutter-texture.c +++ b/tests/conform/test-clutter-texture.c @@ -33,7 +33,7 @@ test_texture_pick_with_alpha (TestConformSimpleFixture *fixture, gconstpointer data) { ClutterTexture *tex = CLUTTER_TEXTURE (clutter_texture_new ()); - ClutterStage *stage = CLUTTER_STAGE (clutter_stage_get_default ()); + ClutterStage *stage = CLUTTER_STAGE (clutter_stage_new ()); ClutterActor *actor; clutter_texture_set_cogl_texture (tex, make_texture ()); @@ -81,7 +81,7 @@ test_texture_pick_with_alpha (TestConformSimpleFixture *fixture, g_print ("actor @ (10, 10) = %p\n", actor); g_assert (actor == CLUTTER_ACTOR (tex)); - clutter_actor_destroy (CLUTTER_ACTOR (tex)); + clutter_actor_destroy (CLUTTER_ACTOR (stage)); if (g_test_verbose ()) g_print ("OK\n"); diff --git a/tests/conform/test-cogl-backface-culling.c b/tests/conform/test-cogl-backface-culling.c index bcef760a8..5f139bfd1 100644 --- a/tests/conform/test-cogl-backface-culling.c +++ b/tests/conform/test-cogl-backface-culling.c @@ -298,7 +298,7 @@ test_cogl_backface_culling (TestConformSimpleFixture *fixture, ClutterActor *group; guint idle_source; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_actor_get_size (stage, &stage_width, &stage_height); state.offscreen = COGL_INVALID_HANDLE; @@ -333,7 +333,8 @@ test_cogl_backface_culling (TestConformSimpleFixture *fixture, cogl_handle_unref (state.offscreen_tex); cogl_handle_unref (state.texture); + clutter_actor_destroy (stage); + if (g_test_verbose ()) g_print ("OK\n"); } - diff --git a/tests/conform/test-cogl-blend-strings.c b/tests/conform/test-cogl-blend-strings.c index 852e722ed..a2a683769 100644 --- a/tests/conform/test-cogl-blend-strings.c +++ b/tests/conform/test-cogl-blend-strings.c @@ -405,7 +405,7 @@ test_cogl_blend_strings (TestConformSimpleFixture *fixture, ClutterActor *group; guint idle_source; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); clutter_actor_get_geometry (stage, &state.stage_geom); @@ -426,7 +426,8 @@ test_cogl_blend_strings (TestConformSimpleFixture *fixture, g_source_remove (idle_source); + clutter_actor_destroy (stage); + if (g_test_verbose ()) g_print ("OK\n"); } - diff --git a/tests/conform/test-cogl-depth-test.c b/tests/conform/test-cogl-depth-test.c index 335e55820..4e2a62531 100644 --- a/tests/conform/test-cogl-depth-test.c +++ b/tests/conform/test-cogl-depth-test.c @@ -308,7 +308,7 @@ test_cogl_depth_test (TestConformSimpleFixture *fixture, ClutterActor *group; guint idle_source; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); clutter_actor_get_geometry (stage, &state.stage_geom); @@ -329,7 +329,8 @@ test_cogl_depth_test (TestConformSimpleFixture *fixture, g_source_remove (idle_source); + clutter_actor_destroy (stage); + if (g_test_verbose ()) g_print ("OK\n"); } - diff --git a/tests/conform/test-cogl-just-vertex-shader.c b/tests/conform/test-cogl-just-vertex-shader.c index d0cceebba..df9fcc012 100644 --- a/tests/conform/test-cogl-just-vertex-shader.c +++ b/tests/conform/test-cogl-just-vertex-shader.c @@ -112,11 +112,11 @@ test_cogl_just_vertex_shader (TestConformSimpleFixture *fixture, ClutterActor *stage; guint paint_handler; - stage = clutter_stage_get_default (); - /* If shaders aren't supported then we can't run the test */ if (cogl_features_available (COGL_FEATURE_SHADERS_GLSL)) { + stage = clutter_stage_new (); + clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); paint_handler = g_signal_connect_after (stage, "paint", @@ -128,10 +128,11 @@ test_cogl_just_vertex_shader (TestConformSimpleFixture *fixture, g_signal_handler_disconnect (stage, paint_handler); + clutter_actor_destroy (stage); + if (g_test_verbose ()) g_print ("OK\n"); } else if (g_test_verbose ()) g_print ("Skipping\n"); } - diff --git a/tests/conform/test-cogl-materials.c b/tests/conform/test-cogl-materials.c index 0abf5641e..10039fcf3 100644 --- a/tests/conform/test-cogl-materials.c +++ b/tests/conform/test-cogl-materials.c @@ -325,7 +325,7 @@ test_cogl_materials (TestConformSimpleFixture *fixture, test_conform_get_gl_functions (&gl_functions); - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); clutter_actor_get_geometry (stage, &state.stage_geom); @@ -346,7 +346,8 @@ test_cogl_materials (TestConformSimpleFixture *fixture, g_source_remove (idle_source); + clutter_actor_destroy (stage); + if (g_test_verbose ()) g_print ("OK\n"); } - diff --git a/tests/conform/test-cogl-multitexture.c b/tests/conform/test-cogl-multitexture.c index 71c21f46b..ed88484ac 100644 --- a/tests/conform/test-cogl-multitexture.c +++ b/tests/conform/test-cogl-multitexture.c @@ -181,7 +181,7 @@ test_cogl_multitexture (TestConformSimpleFixture *fixture, ClutterActor *group; guint idle_source; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); @@ -201,6 +201,8 @@ test_cogl_multitexture (TestConformSimpleFixture *fixture, g_source_remove (idle_source); + clutter_actor_destroy (stage); + if (g_test_verbose ()) g_print ("OK\n"); } diff --git a/tests/conform/test-cogl-npot-texture.c b/tests/conform/test-cogl-npot-texture.c index 274ba03b3..3b21ba51d 100644 --- a/tests/conform/test-cogl-npot-texture.c +++ b/tests/conform/test-cogl-npot-texture.c @@ -32,15 +32,18 @@ static const ClutterColor corner_colors[PARTS * PARTS] = typedef struct _TestState { + ClutterActor *stage; guint frame; CoglHandle texture; } TestState; static gboolean -validate_part (int xnum, int ynum, const ClutterColor *color) +validate_part (ClutterActor *stage, + int xnum, + int ynum, + const ClutterColor *color) { guchar *pixels, *p; - ClutterActor *stage = clutter_stage_get_default (); gboolean ret = TRUE; /* Read the appropriate part but skip out a few pixels around the @@ -75,10 +78,10 @@ validate_result (TestState *state) { /* Validate that all four corners of the texture are drawn in the right color */ - g_assert (validate_part (0, 0, corner_colors + 0)); - g_assert (validate_part (1, 0, corner_colors + 1)); - g_assert (validate_part (0, 1, corner_colors + 2)); - g_assert (validate_part (1, 1, corner_colors + 3)); + g_assert (validate_part (state->stage, 0, 0, corner_colors + 0)); + g_assert (validate_part (state->stage, 1, 0, corner_colors + 1)); + g_assert (validate_part (state->stage, 0, 1, corner_colors + 2)); + g_assert (validate_part (state->stage, 1, 1, corner_colors + 3)); /* Comment this out if you want visual feedback of what this test * paints. @@ -208,7 +211,7 @@ test_cogl_npot_texture (TestConformSimpleFixture *fixture, state.texture = make_texture (); - stage = clutter_stage_get_default (); + state.stage = stage = clutter_stage_new (); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); @@ -230,7 +233,8 @@ test_cogl_npot_texture (TestConformSimpleFixture *fixture, cogl_handle_unref (state.texture); + clutter_actor_destroy (state.stage); + if (g_test_verbose ()) g_print ("OK\n"); } - diff --git a/tests/conform/test-cogl-offscreen.c b/tests/conform/test-cogl-offscreen.c index a7f67416c..72d63f195 100644 --- a/tests/conform/test-cogl-offscreen.c +++ b/tests/conform/test-cogl-offscreen.c @@ -142,7 +142,7 @@ test_cogl_offscreen (TestConformSimpleFixture *fixture, guint idle_source; ClutterActor *stage; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); /* We force continuous redrawing of the stage, since we need to skip @@ -156,12 +156,8 @@ test_cogl_offscreen (TestConformSimpleFixture *fixture, g_source_remove (idle_source); - /* Remove all of the actors from the stage */ - clutter_container_foreach (CLUTTER_CONTAINER (stage), - (ClutterCallback) clutter_actor_destroy, - NULL); + clutter_actor_destroy (stage); if (g_test_verbose ()) g_print ("OK\n"); } - diff --git a/tests/conform/test-cogl-path.c b/tests/conform/test-cogl-path.c index 1daa57f5b..0a4f1be78 100644 --- a/tests/conform/test-cogl-path.c +++ b/tests/conform/test-cogl-path.c @@ -212,7 +212,7 @@ test_cogl_path (TestConformSimpleFixture *fixture, unsigned int paint_handler; state.frame = 0; - state.stage = clutter_stage_get_default (); + state.stage = clutter_stage_new (); clutter_stage_set_color (CLUTTER_STAGE (state.stage), &stage_color); /* We force continuous redrawing of the stage, since we need to skip @@ -228,7 +228,8 @@ test_cogl_path (TestConformSimpleFixture *fixture, g_signal_handler_disconnect (state.stage, paint_handler); g_source_remove (idle_source); + clutter_actor_destroy (state.stage); + if (g_test_verbose ()) g_print ("OK\n"); } - diff --git a/tests/conform/test-cogl-pipeline-user-matrix.c b/tests/conform/test-cogl-pipeline-user-matrix.c index afbeaaf00..15a650407 100644 --- a/tests/conform/test-cogl-pipeline-user-matrix.c +++ b/tests/conform/test-cogl-pipeline-user-matrix.c @@ -119,7 +119,7 @@ test_cogl_pipeline_user_matrix (TestConformSimpleFixture *fixture, guint idle_source; guint paint_handler; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); @@ -139,6 +139,8 @@ test_cogl_pipeline_user_matrix (TestConformSimpleFixture *fixture, g_source_remove (idle_source); g_signal_handler_disconnect (stage, paint_handler); + clutter_actor_destroy (stage); + if (g_test_verbose ()) g_print ("OK\n"); } diff --git a/tests/conform/test-cogl-pixel-buffer.c b/tests/conform/test-cogl-pixel-buffer.c index 09faa578f..88d26b0ca 100644 --- a/tests/conform/test-cogl-pixel-buffer.c +++ b/tests/conform/test-cogl-pixel-buffer.c @@ -286,7 +286,7 @@ test_cogl_pixel_array (TestConformSimpleFixture *fixture, state.frame = 0; - state.stage = clutter_stage_get_default (); + state.stage = clutter_stage_new (); create_map_tile (&tiles[TILE_MAP]); #if 0 @@ -319,12 +319,8 @@ test_cogl_pixel_array (TestConformSimpleFixture *fixture, cogl_handle_unref (state.tiles[i].texture); } - /* Remove all of the actors from the stage */ - clutter_container_foreach (CLUTTER_CONTAINER (state.stage), - (ClutterCallback) clutter_actor_destroy, - NULL); + clutter_actor_destroy (state.stage); if (g_test_verbose ()) g_print ("OK\n"); } - diff --git a/tests/conform/test-cogl-premult.c b/tests/conform/test-cogl-premult.c index c0a874d92..284c8d478 100644 --- a/tests/conform/test-cogl-premult.c +++ b/tests/conform/test-cogl-premult.c @@ -340,7 +340,7 @@ test_cogl_premult (TestConformSimpleFixture *fixture, cogl_material_set_layer_combine (state.passthrough_material, 0, "RGBA = REPLACE (TEXTURE)", NULL); - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); clutter_actor_get_geometry (stage, &state.stage_geom); @@ -361,7 +361,8 @@ test_cogl_premult (TestConformSimpleFixture *fixture, g_source_remove (idle_source); + clutter_actor_destroy (stage); + if (g_test_verbose ()) g_print ("OK\n"); } - diff --git a/tests/conform/test-cogl-primitive.c b/tests/conform/test-cogl-primitive.c index 649ab81c3..4ee1efe46 100644 --- a/tests/conform/test-cogl-primitive.c +++ b/tests/conform/test-cogl-primitive.c @@ -211,7 +211,7 @@ test_cogl_primitive (TestConformSimpleFixture *fixture, ClutterActor *stage; guint paint_handler; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); @@ -224,7 +224,8 @@ test_cogl_primitive (TestConformSimpleFixture *fixture, g_signal_handler_disconnect (stage, paint_handler); + clutter_actor_destroy (stage); + if (g_test_verbose ()) g_print ("OK\n"); } - diff --git a/tests/conform/test-cogl-readpixels.c b/tests/conform/test-cogl-readpixels.c index f0f23898a..646b24cbe 100644 --- a/tests/conform/test-cogl-readpixels.c +++ b/tests/conform/test-cogl-readpixels.c @@ -153,7 +153,7 @@ test_cogl_readpixels (TestConformSimpleFixture *fixture, guint idle_source; ClutterActor *stage; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); /* We force continuous redrawing of the stage, since we need to skip @@ -167,12 +167,8 @@ test_cogl_readpixels (TestConformSimpleFixture *fixture, g_source_remove (idle_source); - /* Remove all of the actors from the stage */ - clutter_container_foreach (CLUTTER_CONTAINER (stage), - (ClutterCallback) clutter_actor_destroy, - NULL); + clutter_actor_destroy (stage); if (g_test_verbose ()) g_print ("OK\n"); } - diff --git a/tests/conform/test-cogl-sub-texture.c b/tests/conform/test-cogl-sub-texture.c index 6cbafbf67..8fadc6994 100644 --- a/tests/conform/test-cogl-sub-texture.c +++ b/tests/conform/test-cogl-sub-texture.c @@ -339,7 +339,7 @@ test_cogl_sub_texture (TestConformSimpleFixture *fixture, state.frame = 0; - state.stage = clutter_stage_get_default (); + state.stage = clutter_stage_new (); state.tex = create_source (); clutter_stage_set_color (CLUTTER_STAGE (state.stage), &stage_color); @@ -361,12 +361,8 @@ test_cogl_sub_texture (TestConformSimpleFixture *fixture, cogl_handle_unref (state.tex); - /* Remove all of the actors from the stage */ - clutter_container_foreach (CLUTTER_CONTAINER (state.stage), - (ClutterCallback) clutter_actor_destroy, - NULL); + clutter_actor_destroy (state.stage); if (g_test_verbose ()) g_print ("OK\n"); } - diff --git a/tests/conform/test-cogl-texture-3d.c b/tests/conform/test-cogl-texture-3d.c index 82b34ba08..c3ff3b45b 100644 --- a/tests/conform/test-cogl-texture-3d.c +++ b/tests/conform/test-cogl-texture-3d.c @@ -204,12 +204,11 @@ test_cogl_texture_3d (TestConformSimpleFixture *fixture, ClutterActor *stage; guint paint_handler; - stage = clutter_stage_get_default (); - /* Check whether GL supports the rectangle extension. If not we'll just assume the test passes */ if (cogl_features_available (COGL_FEATURE_TEXTURE_3D)) { + stage = clutter_stage_new (); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); paint_handler = g_signal_connect_after (stage, "paint", @@ -221,10 +220,11 @@ test_cogl_texture_3d (TestConformSimpleFixture *fixture, g_signal_handler_disconnect (stage, paint_handler); + clutter_actor_destroy (stage); + if (g_test_verbose ()) g_print ("OK\n"); } else if (g_test_verbose ()) g_print ("Skipping\n"); } - diff --git a/tests/conform/test-cogl-texture-get-set-data.c b/tests/conform/test-cogl-texture-get-set-data.c index 26ba05858..4bbf3802d 100644 --- a/tests/conform/test-cogl-texture-get-set-data.c +++ b/tests/conform/test-cogl-texture-get-set-data.c @@ -150,7 +150,7 @@ test_cogl_texture_get_set_data (TestConformSimpleFixture *fixture, /* We create a stage even though we don't usually need it so that if the draw-and-read texture fallback is needed then it will have something to draw to */ - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); paint_handler = g_signal_connect_after (stage, "paint", G_CALLBACK (paint_cb), NULL); @@ -161,6 +161,8 @@ test_cogl_texture_get_set_data (TestConformSimpleFixture *fixture, g_signal_handler_disconnect (stage, paint_handler); + clutter_actor_destroy (stage); + if (g_test_verbose ()) g_print ("OK\n"); } diff --git a/tests/conform/test-cogl-texture-mipmaps.c b/tests/conform/test-cogl-texture-mipmaps.c index d62b542d3..37b4b0a6c 100644 --- a/tests/conform/test-cogl-texture-mipmaps.c +++ b/tests/conform/test-cogl-texture-mipmaps.c @@ -111,8 +111,7 @@ test_cogl_texture_mipmaps (TestConformSimpleFixture *fixture, ClutterActor *group; guint idle_source; - stage = clutter_stage_get_default (); - + stage = clutter_stage_new (); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); group = clutter_group_new (); @@ -131,6 +130,8 @@ test_cogl_texture_mipmaps (TestConformSimpleFixture *fixture, g_source_remove (idle_source); + clutter_actor_destroy (stage); + if (g_test_verbose ()) g_print ("OK\n"); } diff --git a/tests/conform/test-cogl-texture-pixmap-x11.c b/tests/conform/test-cogl-texture-pixmap-x11.c index 36f86d458..b04e6bc40 100644 --- a/tests/conform/test-cogl-texture-pixmap-x11.c +++ b/tests/conform/test-cogl-texture-pixmap-x11.c @@ -202,44 +202,44 @@ test_cogl_texture_pixmap_x11 (TestConformSimpleFixture *fixture, gconstpointer data) { #ifdef CLUTTER_WINDOWING_X11 + if (clutter_check_windowing_backend (CLUTTER_WINDOWING_X11)) + { + TestState state; + guint idle_handler; + guint paint_handler; - TestState state; - guint idle_handler; - guint paint_handler; + state.frame_count = 0; + state.stage = clutter_stage_new (); - state.frame_count = 0; - state.stage = clutter_stage_get_default (); + state.display = clutter_x11_get_default_display (); - state.display = clutter_x11_get_default_display (); + state.pixmap = create_pixmap (&state); + state.tfp = cogl_texture_pixmap_x11_new (state.pixmap, TRUE); - state.pixmap = create_pixmap (&state); - state.tfp = cogl_texture_pixmap_x11_new (state.pixmap, TRUE); + clutter_stage_set_color (CLUTTER_STAGE (state.stage), &stage_color); - clutter_stage_set_color (CLUTTER_STAGE (state.stage), &stage_color); + paint_handler = g_signal_connect_after (state.stage, "paint", + G_CALLBACK (on_paint), &state); - paint_handler = g_signal_connect_after (state.stage, "paint", - G_CALLBACK (on_paint), &state); + idle_handler = g_idle_add (queue_redraw, state.stage); - idle_handler = g_idle_add (queue_redraw, state.stage); + clutter_actor_show_all (state.stage); - clutter_actor_show_all (state.stage); + clutter_main (); - clutter_main (); + g_signal_handler_disconnect (state.stage, paint_handler); - g_signal_handler_disconnect (state.stage, paint_handler); + g_source_remove (idle_handler); - g_source_remove (idle_handler); + XFreePixmap (state.display, state.pixmap); - XFreePixmap (state.display, state.pixmap); + clutter_actor_destroy (state.stage); + if (g_test_verbose ()) + g_print ("OK\n"); + } + else +#endif if (g_test_verbose ()) - g_print ("OK\n"); - -#else /* CLUTTER_WINDOWING_X11 */ - - if (g_test_verbose ()) - g_print ("Skipping\n"); - -#endif /* CLUTTER_WINDOWING_X11 */ + g_print ("Skipping\n"); } - diff --git a/tests/conform/test-cogl-texture-rectangle.c b/tests/conform/test-cogl-texture-rectangle.c index 2839ea10c..15d991d5e 100644 --- a/tests/conform/test-cogl-texture-rectangle.c +++ b/tests/conform/test-cogl-texture-rectangle.c @@ -248,7 +248,7 @@ test_cogl_texture_rectangle (TestConformSimpleFixture *fixture, guint idle_source; guint paint_handler; - state.stage = clutter_stage_get_default (); + state.stage = clutter_stage_new (); test_conform_get_gl_functions (&gl_functions); @@ -273,6 +273,8 @@ test_cogl_texture_rectangle (TestConformSimpleFixture *fixture, g_source_remove (idle_source); g_signal_handler_disconnect (state.stage, paint_handler); + clutter_actor_destroy (state.stage); + if (g_test_verbose ()) g_print ("OK\n"); } diff --git a/tests/conform/test-cogl-vertex-buffer-contiguous.c b/tests/conform/test-cogl-vertex-buffer-contiguous.c index dbc069753..bace61c1b 100644 --- a/tests/conform/test-cogl-vertex-buffer-contiguous.c +++ b/tests/conform/test-cogl-vertex-buffer-contiguous.c @@ -167,7 +167,7 @@ test_cogl_vertex_buffer_contiguous (TestConformSimpleFixture *fixture, 0x00, 0xff, 0x00, 0xff }; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_clr); clutter_actor_get_geometry (stage, &state.stage_geom); @@ -251,7 +251,8 @@ test_cogl_vertex_buffer_contiguous (TestConformSimpleFixture *fixture, g_source_remove (idle_source); + clutter_actor_destroy (stage); + if (g_test_verbose ()) g_print ("OK\n"); } - diff --git a/tests/conform/test-cogl-vertex-buffer-interleved.c b/tests/conform/test-cogl-vertex-buffer-interleved.c index d8cd7cc19..e7c955942 100644 --- a/tests/conform/test-cogl-vertex-buffer-interleved.c +++ b/tests/conform/test-cogl-vertex-buffer-interleved.c @@ -92,7 +92,7 @@ test_cogl_vertex_buffer_interleved (TestConformSimpleFixture *fixture, ClutterActor *group; guint idle_source; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_clr); clutter_actor_get_geometry (stage, &state.stage_geom); @@ -156,7 +156,8 @@ test_cogl_vertex_buffer_interleved (TestConformSimpleFixture *fixture, g_source_remove (idle_source); + clutter_actor_destroy (stage); + if (g_test_verbose ()) g_print ("OK\n"); } - diff --git a/tests/conform/test-cogl-vertex-buffer-mutability.c b/tests/conform/test-cogl-vertex-buffer-mutability.c index 023df6173..08d6377e4 100644 --- a/tests/conform/test-cogl-vertex-buffer-mutability.c +++ b/tests/conform/test-cogl-vertex-buffer-mutability.c @@ -135,7 +135,7 @@ test_cogl_vertex_buffer_mutability (TestConformSimpleFixture *fixture, ClutterActor *group; guint idle_source; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_clr); clutter_actor_get_geometry (stage, &state.stage_geom); @@ -192,7 +192,8 @@ test_cogl_vertex_buffer_mutability (TestConformSimpleFixture *fixture, g_source_remove (idle_source); + clutter_actor_destroy (stage); + if (g_test_verbose ()) g_print ("OK\n"); } - diff --git a/tests/conform/test-cogl-viewport.c b/tests/conform/test-cogl-viewport.c index 778bae011..b3226cd25 100644 --- a/tests/conform/test-cogl-viewport.c +++ b/tests/conform/test-cogl-viewport.c @@ -391,7 +391,7 @@ test_cogl_viewport (TestConformSimpleFixture *fixture, guint idle_source; ClutterActor *stage; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); /* We force continuous redrawing of the stage, since we need to skip @@ -405,12 +405,8 @@ test_cogl_viewport (TestConformSimpleFixture *fixture, g_source_remove (idle_source); - /* Remove all of the actors from the stage */ - clutter_container_foreach (CLUTTER_CONTAINER (stage), - (ClutterCallback) clutter_actor_destroy, - NULL); + clutter_actor_destroy (stage); if (g_test_verbose ()) g_print ("OK\n"); } - diff --git a/tests/conform/test-cogl-wrap-modes.c b/tests/conform/test-cogl-wrap-modes.c index 0a5eaea26..499b66e90 100644 --- a/tests/conform/test-cogl-wrap-modes.c +++ b/tests/conform/test-cogl-wrap-modes.c @@ -293,7 +293,7 @@ test_cogl_wrap_modes (TestConformSimpleFixture *fixture, guint idle_source; guint paint_handler; - state.stage = clutter_stage_get_default (); + state.stage = clutter_stage_new (); clutter_stage_set_color (CLUTTER_STAGE (state.stage), &stage_color); @@ -312,6 +312,8 @@ test_cogl_wrap_modes (TestConformSimpleFixture *fixture, g_source_remove (idle_source); g_signal_handler_disconnect (state.stage, paint_handler); + clutter_actor_destroy (state.stage); + if (g_test_verbose ()) g_print ("OK\n"); } diff --git a/tests/conform/test-conform-main.c b/tests/conform/test-conform-main.c index 3373e9481..7a187b92c 100644 --- a/tests/conform/test-conform-main.c +++ b/tests/conform/test-conform-main.c @@ -145,6 +145,7 @@ main (int argc, char **argv) TEST_CONFORM_SIMPLE ("/invariants", test_show_on_set_parent); TEST_CONFORM_SIMPLE ("/invariants", test_clone_no_map); TEST_CONFORM_SIMPLE ("/invariants", test_contains); + TEST_CONFORM_SIMPLE ("/invariants", default_stage); TEST_CONFORM_SIMPLE ("/opacity", test_label_opacity); TEST_CONFORM_SIMPLE ("/opacity", test_rectangle_opacity); diff --git a/tests/conform/test-offscreen-redirect.c b/tests/conform/test-offscreen-redirect.c index 0952fa315..62d834e93 100644 --- a/tests/conform/test-offscreen-redirect.c +++ b/tests/conform/test-offscreen-redirect.c @@ -301,7 +301,7 @@ test_offscreen_redirect (TestConformSimpleFixture *fixture, { Data data; - data.stage = clutter_stage_get_default (); + data.stage = clutter_stage_new (); data.parent_container = clutter_group_new (); @@ -337,6 +337,8 @@ test_offscreen_redirect (TestConformSimpleFixture *fixture, clutter_main (); + clutter_actor_destroy (data.stage); + if (g_test_verbose ()) g_print ("OK\n"); } diff --git a/tests/conform/test-paint-opacity.c b/tests/conform/test-paint-opacity.c index 3dd48e912..2bd2970b5 100644 --- a/tests/conform/test-paint-opacity.c +++ b/tests/conform/test-paint-opacity.c @@ -12,7 +12,7 @@ test_label_opacity (TestConformSimpleFixture *fixture, ClutterColor label_color = { 255, 0, 0, 128 }; ClutterColor color_check = { 0, }; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); label = clutter_text_new_with_text ("Sans 18px", "Label, 50% opacity"); clutter_text_set_color (CLUTTER_TEXT (label), &label_color); @@ -39,7 +39,7 @@ test_label_opacity (TestConformSimpleFixture *fixture, clutter_actor_set_opacity (label, 128); g_assert (clutter_actor_get_paint_opacity (label) == 128); - clutter_actor_destroy (label); + clutter_actor_destroy (stage); } void @@ -51,7 +51,7 @@ test_rectangle_opacity (TestConformSimpleFixture *fixture, ClutterColor rect_color = { 0, 0, 255, 255 }; ClutterColor color_check = { 0, }; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); rect = clutter_rectangle_new_with_color (&rect_color); clutter_actor_set_size (rect, 128, 128); @@ -73,7 +73,7 @@ test_rectangle_opacity (TestConformSimpleFixture *fixture, g_print ("rect 100%%.get_paint_opacity()\n"); g_assert (clutter_actor_get_paint_opacity (rect) == 255); - clutter_actor_destroy (rect); + clutter_actor_destroy (stage); } void @@ -86,7 +86,7 @@ test_paint_opacity (TestConformSimpleFixture *fixture, ClutterColor rect_color = { 0, 0, 255, 255 }; ClutterColor color_check = { 0, }; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); group1 = clutter_group_new (); clutter_actor_set_opacity (group1, 128); @@ -138,7 +138,5 @@ test_paint_opacity (TestConformSimpleFixture *fixture, g_print ("rect 100%%.get_paint_opacity()\n"); g_assert (clutter_actor_get_paint_opacity (rect) == 128); - clutter_actor_destroy (rect); - clutter_actor_destroy (group2); - clutter_actor_destroy (group1); + clutter_actor_destroy (stage); } diff --git a/tests/conform/test-pick.c b/tests/conform/test-pick.c index 845d39dec..affef2866 100644 --- a/tests/conform/test-pick.c +++ b/tests/conform/test-pick.c @@ -240,7 +240,7 @@ actor_picking (void) state.pass = TRUE; - state.stage = clutter_stage_get_default (); + state.stage = clutter_stage_new (); state.actor_width = STAGE_WIDTH / ACTORS_X; state.actor_height = STAGE_HEIGHT / ACTORS_Y; @@ -271,9 +271,10 @@ actor_picking (void) clutter_main (); - if (g_test_verbose ()) g_print ("end result: %s\n", state.pass ? "pass" : "FAIL"); g_assert (state.pass); + + clutter_actor_destroy (state.stage); } diff --git a/tests/conform/test-score.c b/tests/conform/test-score.c index 65384f10c..a827f7efa 100644 --- a/tests/conform/test-score.c +++ b/tests/conform/test-score.c @@ -54,8 +54,8 @@ test_score (TestConformSimpleFixture *fixture, ClutterTimeline *timeline_5; GSList *timelines; - /* this is necessary to make the master clock spin */ - (void) clutter_stage_get_default (); + /* FIXME - this is necessary to make the master clock spin */ + ClutterActor *stage = clutter_stage_new (); timeline_1 = clutter_timeline_new (100); g_object_set_data_full (G_OBJECT (timeline_1), @@ -110,6 +110,8 @@ test_score (TestConformSimpleFixture *fixture, clutter_score_start (score); + clutter_actor_destroy (stage); + g_object_unref (timeline_1); g_object_unref (timeline_2); g_object_unref (timeline_3); diff --git a/tests/conform/test-shader-effect.c b/tests/conform/test-shader-effect.c index 916edf757..a21db610f 100644 --- a/tests/conform/test-shader-effect.c +++ b/tests/conform/test-shader-effect.c @@ -239,7 +239,7 @@ test_shader_effect (TestConformSimpleFixture *fixture, ClutterActor *stage; ClutterActor *rect; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); rect = make_actor (foo_old_shader_effect_get_type ()); clutter_container_add_actor (CLUTTER_CONTAINER (stage), rect); @@ -262,6 +262,8 @@ test_shader_effect (TestConformSimpleFixture *fixture, clutter_main (); + clutter_actor_destroy (stage); + if (g_test_verbose ()) g_print ("OK\n"); } diff --git a/tests/conform/test-text-cache.c b/tests/conform/test-text-cache.c index fc41b0200..82884df1c 100644 --- a/tests/conform/test-text-cache.c +++ b/tests/conform/test-text-cache.c @@ -263,7 +263,7 @@ text_cache (void) memset (&data, 0, sizeof (data)); - data.stage = clutter_stage_get_default (); + data.stage = clutter_stage_new (); data.label = clutter_text_new_with_text (TEST_FONT, ""); @@ -279,6 +279,8 @@ text_cache (void) clutter_main (); + clutter_actor_destroy (data.stage); + if (g_test_verbose ()) g_print ("\nOverall result: "); diff --git a/tests/conform/test-texture-fbo.c b/tests/conform/test-texture-fbo.c index 9aa696db5..4ef7b8d4c 100644 --- a/tests/conform/test-texture-fbo.c +++ b/tests/conform/test-texture-fbo.c @@ -173,14 +173,12 @@ test_texture_fbo (TestConformSimpleFixture *fixture, gconstpointer data) { TestState state; - guint idle_source; - gulong paint_handler; ClutterActor *actor; int ypos = 0; state.frame = 0; - state.stage = clutter_stage_get_default (); + state.stage = clutter_stage_new (); clutter_stage_set_color (CLUTTER_STAGE (state.stage), &stage_color); @@ -229,25 +227,15 @@ test_texture_fbo (TestConformSimpleFixture *fixture, /* We force continuous redrawing of the stage, since we need to skip * the first few frames, and we wont be doing anything else that * will trigger redrawing. */ - idle_source = g_idle_add (queue_redraw, state.stage); - - paint_handler = g_signal_connect_after (state.stage, "paint", - G_CALLBACK (on_paint), &state); + g_idle_add (queue_redraw, state.stage); + g_signal_connect_after (state.stage, "paint", G_CALLBACK (on_paint), &state); clutter_actor_show_all (state.stage); clutter_main (); - g_signal_handler_disconnect (state.stage, paint_handler); - - g_source_remove (idle_source); - - /* Remove all of the actors from the stage */ - clutter_container_foreach (CLUTTER_CONTAINER (state.stage), - (ClutterCallback) clutter_actor_destroy, - NULL); + clutter_actor_destroy (state.stage); if (g_test_verbose ()) g_print ("OK\n"); } - diff --git a/tests/conform/test-timeline.c b/tests/conform/test-timeline.c index a04e948e2..7a1c17971 100644 --- a/tests/conform/test-timeline.c +++ b/tests/conform/test-timeline.c @@ -185,7 +185,6 @@ void test_timeline (TestConformSimpleFixture *fixture, gconstpointer data) { - ClutterActor *stage G_GNUC_UNUSED; ClutterTimeline *timeline_1; TimelineData data_1; ClutterTimeline *timeline_2; @@ -198,7 +197,7 @@ test_timeline (TestConformSimpleFixture *fixture, /* NB: We have to ensure a stage is instantiated else the master * clock wont run... */ - stage = clutter_stage_get_default (); + ClutterActor *stage = clutter_stage_new (); timeline_data_init (&data_1, 1); timeline_1 = clutter_timeline_new (FRAME_COUNT * 1000 / FPS); @@ -316,4 +315,6 @@ test_timeline (TestConformSimpleFixture *fixture, timeline_data_destroy (&data_3); g_source_remove (delay_tag); + + clutter_actor_destroy (stage); } diff --git a/tests/interactive/test-actor-clone.c b/tests/interactive/test-actor-clone.c index ec4f392d7..fa7fa3b58 100644 --- a/tests/interactive/test-actor-clone.c +++ b/tests/interactive/test-actor-clone.c @@ -10,10 +10,11 @@ typedef struct SuperOH { - ClutterActor **hand, *bgtex; - ClutterActor *real_hand; - ClutterActor *group; - ClutterActor *stage; + ClutterActor **hand; + ClutterActor *bgtex; + ClutterActor *real_hand; + ClutterActor *group; + ClutterActor *stage; gint stage_width; gint stage_height; @@ -22,6 +23,8 @@ typedef struct SuperOH ClutterBehaviour *scaler_1; ClutterBehaviour *scaler_2; ClutterTimeline *timeline; + + guint frame_id; } SuperOH; static gint n_hands = NHANDS; @@ -36,6 +39,15 @@ static GOptionEntry super_oh_entries[] = { { NULL } }; +static void +clean_and_quit (ClutterActor *actor, + SuperOH *oh) +{ + g_signal_handler_disconnect (oh->timeline, oh->frame_id); + + clutter_main_quit (); +} + static gboolean on_button_press_event (ClutterActor *actor, ClutterEvent *event, @@ -155,20 +167,23 @@ test_actor_clone_main (int argc, char *argv[]) return EXIT_FAILURE; } - stage = clutter_stage_get_default (); + oh = g_new (SuperOH, 1); + + oh->stage = stage = clutter_stage_new (); clutter_actor_set_size (stage, 800, 600); clutter_stage_set_title (CLUTTER_STAGE (stage), "Clone Test"); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); - oh = g_new (SuperOH, 1); + g_signal_connect (stage, "destroy", G_CALLBACK (clean_and_quit), oh); /* Create a timeline to manage animation */ oh->timeline = clutter_timeline_new (6000); clutter_timeline_set_loop (oh->timeline, TRUE); /* fire a callback for frame change */ - g_signal_connect (oh->timeline, "new-frame", G_CALLBACK (frame_cb), oh); + oh->frame_id = + g_signal_connect (oh->timeline, "new-frame", G_CALLBACK (frame_cb), oh); /* Set up some behaviours to handle scaling */ alpha = clutter_alpha_new_with_func (oh->timeline, my_sine_wave, NULL, NULL); @@ -207,7 +222,7 @@ test_actor_clone_main (int argc, char *argv[]) clutter_actor_hide (real_hand); /* create a new group to hold multiple actors in a group */ - oh->group = clutter_group_new(); + oh->group = clutter_group_new (); oh->hand = g_new (ClutterActor*, n_hands); @@ -274,11 +289,12 @@ test_actor_clone_main (int argc, char *argv[]) clutter_main (); - /* clean up */ g_object_unref (oh->scaler_1); g_object_unref (oh->scaler_2); g_object_unref (oh->timeline); + g_free (oh->hand); + g_free (oh); return EXIT_SUCCESS; diff --git a/tests/interactive/test-animation.c b/tests/interactive/test-animation.c index aba1a9d50..80b1212a1 100644 --- a/tests/interactive/test-animation.c +++ b/tests/interactive/test-animation.c @@ -84,15 +84,16 @@ G_MODULE_EXPORT int test_animation_main (int argc, char *argv[]) { ClutterActor *stage, *rect; - ClutterColor stage_color = { 0x66, 0x66, 0xdd, 0xff }; ClutterColor rect_color = { 0x44, 0xdd, 0x44, 0xff }; ClutterAction *action; if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; - stage = clutter_stage_get_default (); - clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); + stage = clutter_stage_new (); + clutter_stage_set_color (CLUTTER_STAGE (stage), CLUTTER_COLOR_LightSkyBlue); + clutter_stage_set_title (CLUTTER_STAGE (stage), "Animation"); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); rect = clutter_rectangle_new_with_color (&rect_color); clutter_container_add_actor (CLUTTER_CONTAINER (stage), rect); diff --git a/tests/interactive/test-animator.c b/tests/interactive/test-animator.c index d158655de..dcd64c038 100644 --- a/tests/interactive/test-animator.c +++ b/tests/interactive/test-animator.c @@ -55,18 +55,20 @@ test_animator_main (gint argc, if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); + clutter_stage_set_title (CLUTTER_STAGE (stage), "Animator"); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); - for (i=0; iy += flowers[i]->v; flowers[i]->rot += flowers[i]->rv; - stage = clutter_stage_get_default (); if (flowers[i]->y > (gint) clutter_actor_get_height (stage)) flowers[i]->y = -clutter_actor_get_height (flowers[i]->ctex); @@ -167,23 +166,35 @@ tick (ClutterTimeline *timeline, } } -int +static void +stop_and_quit (ClutterActor *actor, + ClutterTimeline *timeline) +{ + clutter_timeline_stop (timeline); + clutter_main_quit (); +} + +G_MODULE_EXPORT int test_cairo_flowers_main (int argc, char **argv) { - int i; - ClutterActor *stage; - ClutterColor stage_color = { 0x0, 0x0, 0x0, 0xff }; + Flower *flowers[N_FLOWERS]; ClutterTimeline *timeline; - Flower *flowers[N_FLOWERS]; + int i; srand (time (NULL)); if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; - stage = clutter_stage_get_default (); + /* Create a timeline to manage animation */ + timeline = clutter_timeline_new (6000); + clutter_timeline_set_loop (timeline, TRUE); - clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); + stage = clutter_stage_new (); + clutter_stage_set_title (CLUTTER_STAGE (stage), "Cairo Flowers"); + g_signal_connect (stage, "destroy", G_CALLBACK (stop_and_quit), timeline); + + clutter_stage_set_color (CLUTTER_STAGE (stage), CLUTTER_COLOR_Black); for (i=0; i< N_FLOWERS; i++) { @@ -201,10 +212,6 @@ test_cairo_flowers_main (int argc, char **argv) flowers[i]->x, flowers[i]->y); } - /* Create a timeline to manage animation */ - timeline = clutter_timeline_new (6000); - clutter_timeline_set_loop (timeline, TRUE); - /* fire a callback for frame change */ g_signal_connect (timeline, "new-frame", G_CALLBACK (tick), flowers); @@ -218,6 +225,13 @@ test_cairo_flowers_main (int argc, char **argv) clutter_main(); + g_object_unref (timeline); + return EXIT_SUCCESS; } +G_MODULE_EXPORT const char * +test_cairo_flowers_describe (void) +{ + return "Drawing pretty flowers with Cairo"; +} diff --git a/tests/interactive/test-clip.c b/tests/interactive/test-clip.c index b2f2a8af2..cdfbee1b7 100644 --- a/tests/interactive/test-clip.c +++ b/tests/interactive/test-clip.c @@ -325,7 +325,9 @@ test_clip_main (int argc, char **argv) data.current_clip.type = CLIP_NONE; data.clips = NULL; - data.stage = clutter_stage_get_default (); + data.stage = clutter_stage_new (); + clutter_stage_set_title (CLUTTER_STAGE (data.stage), "Clipping"); + g_signal_connect (data.stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); stub_actor = clutter_rectangle_new (); clutter_container_add (CLUTTER_CONTAINER (data.stage), stub_actor, NULL); @@ -366,3 +368,9 @@ test_clip_main (int argc, char **argv) return 0; } + +G_MODULE_EXPORT const char * +test_clip_describe (void) +{ + return "Actor clipping with various techniques"; +} diff --git a/tests/interactive/test-cogl-multitexture.c b/tests/interactive/test-cogl-multitexture.c index 1e23b0933..b815831b5 100644 --- a/tests/interactive/test-cogl-multitexture.c +++ b/tests/interactive/test-cogl-multitexture.c @@ -102,7 +102,7 @@ test_cogl_multitexture_main (int argc, char *argv[]) ClutterActor *stage; ClutterColor stage_color = { 0x61, 0x56, 0x56, 0xff }; TestMultiLayerMaterialState *state = g_new0 (TestMultiLayerMaterialState, 1); - ClutterGeometry geom; + gfloat stage_w, stage_h; gchar **files; gfloat tex_coords[] = { @@ -115,17 +115,20 @@ test_cogl_multitexture_main (int argc, char *argv[]) if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; - stage = clutter_stage_get_default (); - clutter_actor_get_geometry (stage, &geom); + stage = clutter_stage_new (); + clutter_actor_get_size (stage, &stage_w, &stage_h); + clutter_stage_set_title (CLUTTER_STAGE (stage), "Cogl: Multi-texturing"); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); + /* We create a non-descript actor that we know doesn't have a * default paint handler, so that we can easily control * painting in a paint signal handler, without having to * sub-class anything etc. */ state->group = clutter_group_new (); - clutter_actor_set_position (state->group, geom.width/2, geom.height/2); + clutter_actor_set_position (state->group, stage_w / 2, stage_h / 2); g_signal_connect (state->group, "paint", G_CALLBACK(material_rectangle_paint), state); @@ -227,3 +230,9 @@ test_cogl_multitexture_main (int argc, char *argv[]) return 0; } + +G_MODULE_EXPORT const char * +test_cogl_multitexture_describe (void) +{ + return "Multi-texturing support in Cogl."; +} diff --git a/tests/interactive/test-cogl-offscreen.c b/tests/interactive/test-cogl-offscreen.c index e6a1bb7d6..4e1c210ca 100644 --- a/tests/interactive/test-cogl-offscreen.c +++ b/tests/interactive/test-cogl-offscreen.c @@ -225,37 +225,20 @@ setup_viewport (unsigned int width, } static void -test_coglbox_init (TestCoglbox *self) +test_coglbox_map (ClutterActor *actor) { + TestCoglboxPrivate *priv = TEST_COGLBOX_GET_PRIVATE (actor); ClutterActor *stage; - TestCoglboxPrivate *priv; - gchar *file; ClutterPerspective perspective; float stage_width; float stage_height; - self->priv = priv = TEST_COGLBOX_GET_PRIVATE(self); - - printf ("Loading redhand.png\n"); - file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL); - priv->texhand_id = cogl_texture_new_from_file (file, - COGL_TEXTURE_NONE, - COGL_PIXEL_FORMAT_ANY, - NULL); - g_free (file); - - printf ("Creating texture with size\n"); - priv->texture_id = cogl_texture_new_with_size (200, 200, - COGL_TEXTURE_NONE, - COGL_PIXEL_FORMAT_RGB_888); - - if (priv->texture_id == COGL_INVALID_HANDLE) - printf ("Failed creating texture with size!\n"); + CLUTTER_ACTOR_CLASS (test_coglbox_parent_class)->map (actor); printf ("Creating offscreen\n"); priv->offscreen_id = cogl_offscreen_new_to_texture (priv->texture_id); - stage = clutter_stage_get_default (); + stage = clutter_actor_get_stage (actor); clutter_stage_get_perspective (CLUTTER_STAGE (stage), &perspective); clutter_actor_get_size (stage, &stage_width, &stage_height); @@ -273,6 +256,31 @@ test_coglbox_init (TestCoglbox *self) printf ("Failed creating offscreen to texture!\n"); } +static void +test_coglbox_init (TestCoglbox *self) +{ + TestCoglboxPrivate *priv; + gchar *file; + + self->priv = priv = TEST_COGLBOX_GET_PRIVATE(self); + + printf ("Loading redhand.png\n"); + file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL); + priv->texhand_id = cogl_texture_new_from_file (file, + COGL_TEXTURE_NONE, + COGL_PIXEL_FORMAT_ANY, + NULL); + g_free (file); + + printf ("Creating texture with size\n"); + priv->texture_id = cogl_texture_new_with_size (200, 200, + COGL_TEXTURE_NONE, + COGL_PIXEL_FORMAT_RGB_888); + + if (priv->texture_id == COGL_INVALID_HANDLE) + printf ("Failed creating texture with size!\n"); +} + static void test_coglbox_class_init (TestCoglboxClass *klass) { @@ -281,6 +289,8 @@ test_coglbox_class_init (TestCoglboxClass *klass) gobject_class->finalize = test_coglbox_finalize; gobject_class->dispose = test_coglbox_dispose; + + actor_class->map = test_coglbox_map; actor_class->paint = test_coglbox_paint; g_type_class_add_private (gobject_class, sizeof (TestCoglboxPrivate)); @@ -295,16 +305,17 @@ test_coglbox_new (void) G_MODULE_EXPORT int test_cogl_offscreen_main (int argc, char *argv[]) { - ClutterActor *stage; - ClutterActor *coglbox; + ClutterActor *stage; + ClutterActor *coglbox; if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; /* Stage */ - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_actor_set_size (stage, 400, 400); - clutter_stage_set_title (CLUTTER_STAGE (stage), "Cogl Test"); + clutter_stage_set_title (CLUTTER_STAGE (stage), "Cogl Offscreen Buffers"); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); /* Cogl Box */ coglbox = test_coglbox_new (); @@ -316,3 +327,9 @@ test_cogl_offscreen_main (int argc, char *argv[]) return 0; } + +G_MODULE_EXPORT const char * +test_cogl_offscreen_describe (void) +{ + return "Offscreen buffer support in Cogl."; +} diff --git a/tests/interactive/test-cogl-point-sprites.c b/tests/interactive/test-cogl-point-sprites.c index c457aa34c..6a18ce3b8 100644 --- a/tests/interactive/test-cogl-point-sprites.c +++ b/tests/interactive/test-cogl-point-sprites.c @@ -219,7 +219,6 @@ idle_cb (gpointer data) G_MODULE_EXPORT int test_cogl_point_sprites_main (int argc, char *argv[]) { - static const ClutterColor black = { 0, 0, 0, 255 }; ClutterActor *stage; CoglHandle tex; Data data; @@ -260,9 +259,10 @@ test_cogl_point_sprites_main (int argc, char *argv[]) data.sparks[i].y = 2.0f; } - stage = clutter_stage_get_default (); - clutter_stage_set_color (CLUTTER_STAGE (stage), &black); - + stage = clutter_stage_new (); + clutter_stage_set_color (CLUTTER_STAGE (stage), CLUTTER_COLOR_Black); + clutter_stage_set_title (CLUTTER_STAGE (stage), "Cogl Point Sprites"); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); g_signal_connect_after (stage, "paint", G_CALLBACK (paint_cb), &data); clutter_actor_show (stage); @@ -279,3 +279,9 @@ test_cogl_point_sprites_main (int argc, char *argv[]) return 0; } + +G_MODULE_EXPORT const char * +test_cogl_point_sprites_describe (void) +{ + return "Point sprites support in Cogl."; +} diff --git a/tests/interactive/test-cogl-primitives.c b/tests/interactive/test-cogl-primitives.c index 9069fc25c..7b237e2e9 100644 --- a/tests/interactive/test-cogl-primitives.c +++ b/tests/interactive/test-cogl-primitives.c @@ -114,9 +114,10 @@ test_cogl_primitives_main (int argc, char *argv[]) clutter_timeline_set_loop (tl, TRUE); clutter_timeline_start (tl); - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_actor_set_size (stage, 400, 400); - clutter_stage_set_title (CLUTTER_STAGE (stage), "Cogl Test"); + clutter_stage_set_title (CLUTTER_STAGE (stage), "Cogl Path Primitives"); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); coglbox = clutter_group_new (); clutter_container_add_actor (CLUTTER_CONTAINER (stage), coglbox); @@ -136,3 +137,9 @@ test_cogl_primitives_main (int argc, char *argv[]) return 0; } + +G_MODULE_EXPORT const char * +test_cogl_primitives (void) +{ + return "2D Path primitives support in Cogl."; +} diff --git a/tests/interactive/test-cogl-tex-convert.c b/tests/interactive/test-cogl-tex-convert.c index f1e80167a..84aa9d6b7 100644 --- a/tests/interactive/test-cogl-tex-convert.c +++ b/tests/interactive/test-cogl-tex-convert.c @@ -202,10 +202,11 @@ test_cogl_tex_convert_main (int argc, char *argv[]) return 1; /* Stage */ - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_actor_set_size (stage, 400, 400); - clutter_stage_set_title (CLUTTER_STAGE (stage), "Cogl Test"); - + clutter_stage_set_title (CLUTTER_STAGE (stage), "Cogl Texture Conversion"); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); + /* Cogl Box */ coglbox = test_coglbox_new (); clutter_container_add_actor (CLUTTER_CONTAINER (stage), coglbox); @@ -216,3 +217,9 @@ test_cogl_tex_convert_main (int argc, char *argv[]) return 0; } + +G_MODULE_EXPORT const char * +test_cogl_tex_convert_describe (void) +{ + return "Pixel format conversion of Cogl textures."; +} diff --git a/tests/interactive/test-cogl-tex-foreign.c b/tests/interactive/test-cogl-tex-foreign.c index 40284fa0c..e32eece05 100644 --- a/tests/interactive/test-cogl-tex-foreign.c +++ b/tests/interactive/test-cogl-tex-foreign.c @@ -226,10 +226,11 @@ test_cogl_tex_foreign_main (int argc, char *argv[]) return 1; /* Stage */ - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_actor_set_size (stage, 400, 400); - clutter_stage_set_title (CLUTTER_STAGE (stage), "Cogl Test"); - + clutter_stage_set_title (CLUTTER_STAGE (stage), "Cogl Foreign Textures"); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); + /* Cogl Box */ coglbox = test_coglbox_new (); clutter_container_add_actor (CLUTTER_CONTAINER (stage), coglbox); @@ -240,3 +241,9 @@ test_cogl_tex_foreign_main (int argc, char *argv[]) return 0; } + +G_MODULE_EXPORT const char * +test_cogl_tex_foreign_describe (void) +{ + return "Foreign textures support in Cogl."; +} diff --git a/tests/interactive/test-cogl-tex-getset.c b/tests/interactive/test-cogl-tex-getset.c index a9d01ebf7..2697f1a69 100644 --- a/tests/interactive/test-cogl-tex-getset.c +++ b/tests/interactive/test-cogl-tex-getset.c @@ -249,10 +249,11 @@ test_cogl_tex_getset_main (int argc, char *argv[]) return 1; /* Stage */ - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_actor_set_size (stage, 400, 400); - clutter_stage_set_title (CLUTTER_STAGE (stage), "Cogl Test"); - + clutter_stage_set_title (CLUTTER_STAGE (stage), "Cogl Texture Readback"); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); + /* Cogl Box */ coglbox = test_coglbox_new (); clutter_container_add_actor (CLUTTER_CONTAINER (stage), coglbox); @@ -263,3 +264,9 @@ test_cogl_tex_getset_main (int argc, char *argv[]) return 0; } + +G_MODULE_EXPORT const char * +test_cogl_tex_getset_describe (void) +{ + return "Texture region readback and update in Cogl."; +} diff --git a/tests/interactive/test-cogl-tex-polygon.c b/tests/interactive/test-cogl-tex-polygon.c index 00e881a66..1b4f6004c 100644 --- a/tests/interactive/test-cogl-tex-polygon.c +++ b/tests/interactive/test-cogl-tex-polygon.c @@ -365,10 +365,11 @@ test_cogl_tex_polygon_main (int argc, char *argv[]) return 1; /* Stage */ - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_stage_set_color (CLUTTER_STAGE (stage), &blue); clutter_actor_set_size (stage, 640, 480); - clutter_stage_set_title (CLUTTER_STAGE (stage), "Cogl Test"); + clutter_stage_set_title (CLUTTER_STAGE (stage), "Cogl Texture Polygon"); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); /* Cogl Box */ coglbox = test_coglbox_new (); @@ -412,3 +413,9 @@ test_cogl_tex_polygon_main (int argc, char *argv[]) return 0; } + +G_MODULE_EXPORT const char * +test_cogl_tex_polygon_describe (void) +{ + return "Texture polygon primitive."; +} diff --git a/tests/interactive/test-cogl-tex-tile.c b/tests/interactive/test-cogl-tex-tile.c index 7682831dd..025e804ea 100644 --- a/tests/interactive/test-cogl-tex-tile.c +++ b/tests/interactive/test-cogl-tex-tile.c @@ -190,9 +190,10 @@ test_cogl_tex_tile_main (int argc, char *argv[]) return 1; /* Stage */ - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_actor_set_size (stage, 400, 400); - clutter_stage_set_title (CLUTTER_STAGE (stage), "Cogl Test"); + clutter_stage_set_title (CLUTTER_STAGE (stage), "Cogl Texture Tiling"); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); /* Cogl Box */ coglbox = test_coglbox_new (); @@ -210,3 +211,9 @@ test_cogl_tex_tile_main (int argc, char *argv[]) return 0; } + +G_MODULE_EXPORT const char * +test_cogl_tex_tile_describe (void) +{ + return "Texture tiling."; +} diff --git a/tests/interactive/test-cogl-vertex-buffer.c b/tests/interactive/test-cogl-vertex-buffer.c index 606c5bedf..6c26c9c57 100644 --- a/tests/interactive/test-cogl-vertex-buffer.c +++ b/tests/interactive/test-cogl-vertex-buffer.c @@ -50,6 +50,7 @@ typedef struct _TestState guint n_static_indices; CoglHandle indices; ClutterTimeline *timeline; + guint frame_id; } TestState; static void @@ -324,37 +325,47 @@ create_dummy_actor (guint width, guint height) return group; } +static void +stop_and_quit (ClutterActor *actor, + TestState *state) +{ + clutter_timeline_stop (state->timeline); + clutter_main_quit (); +} + G_MODULE_EXPORT int test_cogl_vertex_buffer_main (int argc, char *argv[]) { TestState state; ClutterActor *stage; - ClutterColor stage_clr = {0x0, 0x0, 0x0, 0xff}; - ClutterGeometry stage_geom; + gfloat stage_w, stage_h; gint dummy_width, dummy_height; if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); - clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_clr); - clutter_actor_get_geometry (stage, &stage_geom); + clutter_stage_set_title (CLUTTER_STAGE (stage), "Cogl Vertex Buffers"); + clutter_stage_set_color (CLUTTER_STAGE (stage), CLUTTER_COLOR_Black); + g_signal_connect (stage, "destroy", G_CALLBACK (stop_and_quit), &state); + clutter_actor_get_size (stage, &stage_w, &stage_h); dummy_width = MESH_WIDTH * QUAD_WIDTH; dummy_height = MESH_HEIGHT * QUAD_HEIGHT; state.dummy = create_dummy_actor (dummy_width, dummy_height); clutter_container_add_actor (CLUTTER_CONTAINER (stage), state.dummy); clutter_actor_set_position (state.dummy, - (stage_geom.width / 2.0) - (dummy_width / 2.0), - (stage_geom.height / 2.0) - (dummy_height / 2.0)); + (stage_w / 2.0) - (dummy_width / 2.0), + (stage_h / 2.0) - (dummy_height / 2.0)); state.timeline = clutter_timeline_new (1000); clutter_timeline_set_loop (state.timeline, TRUE); - g_signal_connect (state.timeline, - "new-frame", - G_CALLBACK (frame_cb), - &state); + + state.frame_id = g_signal_connect (state.timeline, + "new-frame", + G_CALLBACK (frame_cb), + &state); g_signal_connect (state.dummy, "paint", G_CALLBACK (on_paint), &state); @@ -372,3 +383,8 @@ test_cogl_vertex_buffer_main (int argc, char *argv[]) return 0; } +G_MODULE_EXPORT const char * +test_cogl_vertex_buffer_describe (void) +{ + return "Vertex buffers support in Cogl."; +} diff --git a/tests/interactive/test-events.c b/tests/interactive/test-events.c index 18ba50229..de327c564 100644 --- a/tests/interactive/test-events.c +++ b/tests/interactive/test-events.c @@ -48,13 +48,13 @@ stage_state_cb (ClutterStage *stage, } static gboolean -blue_button_cb (ClutterActor *actor, - ClutterEvent *event, - gpointer data) +blue_button_cb (ClutterActor *actor, + ClutterEvent *event, + gpointer data) { ClutterActor *stage; - stage = clutter_stage_get_default (); + stage = clutter_actor_get_stage (actor); if (IsFullScreen) IsFullScreen = FALSE; @@ -104,12 +104,12 @@ capture_cb (ClutterActor *actor, } static void -key_focus_in_cb (ClutterActor *actor, - gpointer data) +key_focus_in_cb (ClutterActor *actor, + gpointer data) { - ClutterActor *focus_box = CLUTTER_ACTOR(data); + ClutterActor *focus_box = CLUTTER_ACTOR (data); - if (actor == clutter_stage_get_default ()) + if (CLUTTER_IS_STAGE (actor)) clutter_actor_hide (focus_box); else { @@ -171,7 +171,7 @@ input_cb (ClutterActor *actor, ClutterEvent *event, gpointer data) { - ClutterStage *stage = CLUTTER_STAGE (clutter_stage_get_default ()); + ClutterActor *stage = clutter_actor_get_stage (actor); ClutterActor *source_actor = clutter_event_get_source (event); gchar keybuf[128]; @@ -223,11 +223,11 @@ input_cb (ClutterActor *actor, clutter_event_get_button (event), clutter_event_get_click_count (event)); - if (source_actor == CLUTTER_ACTOR (stage)) - clutter_stage_set_key_focus (stage, NULL); + if (source_actor == stage) + clutter_stage_set_key_focus (CLUTTER_STAGE (stage), NULL); else if (source_actor == actor && - clutter_actor_get_parent (actor) == CLUTTER_ACTOR (stage)) - clutter_stage_set_key_focus (stage, actor); + clutter_actor_get_parent (actor) == stage) + clutter_stage_set_key_focus (CLUTTER_STAGE (stage), actor); break; case CLUTTER_SCROLL: g_print ("[%s] BUTTON SCROLL (direction:%s)", @@ -263,21 +263,15 @@ input_cb (ClutterActor *actor, G_MODULE_EXPORT int test_events_main (int argc, char *argv[]) { - ClutterActor *stage, *actor, *focus_box, *group; - ClutterColor rcol = { 0xff, 0, 0, 0xff }, - bcol = { 0, 0, 0xff, 0xff }, - gcol = { 0, 0xff, 0, 0xff }, - ycol = { 0xff, 0xff, 0, 0xff }, - ncol = { 0, 0, 0, 0xff }, - xcol = { 0xff, 0, 0xff, 0xff }; + ClutterActor *stage, *actor, *focus_box, *group; if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; - - - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); + clutter_stage_set_title (CLUTTER_STAGE (stage), "Events"); clutter_actor_set_name (stage, "Stage"); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); g_signal_connect (stage, "event", G_CALLBACK (input_cb), "stage"); g_signal_connect (stage, "fullscreen", G_CALLBACK (stage_state_cb), "fullscreen"); @@ -287,13 +281,12 @@ test_events_main (int argc, char *argv[]) G_CALLBACK (stage_state_cb), "activate"); g_signal_connect (stage, "deactivate", G_CALLBACK (stage_state_cb), "deactivate"); -/*g_signal_connect (stage, "captured-event", G_CALLBACK (capture_cb), NULL);*/ - focus_box = clutter_rectangle_new_with_color (&ncol); + focus_box = clutter_rectangle_new_with_color (CLUTTER_COLOR_Black); clutter_actor_set_name (focus_box, "Focus Box"); clutter_container_add (CLUTTER_CONTAINER(stage), focus_box, NULL); - actor = clutter_rectangle_new_with_color (&rcol); + actor = clutter_rectangle_new_with_color (CLUTTER_COLOR_Red); clutter_actor_set_name (actor, "Red Box"); clutter_actor_set_size (actor, 100, 100); clutter_actor_set_position (actor, 100, 100); @@ -308,7 +301,7 @@ test_events_main (int argc, char *argv[]) clutter_stage_set_key_focus (CLUTTER_STAGE (stage), actor); - actor = clutter_rectangle_new_with_color (&gcol); + actor = clutter_rectangle_new_with_color (CLUTTER_COLOR_Green); clutter_actor_set_name (actor, "Green Box"); clutter_actor_set_size (actor, 100, 100); clutter_actor_set_position (actor, 250, 100); @@ -319,7 +312,7 @@ test_events_main (int argc, char *argv[]) focus_box); g_signal_connect (actor, "captured-event", G_CALLBACK (capture_cb), NULL); - actor = clutter_rectangle_new_with_color (&bcol); + actor = clutter_rectangle_new_with_color (CLUTTER_COLOR_Blue); clutter_actor_set_name (actor, "Blue Box"); clutter_actor_set_size (actor, 100, 100); clutter_actor_set_position (actor, 400, 100); @@ -333,7 +326,7 @@ test_events_main (int argc, char *argv[]) G_CALLBACK (blue_button_cb), NULL); /* non reactive */ - actor = clutter_rectangle_new_with_color (&ncol); + actor = clutter_rectangle_new_with_color (CLUTTER_COLOR_Black); clutter_actor_set_name (actor, "Black Box"); clutter_actor_set_size (actor, 400, 50); clutter_actor_set_position (actor, 100, 250); @@ -345,7 +338,7 @@ test_events_main (int argc, char *argv[]) focus_box); /* non reactive group, with reactive child */ - actor = clutter_rectangle_new_with_color (&ycol); + actor = clutter_rectangle_new_with_color (CLUTTER_COLOR_Yellow); clutter_actor_set_name (actor, "Yellow Box"); clutter_actor_set_size (actor, 100, 100); clutter_actor_set_reactive (actor, TRUE); @@ -360,7 +353,7 @@ test_events_main (int argc, char *argv[]) clutter_actor_show_all (group); /* border actor */ - actor = clutter_rectangle_new_with_color (&xcol); + actor = clutter_rectangle_new_with_color (CLUTTER_COLOR_Magenta); clutter_actor_set_name (actor, "Border Box"); clutter_actor_set_size (actor, 100, 100); clutter_actor_set_position (actor, @@ -376,3 +369,9 @@ test_events_main (int argc, char *argv[]) return 0; } + +G_MODULE_EXPORT const char * +test_events_describe (void) +{ + return "Event handling and propagation."; +} diff --git a/tests/interactive/test-fbo.c b/tests/interactive/test-fbo.c index 5854ad181..039f73082 100644 --- a/tests/interactive/test-fbo.c +++ b/tests/interactive/test-fbo.c @@ -55,9 +55,11 @@ test_fbo_main (int argc, char *argv[]) if (clutter_feature_available (CLUTTER_FEATURE_OFFSCREEN) == FALSE) g_error("This test requires CLUTTER_FEATURE_OFFSCREEN"); - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_actor_set_size (stage, STAGE_WIDTH, STAGE_HEIGHT); clutter_stage_set_color (CLUTTER_STAGE (stage), &blue); + clutter_stage_set_title (CLUTTER_STAGE (stage), "Texture from Actor"); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); /* Create the first source */ onscreen_source = make_source(); @@ -97,3 +99,9 @@ test_fbo_main (int argc, char *argv[]) return 0; } + +G_MODULE_EXPORT const char * +test_fbo_describe (void) +{ + return "Create a texture from an actor."; +} diff --git a/tests/interactive/test-flow-layout.c b/tests/interactive/test-flow-layout.c index 82c2f3070..f0550543a 100644 --- a/tests/interactive/test-flow-layout.c +++ b/tests/interactive/test-flow-layout.c @@ -90,10 +90,11 @@ test_flow_layout_main (int argc, char *argv[]) return EXIT_FAILURE; } - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_stage_set_title (CLUTTER_STAGE (stage), "Flow Layout"); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); clutter_stage_set_user_resizable (CLUTTER_STAGE (stage), TRUE); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); layout = clutter_flow_layout_new (vertical ? CLUTTER_FLOW_VERTICAL : CLUTTER_FLOW_HORIZONTAL); @@ -154,3 +155,9 @@ test_flow_layout_main (int argc, char *argv[]) return EXIT_SUCCESS; } + +G_MODULE_EXPORT const char * +test_flow_layout_describe (void) +{ + return "FlowLayout layout manager example"; +} diff --git a/tests/interactive/test-fullscreen.c b/tests/interactive/test-fullscreen.c index 6dbe2a2f3..007b7a743 100644 --- a/tests/interactive/test-fullscreen.c +++ b/tests/interactive/test-fullscreen.c @@ -31,9 +31,9 @@ on_unfullscreen (ClutterStage *stage) } static gboolean -toggle_fullscreen (gpointer dummy) +toggle_fullscreen (gpointer data) { - ClutterActor *stage = clutter_stage_get_default (); + ClutterActor *stage = data; gboolean is_fullscreen = FALSE; g_object_get (G_OBJECT (stage), "fullscreen-set", &is_fullscreen, NULL); @@ -60,7 +60,7 @@ toggle_fullscreen (gpointer dummy) case DONE: g_debug ("done: is_fullscreen := %s", is_fullscreen ? "true" : "false"); - clutter_main_quit (); + clutter_actor_destroy (stage); break; } @@ -75,13 +75,17 @@ test_fullscreen_main (int argc, char *argv[]) if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); + clutter_stage_set_title (CLUTTER_STAGE (stage), "Fullscreen"); g_signal_connect (stage, "fullscreen", G_CALLBACK (on_fullscreen), NULL); g_signal_connect (stage, "unfullscreen", G_CALLBACK (on_unfullscreen), NULL); + g_signal_connect (stage, + "destroy", G_CALLBACK (clutter_main_quit), + NULL); clutter_stage_set_fullscreen (CLUTTER_STAGE (stage), TRUE); clutter_actor_show (stage); @@ -91,9 +95,15 @@ test_fullscreen_main (int argc, char *argv[]) clutter_actor_get_height (stage), CLUTTER_ACTOR_IS_MAPPED (stage) ? "true" : "false"); - g_timeout_add (1000, toggle_fullscreen, NULL); + clutter_threads_add_timeout (1000, toggle_fullscreen, stage); clutter_main (); return EXIT_SUCCESS; } + +G_MODULE_EXPORT const char * +test_fullscreen_describe (void) +{ + return "Check behaviour of the Stage during fullscreen."; +} diff --git a/tests/interactive/test-grab.c b/tests/interactive/test-grab.c index 26ef6a669..931d0c464 100644 --- a/tests/interactive/test-grab.c +++ b/tests/interactive/test-grab.c @@ -170,9 +170,11 @@ test_grab_main (int argc, char *argv[]) g_print ("Green box: toggle per actor motion events.\n\n"); g_print ("Cyan box: toggle grab (from cyan box) for keyboard events.\n\n"); - stage = clutter_stage_get_default (); - g_signal_connect (stage, "event", G_CALLBACK (debug_event_cb), "stage"); - + stage = clutter_stage_new (); + clutter_stage_set_title (CLUTTER_STAGE (stage), "Grabs"); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); + g_signal_connect (stage, "event", + G_CALLBACK (debug_event_cb), "stage"); g_signal_connect (stage, "fullscreen", G_CALLBACK (stage_state_cb), "fullscreen"); g_signal_connect (stage, "unfullscreen", @@ -241,3 +243,9 @@ test_grab_main (int argc, char *argv[]) return 0; } + +G_MODULE_EXPORT const char * +test_grab_describe (void) +{ + return "Examples of using actor grabs"; +} diff --git a/tests/interactive/test-layout.c b/tests/interactive/test-layout.c index ee8649d0e..20536907a 100644 --- a/tests/interactive/test-layout.c +++ b/tests/interactive/test-layout.c @@ -751,8 +751,10 @@ test_layout_main (int argc, char *argv[]) if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_actor_set_size (stage, 800, 600); + clutter_stage_set_title (CLUTTER_STAGE (stage), "Layout"); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); main_timeline = clutter_timeline_new (2000); clutter_timeline_set_loop (main_timeline, TRUE); @@ -823,3 +825,9 @@ test_layout_main (int argc, char *argv[]) return EXIT_SUCCESS; } + +G_MODULE_EXPORT const char * +test_layout_describe (void) +{ + return "Container implementing a layout policy."; +} diff --git a/tests/interactive/test-main.c b/tests/interactive/test-main.c index cec02cf51..586d6dc70 100644 --- a/tests/interactive/test-main.c +++ b/tests/interactive/test-main.c @@ -149,7 +149,15 @@ main (int argc, char **argv) goto out; } - n_unit_names = g_strv_length (unit_names); + if (unit_names != NULL) + n_unit_names = g_strv_length (unit_names); + else + { + g_print ("Usage: test-interactive \n"); + ret = EXIT_FAILURE; + goto out; + } + for (i = 0; i < n_unit_names; i++) { const char *unit_name = unit_names[i]; diff --git a/tests/interactive/test-multistage.c b/tests/interactive/test-multistage.c index 3a877fc81..5ae0d96c9 100644 --- a/tests/interactive/test-multistage.c +++ b/tests/interactive/test-multistage.c @@ -117,10 +117,12 @@ test_multistage_main (int argc, char *argv[]) if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; - stage_default = clutter_stage_get_default (); + stage_default = clutter_stage_new (); clutter_stage_set_title (CLUTTER_STAGE (stage_default), "Default Stage"); clutter_actor_set_name (stage_default, "Default Stage"); - + g_signal_connect (stage_default, "destroy", + G_CALLBACK (clutter_main_quit), + NULL); g_signal_connect (stage_default, "button-press-event", G_CALLBACK (on_button_press), NULL); diff --git a/tests/interactive/test-paint-wrapper.c b/tests/interactive/test-paint-wrapper.c index b51562a4c..e06c87ff0 100644 --- a/tests/interactive/test-paint-wrapper.c +++ b/tests/interactive/test-paint-wrapper.c @@ -32,6 +32,8 @@ typedef struct SuperOH ClutterBehaviour *scaler_2; ClutterTimeline *timeline; + guint frame_id; + gboolean *paint_guards; } SuperOH; @@ -187,6 +189,16 @@ hand_post_paint (ClutterActor *actor, oh->paint_guards[actor_num] = FALSE; } +static void +stop_and_quit (ClutterActor *actor, + SuperOH *oh) +{ + g_signal_handler_disconnect (oh->timeline, oh->frame_id); + clutter_timeline_stop (oh->timeline); + + clutter_main_quit (); +} + G_MODULE_EXPORT int test_paint_wrapper_main (int argc, char *argv[]) { @@ -217,7 +229,9 @@ test_paint_wrapper_main (int argc, char *argv[]) return EXIT_FAILURE; } - stage = clutter_stage_get_default (); + oh = g_new(SuperOH, 1); + + stage = clutter_stage_new (); clutter_actor_set_size (stage, 800, 600); if (use_alpha != 255) @@ -228,8 +242,8 @@ test_paint_wrapper_main (int argc, char *argv[]) clutter_stage_set_title (CLUTTER_STAGE (stage), "Paint Test"); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); + g_signal_connect (stage, "destroy", G_CALLBACK (stop_and_quit), oh); - oh = g_new(SuperOH, 1); oh->stage = stage; /* Create a timeline to manage animation */ @@ -237,7 +251,8 @@ test_paint_wrapper_main (int argc, char *argv[]) clutter_timeline_set_loop (oh->timeline, TRUE); /* fire a callback for frame change */ - g_signal_connect (oh->timeline, "new-frame", G_CALLBACK (frame_cb), oh); + oh->frame_id = + g_signal_connect (oh->timeline, "new-frame", G_CALLBACK (frame_cb), oh); /* Set up some behaviours to handle scaling */ alpha = clutter_alpha_new_with_func (oh->timeline, my_sine_wave, NULL, NULL); @@ -347,3 +362,9 @@ test_paint_wrapper_main (int argc, char *argv[]) return 0; } + +G_MODULE_EXPORT const char * +test_paint_wrapper_describe (void) +{ + return "Wrap an actor's paint cycle for pre and post processing."; +} diff --git a/tests/interactive/test-pixmap.c b/tests/interactive/test-pixmap.c index b6ce2daa2..371276449 100644 --- a/tests/interactive/test-pixmap.c +++ b/tests/interactive/test-pixmap.c @@ -235,9 +235,11 @@ test_pixmap_main (int argc, char **argv) XMapWindow (xdpy, win_remote); - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_actor_set_position (stage, 0, 150); clutter_stage_set_color (CLUTTER_STAGE (stage), &gry); + clutter_stage_set_title (CLUTTER_STAGE (stage), "X11 Texture from Pixmap"); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); timeline = clutter_timeline_new (5000); g_signal_connect (timeline, @@ -315,3 +317,9 @@ test_pixmap_main (int argc, char **argv) return EXIT_SUCCESS; } + +G_MODULE_EXPORT const char * +test_pixmap_describe (void) +{ + return "GLX Texture from pixmap extension support."; +} diff --git a/tests/interactive/test-scale.c b/tests/interactive/test-scale.c index 506948ba5..4564fea2b 100644 --- a/tests/interactive/test-scale.c +++ b/tests/interactive/test-scale.c @@ -59,10 +59,11 @@ test_scale_main (int argc, char *argv[]) if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; - stage = clutter_stage_get_default (); - + stage = clutter_stage_new (); + clutter_stage_set_title (CLUTTER_STAGE (stage), "Scaling"); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); clutter_actor_set_size (stage, 300, 300); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); rect = clutter_rectangle_new_with_color (&rect_color); clutter_actor_set_size (rect, 100, 100); @@ -113,3 +114,9 @@ test_scale_main (int argc, char *argv[]) return EXIT_SUCCESS; } + +G_MODULE_EXPORT const char * +test_scale_describe (void) +{ + return "Scaling animation and scaling center changes"; +} diff --git a/tests/interactive/test-stage-read-pixels.c b/tests/interactive/test-stage-read-pixels.c index b49afc62e..535fc8d65 100644 --- a/tests/interactive/test-stage-read-pixels.c +++ b/tests/interactive/test-stage-read-pixels.c @@ -137,7 +137,9 @@ test_stage_read_pixels_main (int argc, char **argv) return 1; data.idle_source = 0; - data.stage = clutter_stage_get_default (); + data.stage = clutter_stage_new (); + clutter_stage_set_title (CLUTTER_STAGE (data.stage), "Read Pixels"); + g_signal_connect (data.stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); data.tex = make_tex (); data.box = make_box (); @@ -158,3 +160,9 @@ test_stage_read_pixels_main (int argc, char **argv) return 0; } + +G_MODULE_EXPORT const char * +test_stage_read_pixels_describe (void) +{ + return "Read back pixels from a Stage."; +} diff --git a/tests/interactive/test-stage-sizing.c b/tests/interactive/test-stage-sizing.c index f4bd6867f..0a939962f 100644 --- a/tests/interactive/test-stage-sizing.c +++ b/tests/interactive/test-stage-sizing.c @@ -44,7 +44,9 @@ test_stage_sizing_main (int argc, char *argv[]) if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); + clutter_stage_set_title (CLUTTER_STAGE (stage), "Stage Sizing"); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); label = clutter_text_new_with_text ("Sans 16", "Toggle fullscreen"); rect = clutter_rectangle_new_with_color (CLUTTER_COLOR_LightScarletRed); @@ -107,3 +109,9 @@ test_stage_sizing_main (int argc, char *argv[]) return EXIT_SUCCESS; } + +G_MODULE_EXPORT const char * +test_stage_sizing_describe (void) +{ + return "Check stage sizing policies."; +} diff --git a/tests/interactive/test-state-animator.c b/tests/interactive/test-state-animator.c index 6a77d7b91..94d93c211 100644 --- a/tests/interactive/test-state-animator.c +++ b/tests/interactive/test-state-animator.c @@ -52,14 +52,17 @@ test_state_animator_main (gint argc, ClutterActor *stage; ClutterActor *rects[40]; gint i; + if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); + clutter_stage_set_title (CLUTTER_STAGE (stage), "State and Animator"); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); - for (i=0; i<2; i++) + for (i = 0; i < 2; i++) { - rects[i]=new_rect (255 *(i * 1.0/40), 50, 160, 255); + rects[i] = new_rect (255 * (i * 1.0 / 40), 50, 160, 255); clutter_container_add_actor (CLUTTER_CONTAINER (stage), rects[i]); clutter_actor_set_anchor_point (rects[i], 64, 64); clutter_actor_set_position (rects[i], 320.0, 240.0); @@ -133,3 +136,9 @@ test_state_animator_main (gint argc, return EXIT_SUCCESS; } + +G_MODULE_EXPORT const char * +test_state_animator_describe (void) +{ + return "Animate using the State and Animator classes."; +} diff --git a/tests/interactive/test-state.c b/tests/interactive/test-state.c index f02ecc69e..a8767e69e 100644 --- a/tests/interactive/test-state.c +++ b/tests/interactive/test-state.c @@ -92,24 +92,26 @@ G_MODULE_EXPORT gint test_state_main (gint argc, gchar **argv) { - ClutterColor black={0,0,0,0xff}; ClutterActor *stage; ClutterState *layout_state; gint i; + if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; - stage = clutter_stage_get_default (); layout_state = clutter_state_new (); - clutter_stage_set_color (CLUTTER_STAGE (stage), &black); - clutter_actor_set_size (stage, STAGE_WIDTH, STAGE_HEIGHT); + stage = clutter_stage_new (); + clutter_stage_set_color (CLUTTER_STAGE (stage), CLUTTER_COLOR_Black); + clutter_stage_set_title (CLUTTER_STAGE (stage), "State Machine"); + clutter_actor_set_size (stage, STAGE_WIDTH, STAGE_HEIGHT); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); g_signal_connect (stage, "button-press-event", G_CALLBACK (press_event), layout_state); g_signal_connect (stage, "button-release-event", G_CALLBACK (release_event), layout_state); - for (i=0; i