From 55bf79c3fe49d630865494b8e782e1646d732b63 Mon Sep 17 00:00:00 2001 From: Johan Malm Date: Thu, 29 Jun 2023 21:29:43 +0100 Subject: [PATCH] theme: add option osd.window-switcher.padding Fixes: issue #969 --- docs/labwc-theme.5.scd | 7 ++++++- docs/themerc | 1 + include/theme.h | 1 + src/osd.c | 14 +++++++++----- src/theme.c | 7 +++++++ 5 files changed, 24 insertions(+), 6 deletions(-) diff --git a/docs/labwc-theme.5.scd b/docs/labwc-theme.5.scd index 2a530f35..6142f085 100644 --- a/docs/labwc-theme.5.scd +++ b/docs/labwc-theme.5.scd @@ -141,7 +141,7 @@ elements are not listed here, but are supported. Border color of on-screen-display *osd.border.width* - Border width of on-screen-display + Border width of on-screen-display. Inherits *border.width* if not set. *osd.label.text.color* Text color of on-screen-display @@ -149,6 +149,11 @@ elements are not listed here, but are supported. *osd.window-switcher.width* Width of window switcher in pixels. Default is 600. +*osd.window-switcher.padding* + Padding of window switcher in pixels. This is the space between the + window-switcher border and its items. Inherits *osd.border.width* if + not set. + *osd.window-switcher.item.padding.x* Horizontal padding of window switcher entries in pixels. Default is 10. diff --git a/docs/themerc b/docs/themerc index 0ad6e3db..03bb3216 100644 --- a/docs/themerc +++ b/docs/themerc @@ -54,5 +54,6 @@ osd.border.width: 1 osd.label.text.color: #000000 osd.window-switcher.width: 600 +osd.window-switcher.padding: 1 osd.window-switcher.item.padding.x: 10 osd.window-switcher.item.padding.y: 6 diff --git a/include/theme.h b/include/theme.h index 4183cfd5..df6fbab2 100644 --- a/include/theme.h +++ b/include/theme.h @@ -68,6 +68,7 @@ struct theme { float osd_label_text_color[4]; int osd_window_switcher_width; + int osd_window_switcher_padding; int osd_window_switcher_item_padding_x; int osd_window_switcher_item_padding_y; diff --git a/src/osd.c b/src/osd.c index 29f126a7..f95d8031 100644 --- a/src/osd.c +++ b/src/osd.c @@ -78,6 +78,7 @@ get_osd_height(struct wl_list *node_list) /* Add OSD border width */ height += 2 * rc.theme->osd_border_width; + height += 2 * rc.theme->osd_window_switcher_padding; return height; } @@ -316,7 +317,7 @@ render_osd(struct server *server, cairo_t *cairo, int w, int h, pango_cairo_update_layout(cairo, layout); - int y = theme->osd_border_width; + int y = theme->osd_border_width + theme->osd_window_switcher_padding; /* Draw workspace indicator */ if (show_workspace) { @@ -342,7 +343,8 @@ render_osd(struct server *server, cairo_t *cairo, int w, int h, * Subtract 4x border-width to allow for both the OSD border and the * item border. This is the width of the area available for text fields. */ - int available_width = w - 4 * theme->osd_border_width; + int available_width = w - 4 * theme->osd_border_width + - 2 * theme->osd_window_switcher_padding; /* Draw text for each node */ wl_list_for_each_reverse(node, node_list, link) { @@ -374,7 +376,8 @@ render_osd(struct server *server, cairo_t *cairo, int w, int h, */ y += theme->osd_border_width; int x = theme->osd_window_switcher_item_padding_x - + 2 * theme->osd_border_width; + + 2 * theme->osd_border_width + + theme->osd_window_switcher_padding; int nr_fields = wl_list_length(&rc.window_switcher.fields); struct window_switcher_field *field; @@ -408,10 +411,11 @@ render_osd(struct server *server, cairo_t *cairo, int w, int h, if (view == cycle_view) { /* Highlight current window */ struct wlr_fbox fbox = { - .x = theme->osd_border_width, + .x = theme->osd_border_width + theme->osd_window_switcher_padding, .y = y - theme->osd_border_width, .width = theme->osd_window_switcher_width - - 2 * theme->osd_border_width, + - 2 * theme->osd_border_width + - 2 * theme->osd_window_switcher_padding, .height = theme->osd_window_switcher_item_height + 2 * theme->osd_border_width, }; diff --git a/src/theme.c b/src/theme.c index d1aed200..03d54a9e 100644 --- a/src/theme.c +++ b/src/theme.c @@ -141,6 +141,7 @@ theme_builtin(struct theme *theme) parse_hexstr("#888888", theme->menu_separator_color); theme->osd_window_switcher_width = 600; + theme->osd_window_switcher_padding = INT_MIN; theme->osd_window_switcher_item_padding_x = 10; theme->osd_window_switcher_item_padding_y = 6; @@ -311,6 +312,9 @@ entry(struct theme *theme, const char *key, const char *value) if (match_glob(key, "osd.window-switcher.width")) { theme->osd_window_switcher_width = atoi(value); } + if (match_glob(key, "osd.window-switcher.padding")) { + theme->osd_window_switcher_padding = atoi(value); + } if (match_glob(key, "osd.window-switcher.item.padding.x")) { theme->osd_window_switcher_item_padding_x = atoi(value); } @@ -554,6 +558,9 @@ post_processing(struct theme *theme) if (theme->osd_border_width == INT_MIN) { theme->osd_border_width = theme->border_width; } + if (theme->osd_window_switcher_padding == INT_MIN) { + theme->osd_window_switcher_padding = theme->osd_border_width; + } if (theme->osd_label_text_color[0] == FLT_MIN) { memcpy(theme->osd_label_text_color, theme->window_active_label_text_color,