From deba576dd1ad5ca55c713dcc808e91adf9d2f1df Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 8 Nov 2011 17:04:44 +0000 Subject: [PATCH 01/14] conform/*: Do not use clutter_stage_get_default() Use the correct stage creation/destruction API. --- tests/conform/test-actor-invariants.c | 44 ++++++++++------ tests/conform/test-anchors.c | 4 +- tests/conform/test-cally-text.c | 8 +-- tests/conform/test-clutter-cairo-texture.c | 4 +- tests/conform/test-clutter-texture.c | 4 +- tests/conform/test-cogl-backface-culling.c | 5 +- tests/conform/test-cogl-blend-strings.c | 5 +- tests/conform/test-cogl-depth-test.c | 5 +- tests/conform/test-cogl-just-vertex-shader.c | 7 +-- tests/conform/test-cogl-materials.c | 5 +- tests/conform/test-cogl-multitexture.c | 4 +- tests/conform/test-cogl-npot-texture.c | 20 ++++--- tests/conform/test-cogl-offscreen.c | 8 +-- tests/conform/test-cogl-path.c | 5 +- .../conform/test-cogl-pipeline-user-matrix.c | 4 +- tests/conform/test-cogl-pixel-buffer.c | 8 +-- tests/conform/test-cogl-premult.c | 5 +- tests/conform/test-cogl-primitive.c | 5 +- tests/conform/test-cogl-readpixels.c | 8 +-- tests/conform/test-cogl-sub-texture.c | 8 +-- tests/conform/test-cogl-texture-3d.c | 6 +-- .../conform/test-cogl-texture-get-set-data.c | 4 +- tests/conform/test-cogl-texture-mipmaps.c | 5 +- tests/conform/test-cogl-texture-pixmap-x11.c | 52 +++++++++---------- tests/conform/test-cogl-texture-rectangle.c | 4 +- .../test-cogl-vertex-buffer-contiguous.c | 5 +- .../test-cogl-vertex-buffer-interleved.c | 5 +- .../test-cogl-vertex-buffer-mutability.c | 5 +- tests/conform/test-cogl-viewport.c | 8 +-- tests/conform/test-cogl-wrap-modes.c | 4 +- tests/conform/test-conform-main.c | 1 + tests/conform/test-offscreen-redirect.c | 4 +- tests/conform/test-paint-opacity.c | 14 +++-- tests/conform/test-pick.c | 5 +- tests/conform/test-score.c | 2 +- tests/conform/test-shader-effect.c | 4 +- tests/conform/test-text-cache.c | 4 +- tests/conform/test-texture-fbo.c | 20 ++----- 38 files changed, 167 insertions(+), 151 deletions(-) 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..2554cfdd7 100644 --- a/tests/conform/test-score.c +++ b/tests/conform/test-score.c @@ -54,7 +54,7 @@ test_score (TestConformSimpleFixture *fixture, ClutterTimeline *timeline_5; GSList *timelines; - /* this is necessary to make the master clock spin */ + /* FIXME - this is necessary to make the master clock spin */ (void) clutter_stage_get_default (); timeline_1 = clutter_timeline_new (100); 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"); } - From a5522b707ecb719d05e57702b65be1a2cec250ac Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 8 Nov 2011 17:11:34 +0000 Subject: [PATCH 02/14] accessibility/*: Do not use clutter_stage_get_default() --- tests/accessibility/cally-atkcomponent-example.c | 3 ++- .../cally-atkeditabletext-example.c | 6 +++--- tests/accessibility/cally-atkevents-example.c | 16 +++++++++++----- tests/accessibility/cally-atktext-example.c | 7 +++++-- tests/accessibility/cally-clone-example.c | 8 ++++++-- 5 files changed, 27 insertions(+), 13 deletions(-) diff --git a/tests/accessibility/cally-atkcomponent-example.c b/tests/accessibility/cally-atkcomponent-example.c index 7d4ebcd08..853ccbe91 100644 --- a/tests/accessibility/cally-atkcomponent-example.c +++ b/tests/accessibility/cally-atkcomponent-example.c @@ -45,8 +45,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 - AtkComponent Test"); clutter_stage_set_color (CLUTTER_STAGE (stage), CLUTTER_COLOR_White); clutter_actor_set_size (stage, WIDTH, HEIGHT); diff --git a/tests/accessibility/cally-atkeditabletext-example.c b/tests/accessibility/cally-atkeditabletext-example.c index d13913819..4f2e7320c 100644 --- a/tests/accessibility/cally-atkeditabletext-example.c +++ b/tests/accessibility/cally-atkeditabletext-example.c @@ -168,12 +168,12 @@ _create_button (const gchar *text) 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 */ @@ -256,7 +256,7 @@ main (int argc, char *argv[]) cally_util_a11y_init (&argc, &argv); - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); make_ui (stage); diff --git a/tests/accessibility/cally-atkevents-example.c b/tests/accessibility/cally-atkevents-example.c index ca0a00678..c3f2df299 100644 --- a/tests/accessibility/cally-atkevents-example.c +++ b/tests/accessibility/cally-atkevents-example.c @@ -138,8 +138,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,19 +171,25 @@ 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), "Cally - AtkEvents/1"); + 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"); + make_ui (stage); clutter_actor_show_all (stage); } clutter_main (); + clutter_actor_destroy (stage); + clutter_actor_destroy (stage_main); + return 0; } diff --git a/tests/accessibility/cally-atktext-example.c b/tests/accessibility/cally-atktext-example.c index 4d6099dc4..3ffade656 100644 --- a/tests/accessibility/cally-atktext-example.c +++ b/tests/accessibility/cally-atktext-example.c @@ -243,7 +243,7 @@ make_ui (ClutterActor *stage) int main (int argc, char *argv[]) { - ClutterActor *stage = NULL; + ClutterActor *stage; g_set_application_name ("AtkText"); @@ -252,7 +252,8 @@ 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"); make_ui (stage); @@ -263,5 +264,7 @@ main (int argc, char *argv[]) clutter_main (); + clutter_actor_destroy (stage); + return 0; } diff --git a/tests/accessibility/cally-clone-example.c b/tests/accessibility/cally-clone-example.c index 04137c2a6..3cc3acb9e 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,12 +102,16 @@ 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"); + make_ui (stage); clutter_actor_show_all (stage); clutter_main (); + clutter_actor_destroy (stage); + return 0; } From 93eb0bfe328598fe37a6469cd43ba8fa59ae147e Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 8 Nov 2011 17:23:52 +0000 Subject: [PATCH 03/14] micro-bench/*: Do not use clutter_stage_get_default() --- tests/micro-bench/test-cogl-perf.c | 14 ++++++-------- tests/micro-bench/test-picking.c | 10 ++++++---- tests/micro-bench/test-random-text.c | 5 ++++- tests/micro-bench/test-text-perf.c | 6 +++--- tests/micro-bench/test-text.c | 11 ++++++----- 5 files changed, 25 insertions(+), 21 deletions(-) diff --git a/tests/micro-bench/test-cogl-perf.c b/tests/micro-bench/test-cogl-perf.c index 0f97a95df..5f594e115 100644 --- a/tests/micro-bench/test-cogl-perf.c +++ b/tests/micro-bench/test-cogl-perf.c @@ -23,6 +23,7 @@ static GOptionEntry entries[] = { typedef struct _TestState { + ClutterActor *stage; int current_test; } TestState; @@ -89,8 +90,6 @@ test_rectangles (TestState *state) cogl_pop_matrix (); } } - - } TestCallback tests[] = @@ -117,8 +116,6 @@ main (int argc, char *argv[]) { TestState state; ClutterActor *stage; - ClutterColor stage_clr = {0x0, 0x0, 0x0, 0xff}; - guint idle_source; GError *error = NULL; g_setenv ("CLUTTER_VBLANK", "none", FALSE); @@ -139,13 +136,14 @@ main (int argc, char *argv[]) state.current_test = 0; - stage = clutter_stage_get_default (); + state.stage = stage = clutter_stage_new (); clutter_actor_set_size (stage, STAGE_WIDTH, STAGE_HEIGHT); - clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_clr); + clutter_stage_set_color (CLUTTER_STAGE (stage), CLUTTER_COLOR_White); + clutter_stage_set_title (CLUTTER_STAGE (stage), "Cogl Performance Test"); /* We want continuous redrawing of the stage... */ - idle_source = g_idle_add (queue_redraw, stage); + clutter_threads_add_idle (queue_redraw, stage); g_signal_connect_after (stage, "paint", G_CALLBACK (on_paint), &state); @@ -153,7 +151,7 @@ main (int argc, char *argv[]) clutter_main (); - g_source_remove (idle_source); + clutter_actor_destroy (stage); return 0; } diff --git a/tests/micro-bench/test-picking.c b/tests/micro-bench/test-picking.c index f66172905..094b657a5 100644 --- a/tests/micro-bench/test-picking.c +++ b/tests/micro-bench/test-picking.c @@ -72,7 +72,6 @@ main (int argc, char **argv) { glong i; gdouble angle; - const ClutterColor black = { 0x00, 0x00, 0x00, 0xff }; ClutterColor color = { 0x00, 0x00, 0x00, 0xff }; ClutterActor *stage, *rect; GError *error = NULL; @@ -88,9 +87,10 @@ main (int argc, char **argv) &error) != CLUTTER_INIT_SUCCESS) return 1; - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_actor_set_size (stage, 512, 512); - clutter_stage_set_color (CLUTTER_STAGE (stage), &black); + clutter_stage_set_color (CLUTTER_STAGE (stage), CLUTTER_COLOR_Black); + clutter_stage_set_title (CLUTTER_STAGE (stage), "Picking"); printf ("Picking performance test with " "%d actors and %d events per frame\n", @@ -126,12 +126,14 @@ main (int argc, char **argv) clutter_actor_show (stage); - g_idle_add (queue_redraw, stage); + clutter_threads_add_idle (queue_redraw, stage); g_signal_connect (stage, "paint", G_CALLBACK (on_paint), NULL); clutter_main (); + clutter_actor_destroy (stage); + return 0; } diff --git a/tests/micro-bench/test-random-text.c b/tests/micro-bench/test-random-text.c index b1f710d89..69eb6d018 100644 --- a/tests/micro-bench/test-random-text.c +++ b/tests/micro-bench/test-random-text.c @@ -90,7 +90,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 (); + clutter_stage_set_title (CLUTTER_STAGE (stage), "Random Text"); clutter_actor_show (stage); @@ -98,5 +99,7 @@ main (int argc, char *argv[]) clutter_main (); + clutter_actor_destroy (stage); + return 0; } diff --git a/tests/micro-bench/test-text-perf.c b/tests/micro-bench/test-text-perf.c index e21939caf..5e70ba716 100644 --- a/tests/micro-bench/test-text-perf.c +++ b/tests/micro-bench/test-text-perf.c @@ -105,7 +105,6 @@ int main (int argc, char *argv[]) { ClutterActor *stage; - ClutterColor stage_color = { 0x00, 0x00, 0x00, 0xff }; ClutterActor *label; int w, h; int row, col; @@ -128,9 +127,10 @@ main (int argc, char *argv[]) g_print ("Monospace %dpx, string length = %d\n", font_size, n_chars); - 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), &stage_color); + clutter_stage_set_color (CLUTTER_STAGE (stage), CLUTTER_COLOR_Black); + clutter_stage_set_title (CLUTTER_STAGE (stage), "Text Performance"); g_signal_connect (stage, "paint", G_CALLBACK (on_paint), NULL); diff --git a/tests/micro-bench/test-text.c b/tests/micro-bench/test-text.c index 93a8f5596..18cd775ec 100644 --- a/tests/micro-bench/test-text.c +++ b/tests/micro-bench/test-text.c @@ -43,8 +43,6 @@ int main (int argc, char *argv[]) { ClutterActor *stage; - ClutterColor stage_color = { 0x00, 0x00, 0x00, 0xff }; - ClutterColor label_color = { 0xff, 0xff, 0xff, 0xff }; ClutterActor *group; g_setenv ("CLUTTER_VBLANK", "none", FALSE); @@ -53,9 +51,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, STAGE_WIDTH, STAGE_HEIGHT); - clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); + clutter_stage_set_color (CLUTTER_STAGE (stage), CLUTTER_COLOR_Black); + clutter_stage_set_title (CLUTTER_STAGE (stage), "Text"); group = clutter_group_new (); clutter_actor_set_size (group, STAGE_WIDTH, STAGE_WIDTH); @@ -98,7 +97,7 @@ main (int argc, char *argv[]) } label = clutter_text_new_with_text (font_name, text); - clutter_text_set_color (CLUTTER_TEXT (label), &label_color); + clutter_text_set_color (CLUTTER_TEXT (label), CLUTTER_COLOR_White); clutter_actor_set_position (label, (1.0*STAGE_WIDTH/COLS)*col, (1.0*STAGE_HEIGHT/ROWS)*row); /*clutter_actor_set_clip (label, 0,0, (1.0*STAGE_WIDTH/COLS), @@ -115,5 +114,7 @@ main (int argc, char *argv[]) clutter_main(); + clutter_actor_destroy (stage); + return 0; } From 6ed879b84cad6b8b69403813acdd811de98e9f00 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Wed, 9 Nov 2011 10:55:49 +0000 Subject: [PATCH 04/14] Merge with a11y --- .../accessibility/cally-atkcomponent-example.c | 2 ++ .../cally-atkeditabletext-example.c | 17 +++++++---------- tests/accessibility/cally-atkevents-example.c | 12 +++++------- tests/accessibility/cally-atktext-example.c | 4 +--- tests/accessibility/cally-clone-example.c | 3 +-- 5 files changed, 16 insertions(+), 22 deletions(-) diff --git a/tests/accessibility/cally-atkcomponent-example.c b/tests/accessibility/cally-atkcomponent-example.c index 853ccbe91..79a816bde 100644 --- a/tests/accessibility/cally-atkcomponent-example.c +++ b/tests/accessibility/cally-atkcomponent-example.c @@ -51,6 +51,8 @@ main (int argc, char *argv[]) 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 4f2e7320c..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,12 +163,9 @@ _create_button (const gchar *text) return button; } - static void make_ui (ClutterActor *stage) { - ClutterColor color_text = { 0xff, 0x00, 0x00, 0xff }; - ClutterColor color_sel = { 0x00, 0xff, 0x00, 0x55 }; ClutterActor *button = NULL; clutter_stage_set_title (CLUTTER_STAGE (stage), "Cally - AtkEditable Test"); @@ -179,18 +175,18 @@ make_ui (ClutterActor *stage) /* 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); @@ -257,6 +253,7 @@ main (int argc, char *argv[]) cally_util_a11y_init (&argc, &argv); 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 c3f2df299..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,7 +137,7 @@ make_ui (ClutterActor *stage) int main (int argc, char *argv[]) { - ClutterActor *stage, *stage_main + ClutterActor *stage, *stage_main; Data data1, data2, data3; guint id_2 = 0; @@ -172,7 +171,8 @@ main (int argc, char *argv[]) atk_add_global_event_listener (window_event_listener, "Atk:AtkWindow:deactivate"); stage_main = clutter_stage_new (); - clutter_stage_set_title (CLUTTER_STAGE (stage), "Cally - AtkEvents/1"); + 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_main); @@ -181,6 +181,7 @@ main (int argc, char *argv[]) { 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); @@ -188,8 +189,5 @@ main (int argc, char *argv[]) clutter_main (); - clutter_actor_destroy (stage); - clutter_actor_destroy (stage_main); - return 0; } diff --git a/tests/accessibility/cally-atktext-example.c b/tests/accessibility/cally-atktext-example.c index 3ffade656..f7218ce60 100644 --- a/tests/accessibility/cally-atktext-example.c +++ b/tests/accessibility/cally-atktext-example.c @@ -237,7 +237,6 @@ make_ui (ClutterActor *stage) G_CALLBACK (button_press_cb), NULL); clutter_container_add_actor (CLUTTER_CONTAINER (stage), button); - } int @@ -254,6 +253,7 @@ main (int argc, char *argv[]) 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); @@ -264,7 +264,5 @@ main (int argc, char *argv[]) clutter_main (); - clutter_actor_destroy (stage); - return 0; } diff --git a/tests/accessibility/cally-clone-example.c b/tests/accessibility/cally-clone-example.c index 3cc3acb9e..9cc2d6856 100644 --- a/tests/accessibility/cally-clone-example.c +++ b/tests/accessibility/cally-clone-example.c @@ -104,6 +104,7 @@ main (int argc, char *argv[]) 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); @@ -111,7 +112,5 @@ main (int argc, char *argv[]) clutter_main (); - clutter_actor_destroy (stage); - return 0; } From 7c180a074275ce0eb06165bb6eba83273b5056d2 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Wed, 9 Nov 2011 13:41:15 +0000 Subject: [PATCH 05/14] interactive/*: Do not use clutter_stage_get_default() --- tests/conform/test-score.c | 4 +- tests/conform/test-timeline.c | 5 +- tests/interactive/test-actor-clone.c | 34 ++++++++--- tests/interactive/test-animation.c | 7 ++- tests/interactive/test-animator.c | 11 ++-- tests/interactive/test-bin-layout.c | 11 +++- tests/interactive/test-binding-pool.c | 9 ++- tests/interactive/test-box-layout.c | 9 ++- tests/interactive/test-cairo-flowers.c | 46 +++++++++----- tests/interactive/test-clip.c | 10 ++- tests/interactive/test-cogl-multitexture.c | 17 ++++-- tests/interactive/test-cogl-offscreen.c | 67 +++++++++++++-------- tests/interactive/test-cogl-point-sprites.c | 14 +++-- tests/interactive/test-cogl-primitives.c | 11 +++- tests/interactive/test-cogl-tex-convert.c | 13 +++- tests/interactive/test-cogl-tex-foreign.c | 13 +++- tests/interactive/test-cogl-tex-getset.c | 13 +++- tests/interactive/test-cogl-tex-polygon.c | 11 +++- tests/interactive/test-cogl-tex-tile.c | 11 +++- tests/interactive/test-cogl-vertex-buffer.c | 38 ++++++++---- tests/interactive/test-events.c | 61 +++++++++---------- tests/interactive/test-fbo.c | 10 ++- tests/interactive/test-flow-layout.c | 9 ++- tests/interactive/test-fullscreen.c | 20 ++++-- tests/interactive/test-grab.c | 14 ++++- tests/interactive/test-layout.c | 10 ++- tests/interactive/test-main.c | 10 ++- tests/interactive/test-multistage.c | 6 +- tests/interactive/test-paint-wrapper.c | 27 ++++++++- tests/interactive/test-pixmap.c | 10 ++- tests/interactive/test-scale.c | 11 +++- tests/interactive/test-stage-read-pixels.c | 10 ++- tests/interactive/test-stage-sizing.c | 10 ++- tests/interactive/test-state-animator.c | 15 ++++- tests/interactive/test-state.c | 23 ++++--- tests/interactive/test-swipe-action.c | 11 +++- tests/interactive/test-table-layout.c | 5 +- tests/interactive/test-text.c | 20 +++--- tests/interactive/test-texture-quality.c | 14 ++++- tests/interactive/test-texture-slicing.c | 9 ++- tests/interactive/test-unproject.c | 14 +++-- 41 files changed, 491 insertions(+), 182 deletions(-) diff --git a/tests/conform/test-score.c b/tests/conform/test-score.c index 2554cfdd7..a827f7efa 100644 --- a/tests/conform/test-score.c +++ b/tests/conform/test-score.c @@ -55,7 +55,7 @@ test_score (TestConformSimpleFixture *fixture, GSList *timelines; /* FIXME - this is necessary to make the master clock spin */ - (void) clutter_stage_get_default (); + 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-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 Date: Wed, 9 Nov 2011 13:52:03 +0000 Subject: [PATCH 06/14] performance/*: Do not use clutter_stage_get_default() --- tests/performance/test-picking.c | 9 +++++---- tests/performance/test-state-hidden.c | 7 ++++--- tests/performance/test-state-interactive.c | 6 +++--- tests/performance/test-state-mini.c | 7 ++++--- tests/performance/test-state-pick.c | 7 ++++--- tests/performance/test-state.c | 7 ++++--- tests/performance/test-text-perf.c | 4 +++- 7 files changed, 27 insertions(+), 20 deletions(-) diff --git a/tests/performance/test-picking.c b/tests/performance/test-picking.c index 9362d35eb..3432166ca 100644 --- a/tests/performance/test-picking.c +++ b/tests/performance/test-picking.c @@ -67,7 +67,6 @@ main (int argc, char **argv) { glong i; gdouble angle; - const ClutterColor black = { 0x00, 0x00, 0x00, 0xff }; ClutterColor color = { 0x00, 0x00, 0x00, 0xff }; ClutterActor *stage, *rect; @@ -84,9 +83,11 @@ main (int argc, char **argv) return -1; } - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); clutter_actor_set_size (stage, 512, 512); - clutter_stage_set_color (CLUTTER_STAGE (stage), &black); + clutter_stage_set_color (CLUTTER_STAGE (stage), CLUTTER_COLOR_Black); + clutter_stage_set_title (CLUTTER_STAGE (stage), "Picking Performance"); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); printf ("Picking performance test with " "%d actors and %d events per frame\n", @@ -123,7 +124,7 @@ main (int argc, char **argv) clutter_actor_show (stage); clutter_perf_fps_start (CLUTTER_STAGE (stage)); - g_idle_add (queue_redraw, (gpointer)stage); + clutter_threads_add_idle (queue_redraw, stage); clutter_main (); clutter_perf_fps_report ("test-picking"); diff --git a/tests/performance/test-state-hidden.c b/tests/performance/test-state-hidden.c index 699beffc6..64911b4eb 100644 --- a/tests/performance/test-state-hidden.c +++ b/tests/performance/test-state-hidden.c @@ -53,7 +53,6 @@ gint main (gint argc, gchar **argv) { - ClutterColor black={0,0,0,0xff}; ClutterActor *stage; ClutterActor *group; ClutterState *layout_state; @@ -63,11 +62,13 @@ main (gint argc, if (CLUTTER_INIT_SUCCESS != clutter_init (&argc, &argv)) g_error ("Failed to initialize Clutter"); - stage = clutter_stage_get_default (); + stage = clutter_stage_new (); group = clutter_group_new (); layout_state = clutter_state_new (); - clutter_stage_set_color (CLUTTER_STAGE (stage), &black); + clutter_stage_set_title (CLUTTER_STAGE (stage), "State Performance [hidden]"); + clutter_stage_set_color (CLUTTER_STAGE (stage), CLUTTER_COLOR_Black); clutter_actor_set_size (stage, STAGE_WIDTH, STAGE_HEIGHT); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); for (i=0; i Date: Wed, 9 Nov 2011 14:04:05 +0000 Subject: [PATCH 07/14] Try to mop up the default stage mess MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The default stage was a neat concept when we started Clutter out, somewhere in the Jurassic era; a singleton instance that gets created at initialization time, and remains the same for the entire duration of the process. Worked well enough when Clutter was a small library meant to be used to write fullscreen media browsers, but since the introduction of multiple stages, and Clutter being used to create all sorts of applications, the default stage is just a vestigial remainder of that past, like an appendix; something that complicates the layout of the code and introduces weird behaviour, so that you notice its existence only when something goes wrong. Some platforms we do support, though, only have one framebuffer, so it makes sense for them to have only one stage. At this point, the only sane thing to do is to go through the same code paths on all platforms, and that code path is the stage instance creation and initialization — i.e. clutter_stage_new() (or g_object_new() with CLUTTER_TYPE_STAGE). For platforms that support multiple stages, nothing has changed: the stage created by clutter_stage_get_default() will be set as the default one; if nobody calls it, the default stage is never created, and it just lives on as a meaningless check. For platforms that only support one stage, clutter_stage_new() and clutter_stage_get_default() will behave exactly the same the first time they are called: both will create a stage, and set it as the default. Calling clutter_stage_new() a second time is treated as a programmer error, and will result in Clutter aborting. This is a behavioural change because the existing behaviour or creating a new ClutterStage instance with the same ClutterStageWindow private implementation is, simply put, utterly braindamaged and I should have *never* had written it, and I apologize for it. In my defence, I didn't know any better at the time. This is the first step towards the complete deprecation of clutter_stage_get_default() and clutter_stage_is_default(), which will come later. --- clutter/clutter-backend.c | 5 -- clutter/clutter-stage.c | 114 ++++++++++++++++++++++++++------------ 2 files changed, 79 insertions(+), 40 deletions(-) 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-stage.c b/clutter/clutter-stage.c index 416ca4f7c..f606ec22b 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 @@ -1497,6 +1492,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 +1730,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 +2072,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 +2084,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,15 +2176,26 @@ 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. */ ClutterActor * @@ -3149,16 +3203,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); } @@ -3480,7 +3524,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; From b1ccd262b1a8ba01d214090052f99ef408bff299 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Wed, 9 Nov 2011 17:03:30 +0000 Subject: [PATCH 08/14] cally/actor: Do not use the default stage as a fallback Using the default stage as a fallback is wrong in all circumstances. In this specific case, if an actor is not associated to a stage then it cannot possibly be the key focus. --- clutter/cally/cally-actor.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) 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; From 2288d708e2f6ad9f8348f738a44cc7d29cf95530 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Wed, 9 Nov 2011 17:09:37 +0000 Subject: [PATCH 09/14] script: Do not use clutter_stage_get_default() It's about to go away, so we should use the StageManager API instead. --- clutter/clutter-script-parser.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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++) { From 0c18dc6bf90cf521327869738b206274584c695e Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Wed, 9 Nov 2011 17:12:45 +0000 Subject: [PATCH 10/14] stage: Deprecate the default stage Deprecate the clutter_stage_get_default() function, as well as the clutter_stage_is_default() one, and replace its internal usage. --- clutter/clutter-stage.c | 38 ++++++++++++++++++++---------- clutter/clutter-stage.h | 2 -- clutter/deprecated/clutter-stage.h | 6 +++++ 3 files changed, 31 insertions(+), 15 deletions(-) diff --git a/clutter/clutter-stage.c b/clutter/clutter-stage.c index f606ec22b..60370f1c8 100644 --- a/clutter/clutter-stage.c +++ b/clutter/clutter-stage.c @@ -276,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, @@ -1472,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)); @@ -2197,6 +2214,8 @@ clutter_stage_init (ClutterStage *self) * Return value: (transfer none) (type Clutter.Stage): the main * #ClutterStage. You should never destroy or unref the returned * actor. + * + * Deprecated: 1.10: Use clutter_stage_new() instead. */ ClutterActor * clutter_stage_get_default (void) @@ -3497,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 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__ */ From 26aa4b5290c65984a0512a0ba4a30ab777628269 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Wed, 9 Nov 2011 17:49:25 +0000 Subject: [PATCH 11/14] docs: Remove clutter_stage_get_default() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A lot of the example code in the cookbook and the API reference still uses the default stage — sometimes as if it were a non-default one, which once again demonstrates how the default stage was a flawed concept that just confused people. --- clutter/clutter-actor.c | 2 +- doc/cookbook/examples/animations-looping-animator.c | 2 +- doc/cookbook/examples/animations-looping-implicit.c | 2 +- doc/cookbook/examples/animations-looping-state.c | 2 +- doc/cookbook/examples/animations-moving-animator.c | 2 +- doc/cookbook/examples/animations-moving-implicit.c | 2 +- doc/cookbook/examples/animations-moving-state.c | 2 +- doc/cookbook/examples/animations-rotating.c | 2 +- doc/cookbook/examples/animations-scaling-zoom.c | 2 +- doc/cookbook/examples/animations-scaling.c | 2 +- doc/cookbook/examples/events-buttons-click.c | 2 +- doc/cookbook/examples/events-buttons-lasso.c | 2 +- doc/cookbook/examples/events-buttons.c | 2 +- doc/cookbook/examples/events-mouse-scroll.c | 3 ++- doc/cookbook/examples/events-pointer-motion-crossing.c | 2 +- doc/cookbook/examples/events-pointer-motion-scribbler.c | 3 ++- doc/cookbook/examples/events-pointer-motion-stacked.c | 3 ++- doc/cookbook/examples/events-pointer-motion.c | 3 ++- doc/cookbook/examples/layouts-bind-constraint-allocation.c | 2 +- doc/cookbook/examples/layouts-box-menu.c | 2 +- doc/cookbook/examples/layouts-box-property-effects.c | 2 +- doc/cookbook/examples/layouts-box.c | 2 +- doc/cookbook/examples/layouts-stacking-diff-sized-actors.c | 3 ++- doc/cookbook/examples/layouts-stacking.c | 3 ++- doc/cookbook/examples/textures-crossfade-cogl.c | 2 +- doc/cookbook/examples/textures-crossfade-slideshow.c | 2 +- doc/cookbook/examples/textures-crossfade.c | 2 +- doc/cookbook/examples/textures-split-go.c | 3 ++- doc/cookbook/examples/textures-sub-texture.c | 3 ++- doc/reference/clutter/clutter-animation-tutorial.xml | 3 ++- 30 files changed, 39 insertions(+), 30 deletions(-) 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/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); From b38773f4588f104e0dca8f235344d1599c0d560a Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 10 Nov 2011 15:09:04 +0000 Subject: [PATCH 12/14] docs: Note default stage deprecation in README Mention the behaviour of Clutter when creating more than one stage on platforms that only support one stage instance. --- README.in | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.in b/README.in index 8d2c4668f..15ef48eff 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: From 5705d08b5d50901e2f752a505e7daab3e98696ae Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Fri, 17 Jun 2011 11:31:34 +0100 Subject: [PATCH 13/14] evdev: don't even process events without a default stage The evdev system is a bit different from other input systems in Clutter because it's completly decorrelated from anything graphic. In the case of embedded devices with no proper windowing system, you might want to not implicitly create a default stage when you're receiving the first input event. This patch changes this behavior by not forwarding any event if you don't have a default stage. Signed-off-by: Lionel Landwerlin https://bugzilla.gnome.org/show_bug.cgi?id=651718 --- clutter/evdev/clutter-device-manager-evdev.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/clutter/evdev/clutter-device-manager-evdev.c b/clutter/evdev/clutter-device-manager-evdev.c index 26079f1d2..80c069825 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]; From 213e6e4a1606945b1e2bbb93289da31aea5edcbe Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Thu, 10 Nov 2011 15:41:41 +0000 Subject: [PATCH 14/14] evdev: do not associate device with stage Their might not be any stage at that time, so this avoids to create a default one. Signed-off-by: Emmanuele Bassi https://bugzilla.gnome.org/show_bug.cgi?id=651718 --- clutter/evdev/clutter-device-manager-evdev.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/clutter/evdev/clutter-device-manager-evdev.c b/clutter/evdev/clutter-device-manager-evdev.c index 80c069825..caa135551 100644 --- a/clutter/evdev/clutter-device-manager-evdev.c +++ b/clutter/evdev/clutter-device-manager-evdev.c @@ -540,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); @@ -583,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",