From 73aaf14ebe9157baf825a02525c850606b66d202 Mon Sep 17 00:00:00 2001 From: Marius Vlad Date: Fri, 26 Mar 2021 15:55:05 +0200 Subject: kiosk-shell: Read background-color from ini file desktop-shell's client is able to read-up from the config file, [shell] section the background, but for kiosk-shell we don't actually have client that does that, so instead allow the shell do that directly. Seems to be a useful thing to have, as a default background color. Signed-off-by: Marius Vlad --- kiosk-shell/kiosk-shell.c | 19 ++++++++++++++++++- kiosk-shell/kiosk-shell.h | 2 ++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/kiosk-shell/kiosk-shell.c b/kiosk-shell/kiosk-shell.c index d08167e2..8f0f49ec 100644 --- a/kiosk-shell/kiosk-shell.c +++ b/kiosk-shell/kiosk-shell.c @@ -458,6 +458,9 @@ kiosk_shell_output_recreate_background(struct kiosk_shell_output *shoutput) { struct kiosk_shell *shell = shoutput->shell; struct weston_output *output = shoutput->output; + struct weston_config_section *shell_section = NULL; + uint32_t bg_color = 0x0; + float r, g, b; if (shoutput->background_view) weston_surface_destroy(shoutput->background_view->surface); @@ -465,9 +468,19 @@ kiosk_shell_output_recreate_background(struct kiosk_shell_output *shoutput) if (!output) return; + if (shell->config) + shell_section = weston_config_get_section(shell->config, "shell", NULL, NULL); + if (shell_section) + weston_config_section_get_color(shell_section, "background-color", + &bg_color, 0x00000000); + + r = ((bg_color >> 16) & 0xff) / 255.0; + b = ((bg_color >> 8) & 0xff) / 255.0, + g = ((bg_color >> 0) & 0xff) / 255.0; + shoutput->background_view = create_colored_surface(shoutput->shell->compositor, - 0.5, 0.5, 0.5, + r, g, b, output->x, output->y, output->width, output->height); @@ -1068,6 +1081,7 @@ wet_shell_init(struct weston_compositor *ec, struct kiosk_shell *shell; struct weston_seat *seat; struct weston_output *output; + const char *config_file; shell = zalloc(sizeof *shell); if (shell == NULL) @@ -1085,6 +1099,9 @@ wet_shell_init(struct weston_compositor *ec, shell->transform_listener.notify = transform_handler; wl_signal_add(&ec->transform_signal, &shell->transform_listener); + config_file = weston_config_get_name_from_env(); + shell->config = weston_config_parse(config_file); + weston_layer_init(&shell->background_layer, ec); weston_layer_init(&shell->normal_layer, ec); diff --git a/kiosk-shell/kiosk-shell.h b/kiosk-shell/kiosk-shell.h index 79c85f4f..a88c5317 100644 --- a/kiosk-shell/kiosk-shell.h +++ b/kiosk-shell/kiosk-shell.h @@ -26,6 +26,7 @@ #include #include +#include struct kiosk_shell { struct weston_compositor *compositor; @@ -45,6 +46,7 @@ struct kiosk_shell { struct wl_list seat_list; const struct weston_xwayland_surface_api *xwayland_surface_api; + struct weston_config *config; }; struct kiosk_shell_surface { -- cgit v1.2.1