diff --git a/ChangeLog b/ChangeLog index 0daf190ff..3776ff9e9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2008-05-14 Emmanuele Bassi + + * tests/test-events.c: Clean up a bit, and print out more + messages when pressing one of the rectangles. + + * tests/test-threads.c: Be more verbose in the console, and + apply another behaviour on the rectangle, to show that we + are not blocking. + 2008-05-14 Øyvind Kolås * clutter/cogl/gles/cogl.c: (_cogl_features_init): do not set diff --git a/tests/test-events.c b/tests/test-events.c index ae5a03ad8..9bf5af489 100644 --- a/tests/test-events.c +++ b/tests/test-events.c @@ -27,6 +27,9 @@ blue_button_cb (ClutterActor *actor, g_object_set (stage, "fullscreen", IsFullScreen, NULL); + g_print ("*** Fullscreen %s ***\n", + IsFullScreen ? "enabled" : "disabled"); + return FALSE; } @@ -43,15 +46,19 @@ red_button_cb (ClutterActor *actor, clutter_set_motion_events_enabled (IsMotion); + g_print ("*** Per actor motion events %s ***\n", + IsMotion ? "enabled" : "disabled"); + return FALSE; } static gboolean -capture_cb (ClutterActor *actor, - ClutterEvent *event, - gpointer data) +capture_cb (ClutterActor *actor, + ClutterEvent *event, + gpointer data) { - printf("captured event for type '%s'\n", G_OBJECT_TYPE_NAME(actor)); + g_print ("* captured event for type '%s' *\n", + G_OBJECT_TYPE_NAME (actor)); return FALSE; } @@ -63,9 +70,7 @@ key_focus_in_cb (ClutterActor *actor, ClutterActor *focus_box = CLUTTER_ACTOR(data); if (actor == clutter_stage_get_default ()) - { - clutter_actor_hide (focus_box); - } + clutter_actor_hide (focus_box); else { clutter_actor_set_position (focus_box, @@ -94,30 +99,30 @@ input_cb (ClutterActor *actor, len = g_unichar_to_utf8 (clutter_keysym_to_unicode (event->key.keyval), keybuf); keybuf[len] = '\0'; - printf ("[%s] KEY PRESS '%s'", source, keybuf); + g_print ("[%s] KEY PRESS '%s'", source, keybuf); break; case CLUTTER_KEY_RELEASE: len = g_unichar_to_utf8 (clutter_keysym_to_unicode (event->key.keyval), keybuf); keybuf[len] = '\0'; - printf ("[%s] KEY RELEASE '%s'", source, keybuf); + g_print ("[%s] KEY RELEASE '%s'", source, keybuf); break; case CLUTTER_MOTION: - printf("[%s] MOTION", source); + g_print ("[%s] MOTION", source); break; case CLUTTER_ENTER: - printf("[%s] ENTER", source); + g_print ("[%s] ENTER", source); break; case CLUTTER_LEAVE: - printf("[%s] LEAVE", source); + g_print ("[%s] LEAVE", source); break; case CLUTTER_BUTTON_PRESS: - printf("[%s] BUTTON PRESS (click count:%i)", - source, event->button.click_count); + g_print ("[%s] BUTTON PRESS (click count:%i)", + source, event->button.click_count); break; case CLUTTER_BUTTON_RELEASE: - printf("[%s] BUTTON RELEASE (click count:%i)", - source, event->button.click_count); + g_print ("[%s] BUTTON RELEASE (click count:%i)", + source, event->button.click_count); if (clutter_event_get_source (event) == CLUTTER_ACTOR (stage)) clutter_stage_set_key_focus (stage, NULL); @@ -126,29 +131,29 @@ input_cb (ClutterActor *actor, clutter_stage_set_key_focus (stage, actor); break; case CLUTTER_SCROLL: - printf("[%s] BUTTON SCROLL (click count:%i)", - source, event->button.click_count); + g_print ("[%s] BUTTON SCROLL (click count:%i)", + source, event->button.click_count); break; case CLUTTER_STAGE_STATE: - printf("[%s] STAGE STATE", source); + g_print ("[%s] STAGE STATE", source); break; case CLUTTER_DESTROY_NOTIFY: - printf("[%s] DESTROY NOTIFY", source); + g_print ("[%s] DESTROY NOTIFY", source); break; case CLUTTER_CLIENT_MESSAGE: - printf("[%s] CLIENT MESSAGE\n", source); + g_print ("[%s] CLIENT MESSAGE", source); break; case CLUTTER_DELETE: - printf("[%s] DELETE", source); + g_print ("[%s] DELETE", source); break; case CLUTTER_NOTHING: return FALSE; } if (clutter_event_get_source (event) == actor) - printf(" *source*"); + g_print (" *source*"); - printf("\n"); + g_printf("\n"); return FALSE; } @@ -197,7 +202,8 @@ main (int argc, char *argv[]) focus_box); /* Toggle motion - enter/leave capture */ - g_signal_connect (actor, "button-press-event", G_CALLBACK (red_button_cb), NULL); + g_signal_connect (actor, "button-press-event", + G_CALLBACK (red_button_cb), NULL); clutter_stage_set_key_focus (CLUTTER_STAGE (stage), actor); @@ -227,7 +233,8 @@ main (int argc, char *argv[]) g_signal_connect (actor, "focus-in", G_CALLBACK (key_focus_in_cb), focus_box); /* Fullscreen */ - g_signal_connect (actor, "button-press-event", G_CALLBACK (blue_button_cb), NULL); + g_signal_connect (actor, "button-press-event", + G_CALLBACK (blue_button_cb), NULL); /* non reactive */ actor = clutter_rectangle_new_with_color (&ncol); @@ -252,8 +259,8 @@ main (int argc, char *argv[]) /* note group not reactive */ group = clutter_group_new (); - clutter_container_add (CLUTTER_CONTAINER(group), actor, NULL); - clutter_container_add (CLUTTER_CONTAINER(stage), group, NULL); + clutter_container_add (CLUTTER_CONTAINER (group), actor, NULL); + clutter_container_add (CLUTTER_CONTAINER (stage), group, NULL); clutter_actor_set_position (group, 100, 350); clutter_actor_show_all (group); diff --git a/tests/test-threads.c b/tests/test-threads.c index 9658d08aa..ad2cb4b6c 100644 --- a/tests/test-threads.c +++ b/tests/test-threads.c @@ -64,9 +64,11 @@ update_label_idle (gpointer data) text = g_strdup_printf ("Count to %d", update->count); clutter_label_set_text (CLUTTER_LABEL (update->thread_data->label), text); + clutter_actor_set_width (update->thread_data->label, -1); g_free (text); g_free (update); + return FALSE; } @@ -82,18 +84,27 @@ do_something_very_slow (void) for (i = 0; i < 100; i++) { - /* sleep for a while */ - g_usleep((rand() / (RAND_MAX / 3) + 1) * 1000000); + gint msecs; - if ((i % 10) == 0) + msecs = 1 + (int) (1000.0 * rand () / ((RAND_MAX + 1.0) / 3)); + + /* sleep for a while */ + g_usleep (msecs * 1000); + + if ((i % 10) == 0) { TestUpdate *update; update = g_new (TestUpdate, 1); update->count = i; update->thread_data = data; + + g_print ("updating the label: %d\n", update->count); + clutter_threads_add_idle (update_label_idle, update); } + + g_print ("slept to %d msecs\n", msecs); } } @@ -114,6 +125,7 @@ test_thread_func (gpointer user_data) static ClutterTimeline *timeline = NULL; static ClutterActor *count_label = NULL; +static ClutterActor *help_label = NULL; static void on_key_press_event (ClutterStage *stage, @@ -125,6 +137,8 @@ on_key_press_event (ClutterStage *stage, switch (clutter_key_event_symbol (event)) { case CLUTTER_s: + clutter_label_set_text (CLUTTER_LABEL (help_label), "Press 'q' to quit"); + clutter_timeline_start (timeline); data = test_thread_data_new (); @@ -143,49 +157,55 @@ int main (int argc, char *argv[]) { ClutterActor *stage; - ClutterActor *label; ClutterActor *rect; ClutterColor stage_color = { 0xcc, 0xcc, 0xcc, 0xff }; ClutterColor rect_color = { 0xee, 0x55, 0x55, 0x99 }; - ClutterBehaviour *behaviour; + ClutterBehaviour *r_behaviour, *p_behaviour; + const ClutterKnot knots[] = { + { 75, 150 }, + { 400, 150 } + }; g_thread_init (NULL); clutter_threads_init (); - clutter_threads_enter (); - clutter_init (&argc, &argv); stage = clutter_stage_get_default (); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); - clutter_actor_set_size (stage, 800, 600); + clutter_actor_set_size (stage, 600, 200); - count_label = clutter_label_new_with_text ("Mono 16", "Counter"); + count_label = clutter_label_new_with_text ("Mono 12", "Counter"); clutter_actor_set_position (count_label, 350, 50); - clutter_actor_show (count_label); - label = clutter_label_new_with_text ("Mono 16", "Press 's' to start"); - clutter_actor_set_position (label, 50, 50); - clutter_actor_show (label); + help_label = clutter_label_new_with_text ("Mono 12", "Press 's' to start"); + clutter_actor_set_position (help_label, 50, 50); rect = clutter_rectangle_new_with_color (&rect_color); - clutter_actor_set_position (rect, 150, 150); - clutter_actor_set_size (rect, 25, 25); - clutter_actor_show (rect); + clutter_actor_set_position (rect, 75, 150); + clutter_actor_set_size (rect, 50, 50); + clutter_actor_set_anchor_point (rect, 25, 25); clutter_container_add (CLUTTER_CONTAINER (stage), - count_label, label, + count_label, help_label, rect, NULL); timeline = clutter_timeline_new (150, 50); clutter_timeline_set_loop (timeline, TRUE); - behaviour = clutter_behaviour_rotate_new (clutter_alpha_new_full (timeline, + r_behaviour = clutter_behaviour_rotate_new (clutter_alpha_new_full (timeline, + CLUTTER_ALPHA_RAMP_INC, + NULL, NULL), + CLUTTER_Z_AXIS, + CLUTTER_ROTATE_CW, + 0.0, 360.0); + clutter_behaviour_apply (r_behaviour, rect); + + p_behaviour = clutter_behaviour_path_new (clutter_alpha_new_full (timeline, CLUTTER_ALPHA_SINE, NULL, NULL), - CLUTTER_Z_AXIS, - CLUTTER_ROTATE_CW, - 0.0, 360.0); - clutter_behaviour_apply (behaviour, rect); + knots, + G_N_ELEMENTS (knots)); + clutter_behaviour_apply (p_behaviour, rect); g_signal_connect (stage, "button-press-event", G_CALLBACK (clutter_main_quit), @@ -196,10 +216,12 @@ main (int argc, char *argv[]) clutter_actor_show (stage); + clutter_threads_enter (); clutter_main (); clutter_threads_leave (); - g_object_unref (behaviour); + g_object_unref (p_behaviour); + g_object_unref (r_behaviour); g_object_unref (timeline); return EXIT_SUCCESS;