From d21563360a511e3d0434a8e87e23db83d85d8bb2 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Mon, 17 Jan 2022 14:05:06 +0000 Subject: [PATCH] shell: Move weston_curtain_create params into the struct Given that we have a struct for argument params, we might as well use it rather than have them split between the struct and native params. For consistency between the implementations, this also includes a shift from float to int positioning for the base offset within the compositor's global co-ordinate space. Signed-off-by: Daniel Stone --- desktop-shell/shell.c | 5 +++-- kiosk-shell/kiosk-shell.c | 10 ++++++---- shared/shell-utils.c | 13 +++++++------ shared/shell-utils.h | 4 ++-- tests/safe-signal-output-removal-test.c | 5 +++-- 5 files changed, 21 insertions(+), 16 deletions(-) diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c index 3eee0bc6..cf594161 100644 --- a/desktop-shell/shell.c +++ b/desktop-shell/shell.c @@ -2070,12 +2070,13 @@ create_black_surface(struct weston_compositor *ec, { struct weston_curtain_params curtain_params = { .r = 0.0, .g = 0.0, .b = 0.0, + .x = x, .y = y, + .width = w, .height = h, .surface_committed = black_surface_committed, .get_label = black_surface_get_label, .surface_private = fs_view, }; - struct weston_view *view; - view = weston_curtain_create(ec, &curtain_params, x, y, w, h); + struct weston_view *view = weston_curtain_create(ec, &curtain_params); return view; } diff --git a/kiosk-shell/kiosk-shell.c b/kiosk-shell/kiosk-shell.c index 245cde86..2df92a71 100644 --- a/kiosk-shell/kiosk-shell.c +++ b/kiosk-shell/kiosk-shell.c @@ -502,14 +502,16 @@ kiosk_shell_output_recreate_background(struct kiosk_shell_output *shoutput) curtain_params.g = ((bg_color >> 8) & 0xff) / 255.0; curtain_params.b = ((bg_color >> 0) & 0xff) / 255.0; + curtain_params.x = output->x; + curtain_params.y = output->y; + curtain_params.width = output->width; + curtain_params.height = output->height; + curtain_params.get_label = kiosk_shell_background_surface_get_label; curtain_params.surface_committed = NULL; curtain_params.surface_private = NULL; - shoutput->background_view = weston_curtain_create(ec, &curtain_params, - output->x, output->y, - output->width, - output->height); + shoutput->background_view = weston_curtain_create(ec, &curtain_params); weston_surface_set_role(shoutput->background_view->surface, "kiosk-shell-background", NULL, 0); diff --git a/shared/shell-utils.c b/shared/shell-utils.c index b4d93e43..51255a5b 100644 --- a/shared/shell-utils.c +++ b/shared/shell-utils.c @@ -140,8 +140,7 @@ surface_get_label(struct weston_surface *surface, char *buf, size_t len) struct weston_view * weston_curtain_create(struct weston_compositor *compositor, - struct weston_curtain_params *params, - float x, float y, int w, int h) + struct weston_curtain_params *params) { struct weston_surface *surface = NULL; struct weston_view *view; @@ -164,12 +163,14 @@ weston_curtain_create(struct weston_compositor *compositor, weston_surface_set_color(surface, params->r, params->g, params->b, 1.0); weston_surface_set_label_func(surface, params->get_label); pixman_region32_fini(&surface->opaque); - pixman_region32_init_rect(&surface->opaque, 0, 0, w, h); + pixman_region32_init_rect(&surface->opaque, 0, 0, + params->width, params->height); pixman_region32_fini(&surface->input); - pixman_region32_init_rect(&surface->input, 0, 0, w, h); + pixman_region32_init_rect(&surface->input, 0, 0, + params->width, params->height); - weston_surface_set_size(surface, w, h); - weston_view_set_position(view, x, y); + weston_surface_set_size(surface, params->width, params->height); + weston_view_set_position(view, params->x, params->y); return view; } diff --git a/shared/shell-utils.h b/shared/shell-utils.h index 9932957b..f8c508ff 100644 --- a/shared/shell-utils.h +++ b/shared/shell-utils.h @@ -32,6 +32,7 @@ struct weston_curtain_params { void (*surface_committed)(struct weston_surface *es, int32_t sx, int32_t sy); void *surface_private; float r, g, b; + int x, y, width, height; }; struct weston_output * @@ -54,5 +55,4 @@ surface_get_label(struct weston_surface *surface, char *buf, size_t len); */ struct weston_view * weston_curtain_create(struct weston_compositor *compositor, - struct weston_curtain_params *ss, - float x, float y, int w, int h); + struct weston_curtain_params *params); diff --git a/tests/safe-signal-output-removal-test.c b/tests/safe-signal-output-removal-test.c index a9f9dbca..422e91bf 100644 --- a/tests/safe-signal-output-removal-test.c +++ b/tests/safe-signal-output-removal-test.c @@ -81,14 +81,15 @@ output_create_view(struct test_output *t_output) { struct weston_curtain_params curtain_params = { .r = 0.5, .g = 0.5, .b = 0.5, + .x = 0, .y = 0, + .width = 320, .height = 240, .get_label = NULL, .surface_committed = NULL, .surface_private = NULL, }; t_output->view = weston_curtain_create(t_output->compositor, - &curtain_params, - 0, 0, 320, 240); + &curtain_params); weston_view_set_output(t_output->view, t_output->output); /* weston_compositor_remove_output() has to be patched with