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
input_cb (ClutterActor *stage,
ClutterEvent *event,
gpointer data)
ClutterEvent *event,
gpointer data)
{
SuperOH *oh = data;
if (event->type == CLUTTER_KEY_RELEASE)
{
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)
{
clutter_test_quit ();
clutter_test_quit ();
return TRUE;
}
@ -106,8 +106,8 @@ input_cb (ClutterActor *stage,
/* Timeline handler */
static void
frame_cb (ClutterTimeline *timeline,
gint msecs,
gpointer data)
gint msecs,
gpointer data)
{
SuperOH *oh = data;
gint i;
@ -214,14 +214,14 @@ test_actors_main (int argc, char *argv[])
h = clutter_actor_get_height (oh->hand[i]);
x = oh->stage_width / 2
+ oh->radius
* cos (i * G_PI / (NHANDS / 2))
- w / 2;
+ oh->radius
* cos (i * G_PI / (NHANDS / 2))
- w / 2;
y = oh->stage_height / 2
+ oh->radius
* sin (i * G_PI / (NHANDS / 2))
- h / 2;
+ oh->radius
* sin (i * G_PI / (NHANDS / 2))
- h / 2;
clutter_actor_set_position (oh->hand[i], x, y);
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 */
clutter_actor_show (oh->stage);
g_signal_connect (oh->stage, "key-release-event",
G_CALLBACK (input_cb),
oh);
g_signal_connect (oh->stage, "key-release-event", G_CALLBACK (input_cb), oh);
/* and start it */
clutter_timeline_start (oh->timeline);

View File

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

View File

@ -40,8 +40,8 @@ test_cogl_multitexture_describe (void);
static void
frame_cb (ClutterTimeline *timeline,
gint frame_no,
gpointer data)
int frame_no,
gpointer data)
{
TestMultiLayerPipelineState *state = data;
@ -112,7 +112,7 @@ G_MODULE_EXPORT int
test_cogl_multitexture_main (int argc, char *argv[])
{
GError *error = NULL;
ClutterActor *stage;
ClutterActor *stage;
ClutterColor stage_color = { 0x61, 0x56, 0x56, 0xff };
g_autofree TestMultiLayerPipelineState *state = g_new0 (TestMultiLayerPipelineState, 1);
gfloat stage_w, stage_h;
@ -142,7 +142,7 @@ test_cogl_multitexture_main (int argc, char *argv[])
state->group = clutter_actor_new ();
clutter_actor_set_position (state->group, stage_w / 2, stage_h / 2);
g_signal_connect (state->group, "paint",
G_CALLBACK(material_rectangle_paint), state);
G_CALLBACK (material_rectangle_paint), state);
files = g_new (gchar*, 4);
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 =
cogl_texture_new_from_file (files[0],
COGL_TEXTURE_NO_SLICING,
COGL_PIXEL_FORMAT_ANY,
&error);
COGL_PIXEL_FORMAT_ANY,
&error);
if (!state->alpha_tex)
g_critical ("Failed to load redhand_alpha.png: %s", error->message);
state->redhand_tex =
cogl_texture_new_from_file (files[1],
COGL_TEXTURE_NO_SLICING,
COGL_PIXEL_FORMAT_ANY,
&error);
COGL_PIXEL_FORMAT_ANY,
&error);
if (!state->redhand_tex)
g_critical ("Failed to load redhand.png: %s", error->message);
state->light_tex0 =
cogl_texture_new_from_file (files[2],
COGL_TEXTURE_NO_SLICING,
COGL_PIXEL_FORMAT_ANY,
&error);
COGL_PIXEL_FORMAT_ANY,
&error);
if (!state->light_tex0)
g_critical ("Failed to load light0.png: %s", error->message);
state->light_tex1 =
cogl_texture_new_from_file (files[2],
COGL_TEXTURE_NO_SLICING,
COGL_PIXEL_FORMAT_ANY,
&error);
COGL_PIXEL_FORMAT_ANY,
&error);
if (!state->light_tex1)
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));
clutter_actor_set_translation (data->parent_container, -86.f, -125.f, 0.f);
clutter_container_add_actor (CLUTTER_CONTAINER(stage),
state->group);
clutter_container_add_actor (CLUTTER_CONTAINER(stage), state->group);
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);
priv->texhand_id = cogl_texture_new_from_file (file,
COGL_TEXTURE_NONE,
COGL_PIXEL_FORMAT_ANY,
COGL_PIXEL_FORMAT_ANY,
NULL);
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
* initialized, from a sampler2D in a variable tex.
*/
#define FRAGMENT_SHADER_VARS \
"uniform sampler2D tex;" \
#define FRAGMENT_SHADER_VARS \
"uniform sampler2D tex;" \
"uniform float x_step, y_step;"
#define FRAGMENT_SHADER_BEGIN \
"void main (){" \
#define FRAGMENT_SHADER_BEGIN \
"void main (){" \
" vec4 color = texture2D (tex, vec2(cogl_tex_coord_in[0]));"
/* 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] =
cogl_texture_new_from_file (file,
COGL_TEXTURE_NONE,
COGL_PIXEL_FORMAT_ANY,
COGL_PIXEL_FORMAT_ANY,
NULL);
priv->cogl_tex_id[1] =
cogl_texture_new_from_file (file,
COGL_TEXTURE_NONE,
COGL_PIXEL_FORMAT_BGRA_8888,
COGL_PIXEL_FORMAT_BGRA_8888,
NULL);
priv->cogl_tex_id[2] =
cogl_texture_new_from_file (file,
COGL_TEXTURE_NONE,
COGL_PIXEL_FORMAT_ARGB_8888,
COGL_PIXEL_FORMAT_ARGB_8888,
NULL);
priv->cogl_tex_id[3] =
cogl_texture_new_from_file (file,
COGL_TEXTURE_NONE,
COGL_PIXEL_FORMAT_G_8,
COGL_PIXEL_FORMAT_G_8,
NULL);
g_free (file);

View File

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

View File

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

View File

@ -106,8 +106,8 @@ get_event_state_string (const ClutterEvent *event)
static gboolean
capture_cb (ClutterActor *actor,
ClutterEvent *event,
gpointer data)
ClutterEvent *event,
gpointer data)
{
g_print ("* captured event '%s' for type '%s' *\n",
get_event_type_name (event),
@ -118,7 +118,7 @@ capture_cb (ClutterActor *actor,
static void
key_focus_in_cb (ClutterActor *actor,
gpointer data)
gpointer data)
{
ClutterActor *focus_box = CLUTTER_ACTOR (data);
@ -127,12 +127,12 @@ key_focus_in_cb (ClutterActor *actor,
else
{
clutter_actor_set_position (focus_box,
clutter_actor_get_x (actor) - 5,
clutter_actor_get_y (actor) - 5);
clutter_actor_get_x (actor) - 5,
clutter_actor_get_y (actor) - 5);
clutter_actor_set_size (focus_box,
clutter_actor_get_width (actor) + 10,
clutter_actor_get_height (actor) + 10);
clutter_actor_get_width (actor) + 10,
clutter_actor_get_height (actor) + 10);
clutter_actor_show (focus_box);
}
}
@ -181,8 +181,8 @@ fill_keybuf (char *keybuf, ClutterKeyEvent *event)
static gboolean
input_cb (ClutterActor *actor,
ClutterEvent *event,
gpointer data)
ClutterEvent *event,
gpointer data)
{
ClutterActor *stage = clutter_actor_get_stage (actor);
ClutterActor *source_actor;
@ -271,7 +271,7 @@ input_cb (ClutterActor *actor,
clutter_stage_set_key_focus (CLUTTER_STAGE (stage), NULL);
else if (source_actor == actor &&
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;
case CLUTTER_TOUCH_BEGIN:
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);
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),
focus_box);
focus_box);
g_signal_connect (actor, "captured-event", G_CALLBACK (capture_cb), NULL);
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);
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),
focus_box);
focus_box);
g_signal_connect (stage, "key-focus-in", G_CALLBACK (key_focus_in_cb),
focus_box);
focus_box);
/* non reactive group, with reactive child */
actor = clutter_actor_new ();

View File

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

View File

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