]> git.mdlowis.com Git - proto/labwc.git/commitdiff
osd-thumbnail: update default colors of selected window item
authortokyo4j <hrak1529@gmail.com>
Wed, 1 Oct 2025 19:06:48 +0000 (04:06 +0900)
committerJohan Malm <johanmalm@users.noreply.github.com>
Tue, 7 Oct 2025 18:47:50 +0000 (19:47 +0100)
Previously, the default values of
`osd.window-switcher.style-thumbnail.item.active.{bg,border}.color`
were blue. But they caused the selected window title in the window
switcher to be unreadable due to duplicated colors of the text and
background with Openbox themes like Numix.

Instead, this commit updates them to follow other themes configurations.
The default border color of the selected window item is now
`osd.label.text.color` with 50% opacity and the background is
`osd.label.text.color` with 15% opacity.

For subpixel antialiasing to work, the background color is calculated by
manually blending `osd.label.text.color` and `osd.bg.color`, rather than
just updating the alpha with 50% or 15%.

docs/labwc-theme.5.scd
docs/themerc
src/theme.c

index efc3a1a507b328aa5f614bca61ae329d201337e5..fad8a77ece04f6be56e0b93e7081e92df3db563c 100644 (file)
@@ -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.
index 7b251a3c7eca4c54451d64ccd4261a0dfc887263..a52dfacd99cce9a161567ee944f68df6c36bf35e 100644 (file)
@@ -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
index d5279367ed74e978731678349644c8b6e8daee46..a3aec34a261c7c99a674166f8fde225a2a7d1e04 100644 (file)
@@ -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;
        }