diff --git a/docs/labwc-theme.5.scd b/docs/labwc-theme.5.scd index efc3a1a5..fad8a77e 100644 --- a/docs/labwc-theme.5.scd +++ b/docs/labwc-theme.5.scd @@ -358,10 +358,12 @@ all are supported. Border width of selected window switcher items in pixels. Default is 2. *osd.window-switcher.style-thumbnail.item.active.border.color* - Color of border around selected window switcher items. Default is #589bda. + Color of border around selected window switcher items. + Default is *osd.label.text.color* with 50% opacity. *osd.window-switcher.style-thumbnail.item.active.bg.color* - Color of selected window switcher items. Default is #c7e2fc. + Color of selected window switcher items. + Default is *osd.label.text.color* with 15% opacity. *osd.window-switcher.style-thumbnail.item.icon.size* Size of window icons in window switcher items in pixels. Default is 60. diff --git a/docs/themerc b/docs/themerc index 7b251a3c..a52dfacd 100644 --- a/docs/themerc +++ b/docs/themerc @@ -106,8 +106,8 @@ osd.window-switcher.style-thumbnail.item.width: 300 osd.window-switcher.style-thumbnail.item.height: 250 osd.window-switcher.style-thumbnail.item.padding: 10 osd.window-switcher.style-thumbnail.item.active.border.width: 2 -osd.window-switcher.style-thumbnail.item.active.border.color: #589bda -osd.window-switcher.style-thumbnail.item.active.bg.color: #c7e2fc +osd.window-switcher.style-thumbnail.item.active.border.color: #706f6d +osd.window-switcher.style-thumbnail.item.active.bg.color: #bfbcba osd.window-switcher.style-thumbnail.item.icon.size: 60 osd.window-switcher.preview.border.width: 1 diff --git a/src/theme.c b/src/theme.c index d5279367..a3aec34a 100644 --- a/src/theme.c +++ b/src/theme.c @@ -613,8 +613,8 @@ theme_builtin(struct theme *theme, struct server *server) theme->osd_window_switcher_thumbnail.item_height = 250; theme->osd_window_switcher_thumbnail.item_padding = 10; theme->osd_window_switcher_thumbnail.item_active_border_width = 2; - parse_color("#589bda", theme->osd_window_switcher_thumbnail.item_active_border_color); - parse_color("#c7e2fc", theme->osd_window_switcher_thumbnail.item_active_bg_color); + theme->osd_window_switcher_thumbnail.item_active_border_color[0] = FLT_MIN; + theme->osd_window_switcher_thumbnail.item_active_bg_color[0] = FLT_MIN; theme->osd_window_switcher_thumbnail.item_icon_size = 60; /* inherit settings in post_processing() if not set elsewhere */ @@ -1633,6 +1633,31 @@ get_titlebar_height(struct theme *theme) return h; } +/* Blend foreground color (with new alpha) with background color */ +static void +blend_color_with_bg(float *dst, float *fg, float fg_a, float *bg) +{ + /* Guard against zero division */ + if (fg[3] <= 0.0f) { + memset(dst, 0, sizeof(float) * 4); + return; + } + + /* Redo premultiplication to update foreground alpha */ + float new_fg[4] = { + fg[0] / fg[3] * fg_a, + fg[1] / fg[3] * fg_a, + fg[2] / fg[3] * fg_a, + fg_a, + }; + + /* Blend colors */ + dst[0] = new_fg[0] + bg[0] * (1.0f - new_fg[3]); + dst[1] = new_fg[1] + bg[1] * (1.0f - new_fg[3]); + dst[2] = new_fg[2] + bg[2] * (1.0f - new_fg[3]); + dst[3] = new_fg[3] + bg[3] * (1.0f - new_fg[3]); +} + static void post_processing(struct theme *theme) { @@ -1721,6 +1746,14 @@ post_processing(struct theme *theme) memcpy(theme->osd_border_color, theme->osd_label_text_color, sizeof(theme->osd_border_color)); } + if (switcher_thumb_theme->item_active_border_color[0] == FLT_MIN) { + blend_color_with_bg(switcher_thumb_theme->item_active_border_color, + theme->osd_label_text_color, 0.50, theme->osd_bg_color); + } + if (switcher_thumb_theme->item_active_bg_color[0] == FLT_MIN) { + blend_color_with_bg(switcher_thumb_theme->item_active_bg_color, + theme->osd_label_text_color, 0.15, theme->osd_bg_color); + } if (theme->osd_workspace_switcher_boxes_width == 0) { theme->osd_workspace_switcher_boxes_height = 0; }