tests/interactive: Cleanup tabs

I also sneaked in some code style fixes on the lines that were
touched. Judge me freely, it's all for the greater good.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2355>
This commit is contained in:
Georges Basile Stavracas Neto 2022-03-31 11:24:52 -03:00
parent f25360677f
commit 83e0553534
11 changed files with 117 additions and 118 deletions

View File

@ -70,19 +70,19 @@ on_button_press_event (ClutterActor *actor,
static gboolean static gboolean
input_cb (ClutterActor *stage, input_cb (ClutterActor *stage,
ClutterEvent *event, ClutterEvent *event,
gpointer data) gpointer data)
{ {
SuperOH *oh = data; SuperOH *oh = data;
if (event->type == CLUTTER_KEY_RELEASE) if (event->type == CLUTTER_KEY_RELEASE)
{ {
g_print ("*** key press event (key:%c) ***\n", g_print ("*** key press event (key:%c) ***\n",
clutter_event_get_key_symbol (event)); clutter_event_get_key_symbol (event));
if (clutter_event_get_key_symbol (event) == CLUTTER_KEY_q) if (clutter_event_get_key_symbol (event) == CLUTTER_KEY_q)
{ {
clutter_test_quit (); clutter_test_quit ();
return TRUE; return TRUE;
} }
@ -106,8 +106,8 @@ input_cb (ClutterActor *stage,
/* Timeline handler */ /* Timeline handler */
static void static void
frame_cb (ClutterTimeline *timeline, frame_cb (ClutterTimeline *timeline,
gint msecs, gint msecs,
gpointer data) gpointer data)
{ {
SuperOH *oh = data; SuperOH *oh = data;
gint i; gint i;
@ -214,14 +214,14 @@ test_actors_main (int argc, char *argv[])
h = clutter_actor_get_height (oh->hand[i]); h = clutter_actor_get_height (oh->hand[i]);
x = oh->stage_width / 2 x = oh->stage_width / 2
+ oh->radius + oh->radius
* cos (i * G_PI / (NHANDS / 2)) * cos (i * G_PI / (NHANDS / 2))
- w / 2; - w / 2;
y = oh->stage_height / 2 y = oh->stage_height / 2
+ oh->radius + oh->radius
* sin (i * G_PI / (NHANDS / 2)) * sin (i * G_PI / (NHANDS / 2))
- h / 2; - h / 2;
clutter_actor_set_position (oh->hand[i], x, y); clutter_actor_set_position (oh->hand[i], x, y);
clutter_actor_set_translation (oh->hand[i], -100.f, -106.5, 0); clutter_actor_set_translation (oh->hand[i], -100.f, -106.5, 0);
@ -244,9 +244,7 @@ test_actors_main (int argc, char *argv[])
/* Show everying */ /* Show everying */
clutter_actor_show (oh->stage); clutter_actor_show (oh->stage);
g_signal_connect (oh->stage, "key-release-event", g_signal_connect (oh->stage, "key-release-event", G_CALLBACK (input_cb), oh);
G_CALLBACK (input_cb),
oh);
/* and start it */ /* and start it */
clutter_timeline_start (oh->timeline); clutter_timeline_start (oh->timeline);

View File

@ -6,7 +6,7 @@
#include "tests/clutter-test-utils.h" #include "tests/clutter-test-utils.h"
#ifndef _MSC_VER #ifndef _MSC_VER
#include <unistd.h> /* for sleep(), used for screenshots */ #include <unistd.h> /* for sleep(), used for screenshots */
#endif #endif
#include <stdlib.h> #include <stdlib.h>
#ifdef _MSC_VER #ifdef _MSC_VER
@ -87,11 +87,12 @@ draw_flower (ClutterCanvas *canvas,
cairo_rotate (cr, rand() % 6); cairo_rotate (cr, rand() % 6);
do { do {
idx = (rand() % (sizeof (colors) / sizeof (double) / 3)) * 3; idx = (rand() % (sizeof (colors) / sizeof (double) / 3)) * 3;
} while (idx == last_idx); } while (idx == last_idx);
cairo_set_source_rgba (cr, colors[idx], colors[idx+1], cairo_set_source_rgba (cr,
colors[idx+2], 0.5); colors[idx], colors[idx+1],
colors[idx+2], 0.5);
last_idx = idx; last_idx = idx;
@ -100,25 +101,25 @@ draw_flower (ClutterCanvas *canvas,
pm2 = rand() % 4; pm2 = rand() % 4;
for (j=1; j<n_petals+1; j++) for (j=1; j<n_petals+1; j++)
{ {
cairo_save (cr); cairo_save (cr);
cairo_rotate (cr, ((2*M_PI)/n_petals)*j); cairo_rotate (cr, ((2*M_PI)/n_petals)*j);
/* Petals are made up beziers */ /* Petals are made up beziers */
cairo_new_path (cr); cairo_new_path (cr);
cairo_move_to (cr, 0, 0); cairo_move_to (cr, 0, 0);
cairo_rel_curve_to (cr, cairo_rel_curve_to (cr,
petal_size, petal_size, petal_size, petal_size,
(pm2+2)*petal_size, petal_size, (pm2 + 2) * petal_size, petal_size,
(2*petal_size) + pm1, 0); (2 * petal_size) + pm1, 0);
cairo_rel_curve_to (cr, cairo_rel_curve_to (cr,
0 + (pm2*petal_size), -petal_size, 0 + (pm2 * petal_size), -petal_size,
-petal_size, -petal_size, -petal_size, -petal_size,
-((2*petal_size) + pm1), 0); -((2 * petal_size) + pm1), 0);
cairo_close_path (cr); cairo_close_path (cr);
cairo_fill (cr); cairo_fill (cr);
cairo_restore (cr); cairo_restore (cr);
} }
petal_size -= rand() % (size/8); petal_size -= rand() % (size/8);
@ -183,7 +184,7 @@ tick (ClutterTimeline *timeline,
flowers[i]->y = -clutter_actor_get_height (flowers[i]->ctex); flowers[i]->y = -clutter_actor_get_height (flowers[i]->ctex);
clutter_actor_set_position (flowers[i]->ctex, clutter_actor_set_position (flowers[i]->ctex,
flowers[i]->x, flowers[i]->y); flowers[i]->x, flowers[i]->y);
clutter_actor_set_rotation_angle (flowers[i]->ctex, clutter_actor_set_rotation_angle (flowers[i]->ctex,
CLUTTER_Z_AXIS, CLUTTER_Z_AXIS,
@ -233,7 +234,8 @@ test_cairo_flowers_main (int argc, char **argv)
clutter_container_add_actor (CLUTTER_CONTAINER (stage), clutter_container_add_actor (CLUTTER_CONTAINER (stage),
flowers[i]->ctex); flowers[i]->ctex);
clutter_actor_set_position (flowers[i]->ctex, clutter_actor_set_position (flowers[i]->ctex,
flowers[i]->x, flowers[i]->y); flowers[i]->x,
flowers[i]->y);
} }
/* fire a callback for frame change */ /* fire a callback for frame change */
@ -244,8 +246,8 @@ test_cairo_flowers_main (int argc, char **argv)
clutter_timeline_start (timeline); clutter_timeline_start (timeline);
g_signal_connect (stage, "key-press-event", g_signal_connect (stage, "key-press-event",
G_CALLBACK (clutter_test_quit), G_CALLBACK (clutter_test_quit),
NULL); NULL);
clutter_test_main (); clutter_test_main ();

View File

@ -40,8 +40,8 @@ test_cogl_multitexture_describe (void);
static void static void
frame_cb (ClutterTimeline *timeline, frame_cb (ClutterTimeline *timeline,
gint frame_no, int frame_no,
gpointer data) gpointer data)
{ {
TestMultiLayerPipelineState *state = data; TestMultiLayerPipelineState *state = data;
@ -112,7 +112,7 @@ G_MODULE_EXPORT int
test_cogl_multitexture_main (int argc, char *argv[]) test_cogl_multitexture_main (int argc, char *argv[])
{ {
GError *error = NULL; GError *error = NULL;
ClutterActor *stage; ClutterActor *stage;
ClutterColor stage_color = { 0x61, 0x56, 0x56, 0xff }; ClutterColor stage_color = { 0x61, 0x56, 0x56, 0xff };
g_autofree TestMultiLayerPipelineState *state = g_new0 (TestMultiLayerPipelineState, 1); g_autofree TestMultiLayerPipelineState *state = g_new0 (TestMultiLayerPipelineState, 1);
gfloat stage_w, stage_h; gfloat stage_w, stage_h;
@ -142,7 +142,7 @@ test_cogl_multitexture_main (int argc, char *argv[])
state->group = clutter_actor_new (); state->group = clutter_actor_new ();
clutter_actor_set_position (state->group, stage_w / 2, stage_h / 2); clutter_actor_set_position (state->group, stage_w / 2, stage_h / 2);
g_signal_connect (state->group, "paint", g_signal_connect (state->group, "paint",
G_CALLBACK(material_rectangle_paint), state); G_CALLBACK (material_rectangle_paint), state);
files = g_new (gchar*, 4); files = g_new (gchar*, 4);
files[0] = g_build_filename (TESTS_DATADIR, "redhand_alpha.png", NULL); files[0] = g_build_filename (TESTS_DATADIR, "redhand_alpha.png", NULL);
@ -153,32 +153,32 @@ test_cogl_multitexture_main (int argc, char *argv[])
state->alpha_tex = state->alpha_tex =
cogl_texture_new_from_file (files[0], cogl_texture_new_from_file (files[0],
COGL_TEXTURE_NO_SLICING, COGL_TEXTURE_NO_SLICING,
COGL_PIXEL_FORMAT_ANY, COGL_PIXEL_FORMAT_ANY,
&error); &error);
if (!state->alpha_tex) if (!state->alpha_tex)
g_critical ("Failed to load redhand_alpha.png: %s", error->message); g_critical ("Failed to load redhand_alpha.png: %s", error->message);
state->redhand_tex = state->redhand_tex =
cogl_texture_new_from_file (files[1], cogl_texture_new_from_file (files[1],
COGL_TEXTURE_NO_SLICING, COGL_TEXTURE_NO_SLICING,
COGL_PIXEL_FORMAT_ANY, COGL_PIXEL_FORMAT_ANY,
&error); &error);
if (!state->redhand_tex) if (!state->redhand_tex)
g_critical ("Failed to load redhand.png: %s", error->message); g_critical ("Failed to load redhand.png: %s", error->message);
state->light_tex0 = state->light_tex0 =
cogl_texture_new_from_file (files[2], cogl_texture_new_from_file (files[2],
COGL_TEXTURE_NO_SLICING, COGL_TEXTURE_NO_SLICING,
COGL_PIXEL_FORMAT_ANY, COGL_PIXEL_FORMAT_ANY,
&error); &error);
if (!state->light_tex0) if (!state->light_tex0)
g_critical ("Failed to load light0.png: %s", error->message); g_critical ("Failed to load light0.png: %s", error->message);
state->light_tex1 = state->light_tex1 =
cogl_texture_new_from_file (files[2], cogl_texture_new_from_file (files[2],
COGL_TEXTURE_NO_SLICING, COGL_TEXTURE_NO_SLICING,
COGL_PIXEL_FORMAT_ANY, COGL_PIXEL_FORMAT_ANY,
&error); &error);
if (!state->light_tex1) if (!state->light_tex1)
g_critical ("Failed to load light0.png: %s", error->message); g_critical ("Failed to load light0.png: %s", error->message);
@ -214,8 +214,7 @@ test_cogl_multitexture_main (int argc, char *argv[])
&GRAPHENE_POINT3D_INIT (0.5, 0.5, 0)); &GRAPHENE_POINT3D_INIT (0.5, 0.5, 0));
clutter_actor_set_translation (data->parent_container, -86.f, -125.f, 0.f); clutter_actor_set_translation (data->parent_container, -86.f, -125.f, 0.f);
clutter_container_add_actor (CLUTTER_CONTAINER(stage), clutter_container_add_actor (CLUTTER_CONTAINER(stage), state->group);
state->group);
state->timeline = clutter_timeline_new_for_actor (stage, 2812); state->timeline = clutter_timeline_new_for_actor (stage, 2812);

View File

@ -291,7 +291,7 @@ test_coglbox_init (TestCoglbox *self)
file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL); file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL);
priv->texhand_id = cogl_texture_new_from_file (file, priv->texhand_id = cogl_texture_new_from_file (file,
COGL_TEXTURE_NONE, COGL_TEXTURE_NONE,
COGL_PIXEL_FORMAT_ANY, COGL_PIXEL_FORMAT_ANY,
NULL); NULL);
g_free (file); g_free (file);

View File

@ -23,12 +23,12 @@ test_cogl_shader_glsl_main (int argc, char *argv[]);
/* FRAGMENT_SHADER_BEGIN: generate boilerplate with a local vec4 color already /* FRAGMENT_SHADER_BEGIN: generate boilerplate with a local vec4 color already
* initialized, from a sampler2D in a variable tex. * initialized, from a sampler2D in a variable tex.
*/ */
#define FRAGMENT_SHADER_VARS \ #define FRAGMENT_SHADER_VARS \
"uniform sampler2D tex;" \ "uniform sampler2D tex;" \
"uniform float x_step, y_step;" "uniform float x_step, y_step;"
#define FRAGMENT_SHADER_BEGIN \ #define FRAGMENT_SHADER_BEGIN \
"void main (){" \ "void main (){" \
" vec4 color = texture2D (tex, vec2(cogl_tex_coord_in[0]));" " vec4 color = texture2D (tex, vec2(cogl_tex_coord_in[0]));"
/* FRAGMENT_SHADER_END: apply the changed color to the output buffer correctly /* FRAGMENT_SHADER_END: apply the changed color to the output buffer correctly

View File

@ -172,25 +172,25 @@ test_coglbox_init (TestCoglbox *self)
priv->cogl_tex_id[0] = priv->cogl_tex_id[0] =
cogl_texture_new_from_file (file, cogl_texture_new_from_file (file,
COGL_TEXTURE_NONE, COGL_TEXTURE_NONE,
COGL_PIXEL_FORMAT_ANY, COGL_PIXEL_FORMAT_ANY,
NULL); NULL);
priv->cogl_tex_id[1] = priv->cogl_tex_id[1] =
cogl_texture_new_from_file (file, cogl_texture_new_from_file (file,
COGL_TEXTURE_NONE, COGL_TEXTURE_NONE,
COGL_PIXEL_FORMAT_BGRA_8888, COGL_PIXEL_FORMAT_BGRA_8888,
NULL); NULL);
priv->cogl_tex_id[2] = priv->cogl_tex_id[2] =
cogl_texture_new_from_file (file, cogl_texture_new_from_file (file,
COGL_TEXTURE_NONE, COGL_TEXTURE_NONE,
COGL_PIXEL_FORMAT_ARGB_8888, COGL_PIXEL_FORMAT_ARGB_8888,
NULL); NULL);
priv->cogl_tex_id[3] = priv->cogl_tex_id[3] =
cogl_texture_new_from_file (file, cogl_texture_new_from_file (file,
COGL_TEXTURE_NONE, COGL_TEXTURE_NONE,
COGL_PIXEL_FORMAT_G_8, COGL_PIXEL_FORMAT_G_8,
NULL); NULL);
g_free (file); g_free (file);

View File

@ -227,9 +227,9 @@ test_coglbox_paint (ClutterActor *self,
0, 0, 1, 1); 0, 0, 1, 1);
test_coglbox_fade_texture (framebuffer, pipeline, test_coglbox_fade_texture (framebuffer, pipeline,
0, tex_height, 0, tex_height,
tex_width, (tex_height * 3 / 2), tex_width, (tex_height * 3 / 2),
0.0, 1.0, 0.0, 1.0,
1.0, 0.5); 1.0, 0.5);
cogl_framebuffer_pop_matrix (framebuffer); cogl_framebuffer_pop_matrix (framebuffer);
@ -241,16 +241,16 @@ test_coglbox_paint (ClutterActor *self,
/* Draw the texture split into two triangles */ /* Draw the texture split into two triangles */
test_coglbox_triangle_texture (framebuffer, pipeline, test_coglbox_triangle_texture (framebuffer, pipeline,
tex_width, tex_height, tex_width, tex_height,
0, 0, 0, 0,
0, 0, 0, 0,
0, 1, 0, 1,
1, 1); 1, 1);
test_coglbox_triangle_texture (framebuffer, pipeline, test_coglbox_triangle_texture (framebuffer, pipeline,
tex_width, tex_height, tex_width, tex_height,
20, 0, 20, 0,
0, 0, 0, 0,
1, 0, 1, 0,
1, 1); 1, 1);
cogl_framebuffer_pop_matrix (framebuffer); cogl_framebuffer_pop_matrix (framebuffer);
@ -343,8 +343,8 @@ test_coglbox_new (void)
static void static void
frame_cb (ClutterTimeline *timeline, frame_cb (ClutterTimeline *timeline,
gint elapsed_msecs, int elapsed_msecs,
gpointer data) gpointer data)
{ {
TestCoglboxPrivate *priv = TEST_COGLBOX_GET_PRIVATE (data); TestCoglboxPrivate *priv = TEST_COGLBOX_GET_PRIVATE (data);
gdouble progress = clutter_timeline_get_progress (timeline); gdouble progress = clutter_timeline_get_progress (timeline);
@ -361,7 +361,7 @@ update_toggle_text (ClutterText *button, gboolean val)
static gboolean static gboolean
on_toggle_click (ClutterActor *button, ClutterEvent *event, on_toggle_click (ClutterActor *button, ClutterEvent *event,
gboolean *toggle_val) gboolean *toggle_val)
{ {
update_toggle_text (CLUTTER_TEXT (button), *toggle_val = !*toggle_val); update_toggle_text (CLUTTER_TEXT (button), *toggle_val = !*toggle_val);
@ -383,7 +383,7 @@ make_toggle (const char *label_text, gboolean *toggle_val)
clutter_container_add (CLUTTER_CONTAINER (group), label, button, NULL); clutter_container_add (CLUTTER_CONTAINER (group), label, button, NULL);
g_signal_connect (button, "button-press-event", G_CALLBACK (on_toggle_click), g_signal_connect (button, "button-press-event", G_CALLBACK (on_toggle_click),
toggle_val); toggle_val);
return group; return group;
} }
@ -420,29 +420,29 @@ test_cogl_tex_polygon_main (int argc, char *argv[])
/* Labels for toggling settings */ /* Labels for toggling settings */
slicing_toggle = make_toggle ("Texture slicing: ", slicing_toggle = make_toggle ("Texture slicing: ",
&(TEST_COGLBOX_GET_PRIVATE (coglbox) &(TEST_COGLBOX_GET_PRIVATE (coglbox)
->use_sliced)); ->use_sliced));
clutter_actor_set_position (slicing_toggle, 0, clutter_actor_set_position (slicing_toggle, 0,
clutter_actor_get_height (stage) clutter_actor_get_height (stage)
- clutter_actor_get_height (slicing_toggle)); - clutter_actor_get_height (slicing_toggle));
filtering_toggle = make_toggle ("Linear filtering: ", filtering_toggle = make_toggle ("Linear filtering: ",
&(TEST_COGLBOX_GET_PRIVATE (coglbox) &(TEST_COGLBOX_GET_PRIVATE (coglbox)
->use_linear_filtering)); ->use_linear_filtering));
clutter_actor_set_position (filtering_toggle, 0, clutter_actor_set_position (filtering_toggle, 0,
clutter_actor_get_y (slicing_toggle) clutter_actor_get_y (slicing_toggle)
- clutter_actor_get_height (filtering_toggle)); - clutter_actor_get_height (filtering_toggle));
note = clutter_text_new_with_text ("Sans 10", "<- Click to change"); note = clutter_text_new_with_text ("Sans 10", "<- Click to change");
clutter_actor_set_position (note, clutter_actor_set_position (note,
clutter_actor_get_width (filtering_toggle) + 10, clutter_actor_get_width (filtering_toggle) + 10,
(clutter_actor_get_height (stage) (clutter_actor_get_height (stage)
+ clutter_actor_get_y (filtering_toggle)) / 2 + clutter_actor_get_y (filtering_toggle)) / 2
- clutter_actor_get_height (note) / 2); - clutter_actor_get_height (note) / 2);
clutter_container_add (CLUTTER_CONTAINER (stage), clutter_container_add (CLUTTER_CONTAINER (stage),
slicing_toggle, slicing_toggle,
filtering_toggle, filtering_toggle,
note, note,
NULL); NULL);
clutter_actor_show (stage); clutter_actor_show (stage);

View File

@ -187,8 +187,8 @@ test_coglbox_new (void)
static void static void
frame_cb (ClutterTimeline *timeline, frame_cb (ClutterTimeline *timeline,
gint msecs, int msecs,
gpointer data) gpointer data)
{ {
TestCoglboxPrivate *priv = TEST_COGLBOX_GET_PRIVATE (data); TestCoglboxPrivate *priv = TEST_COGLBOX_GET_PRIVATE (data);

View File

@ -106,8 +106,8 @@ get_event_state_string (const ClutterEvent *event)
static gboolean static gboolean
capture_cb (ClutterActor *actor, capture_cb (ClutterActor *actor,
ClutterEvent *event, ClutterEvent *event,
gpointer data) gpointer data)
{ {
g_print ("* captured event '%s' for type '%s' *\n", g_print ("* captured event '%s' for type '%s' *\n",
get_event_type_name (event), get_event_type_name (event),
@ -118,7 +118,7 @@ capture_cb (ClutterActor *actor,
static void static void
key_focus_in_cb (ClutterActor *actor, key_focus_in_cb (ClutterActor *actor,
gpointer data) gpointer data)
{ {
ClutterActor *focus_box = CLUTTER_ACTOR (data); ClutterActor *focus_box = CLUTTER_ACTOR (data);
@ -127,12 +127,12 @@ key_focus_in_cb (ClutterActor *actor,
else else
{ {
clutter_actor_set_position (focus_box, clutter_actor_set_position (focus_box,
clutter_actor_get_x (actor) - 5, clutter_actor_get_x (actor) - 5,
clutter_actor_get_y (actor) - 5); clutter_actor_get_y (actor) - 5);
clutter_actor_set_size (focus_box, clutter_actor_set_size (focus_box,
clutter_actor_get_width (actor) + 10, clutter_actor_get_width (actor) + 10,
clutter_actor_get_height (actor) + 10); clutter_actor_get_height (actor) + 10);
clutter_actor_show (focus_box); clutter_actor_show (focus_box);
} }
} }
@ -181,8 +181,8 @@ fill_keybuf (char *keybuf, ClutterKeyEvent *event)
static gboolean static gboolean
input_cb (ClutterActor *actor, input_cb (ClutterActor *actor,
ClutterEvent *event, ClutterEvent *event,
gpointer data) gpointer data)
{ {
ClutterActor *stage = clutter_actor_get_stage (actor); ClutterActor *stage = clutter_actor_get_stage (actor);
ClutterActor *source_actor; ClutterActor *source_actor;
@ -271,7 +271,7 @@ input_cb (ClutterActor *actor,
clutter_stage_set_key_focus (CLUTTER_STAGE (stage), NULL); clutter_stage_set_key_focus (CLUTTER_STAGE (stage), NULL);
else if (source_actor == actor && else if (source_actor == actor &&
clutter_actor_get_parent (actor) == stage) clutter_actor_get_parent (actor) == stage)
clutter_stage_set_key_focus (CLUTTER_STAGE (stage), actor); clutter_stage_set_key_focus (CLUTTER_STAGE (stage), actor);
break; break;
case CLUTTER_TOUCH_BEGIN: case CLUTTER_TOUCH_BEGIN:
clutter_event_get_position (event, &position); clutter_event_get_position (event, &position);
@ -395,7 +395,7 @@ test_events_main (int argc, char *argv[])
clutter_container_add (CLUTTER_CONTAINER (stage), actor, NULL); clutter_container_add (CLUTTER_CONTAINER (stage), actor, NULL);
g_signal_connect (actor, "event", G_CALLBACK (input_cb), (char *) "green box"); g_signal_connect (actor, "event", G_CALLBACK (input_cb), (char *) "green box");
g_signal_connect (actor, "key-focus-in", G_CALLBACK (key_focus_in_cb), g_signal_connect (actor, "key-focus-in", G_CALLBACK (key_focus_in_cb),
focus_box); focus_box);
g_signal_connect (actor, "captured-event", G_CALLBACK (capture_cb), NULL); g_signal_connect (actor, "captured-event", G_CALLBACK (capture_cb), NULL);
clutter_stage_set_key_focus (CLUTTER_STAGE (stage), actor); clutter_stage_set_key_focus (CLUTTER_STAGE (stage), actor);
@ -409,9 +409,9 @@ test_events_main (int argc, char *argv[])
clutter_container_add (CLUTTER_CONTAINER(stage), actor, NULL); clutter_container_add (CLUTTER_CONTAINER(stage), actor, NULL);
g_signal_connect (actor, "event", G_CALLBACK (input_cb), (char *) "blue box"); g_signal_connect (actor, "event", G_CALLBACK (input_cb), (char *) "blue box");
g_signal_connect (actor, "key-focus-in", G_CALLBACK (key_focus_in_cb), g_signal_connect (actor, "key-focus-in", G_CALLBACK (key_focus_in_cb),
focus_box); focus_box);
g_signal_connect (stage, "key-focus-in", G_CALLBACK (key_focus_in_cb), g_signal_connect (stage, "key-focus-in", G_CALLBACK (key_focus_in_cb),
focus_box); focus_box);
/* non reactive group, with reactive child */ /* non reactive group, with reactive child */
actor = clutter_actor_new (); actor = clutter_actor_new ();

View File

@ -22,13 +22,13 @@ debug_event_cb (ClutterActor *actor,
{ {
case CLUTTER_KEY_PRESS: case CLUTTER_KEY_PRESS:
len = g_unichar_to_utf8 (clutter_keysym_to_unicode (event->key.keyval), len = g_unichar_to_utf8 (clutter_keysym_to_unicode (event->key.keyval),
keybuf); keybuf);
keybuf[len] = '\0'; keybuf[len] = '\0';
printf ("[%s] KEY PRESS '%s'", source, keybuf); printf ("[%s] KEY PRESS '%s'", source, keybuf);
break; break;
case CLUTTER_KEY_RELEASE: case CLUTTER_KEY_RELEASE:
len = g_unichar_to_utf8 (clutter_keysym_to_unicode (event->key.keyval), len = g_unichar_to_utf8 (clutter_keysym_to_unicode (event->key.keyval),
keybuf); keybuf);
keybuf[len] = '\0'; keybuf[len] = '\0';
printf ("[%s] KEY RELEASE '%s'", source, keybuf); printf ("[%s] KEY RELEASE '%s'", source, keybuf);
break; break;
@ -199,8 +199,8 @@ test_grab_main (int argc, char *argv[])
ClutterActor *stage, *actor; ClutterActor *stage, *actor;
ClutterColor rcol = { 0xff, 0, 0, 0xff}, ClutterColor rcol = { 0xff, 0, 0, 0xff},
bcol = { 0, 0, 0xff, 0xff }, bcol = { 0, 0, 0xff, 0xff },
ccol = { 0, 0xff, 0xff, 0xff }, ccol = { 0, 0xff, 0xff, 0xff },
ycol = { 0xff, 0xff, 0, 0xff }; ycol = { 0xff, 0xff, 0, 0xff };
clutter_test_init (&argc, &argv); clutter_test_init (&argc, &argv);

View File

@ -492,8 +492,8 @@ create_item (void)
static gboolean static gboolean
keypress_cb (ClutterActor *actor, keypress_cb (ClutterActor *actor,
ClutterEvent *event, ClutterEvent *event,
gpointer data) gpointer data)
{ {
switch (clutter_event_get_key_symbol (event)) switch (clutter_event_get_key_symbol (event))
{ {
@ -663,8 +663,8 @@ test_layout_main (int argc, char *argv[])
clutter_actor_add_child (stage, instructions); clutter_actor_add_child (stage, instructions);
g_signal_connect (stage, "key-release-event", g_signal_connect (stage, "key-release-event",
G_CALLBACK (keypress_cb), G_CALLBACK (keypress_cb),
NULL); NULL);
clutter_timeline_stop (main_timeline); clutter_timeline_stop (main_timeline);