]> git.mdlowis.com Git - proto/labwc.git/commitdiff
theme: move osd.window-switcher.* to osd.window-switcher.style-classic.*
authortokyo4j <hrak1529@gmail.com>
Fri, 8 Aug 2025 03:42:41 +0000 (12:42 +0900)
committerJohan Malm <johanmalm@users.noreply.github.com>
Fri, 29 Aug 2025 19:42:01 +0000 (20:42 +0100)
Backward compatibility is preserved.

docs/labwc-theme.5.scd
docs/themerc
include/theme.h
src/osd/osd-classic.c
src/osd/osd.c
src/ssd/resize-indicator.c
src/theme.c

index fd21edd8e1c82428ade56023b57e6a6d1fd336e5..dc24961186a1cdc9d13f907383eaac857cce7c7d 100644 (file)
@@ -303,28 +303,27 @@ all are supported.
        Text color of on-screen-display. Inherits
        *window.active.label.text.color* if not set.
 
-*osd.window-switcher.width*
-       Width of window switcher in pixels. Default is 600.
-       Width can also be percent of the width of the monitor.
-       % is mandatory as last character in this case, max 100%
+*osd.window-switcher.style-classic.width*
+       Width of window switcher in pixels. Width can also be a percentage of the
+       monitor width by adding '%' as suffix (e.g. 70%). Default is 600.
 
-*osd.window-switcher.padding*
+*osd.window-switcher.style-classic.padding*
        Padding of window switcher in pixels. This is the space between the
        window-switcher border and its items. Default is 4.
 
-*osd.window-switcher.item.padding.x*
+*osd.window-switcher.style-classic.item.padding.x*
        Horizontal padding of window switcher entries in pixels.
        Default is 10.
 
-*osd.window-switcher.item.padding.y*
+*osd.window-switcher.style-classic.item.padding.y*
        Vertical padding of window switcher entries in pixels.
        Default is 1.
 
-*osd.window-switcher.item.active.border.width*
+*osd.window-switcher.style-classic.item.active.border.width*
        Border width of the selection box in the window switcher in pixels.
        Default is 2.
 
-*osd.window-switcher.item.icon.size*
+*osd.window-switcher.style-classic.item.icon.size*
        Size of the icon in window switcher, in pixels.
        If not set, the font size derived from <theme><font place="OnScreenDisplay">
        is used.
index 045c102124022f4497a4422d40c024dbb6cd6bcd..a4a707991c399b3fe6cb2cd8c37f09c3eac7cbd6 100644 (file)
@@ -91,14 +91,14 @@ osd.label.text.color: #000000
 
 # width can be set as percent (of screen width)
 # example 50% or 75% instead of 600, max 100%
-osd.window-switcher.width: 600
+osd.window-switcher.style-classic.width: 600
 
-osd.window-switcher.padding: 4
-osd.window-switcher.item.padding.x: 10
-osd.window-switcher.item.padding.y: 1
-osd.window-switcher.item.active.border.width: 2
+osd.window-switcher.style-classic.padding: 4
+osd.window-switcher.style-classic.item.padding.x: 10
+osd.window-switcher.style-classic.item.padding.y: 1
+osd.window-switcher.style-classic.item.active.border.width: 2
 # The icon size the same as the font size by default
-# osd.window-switcher.item.icon.size: 50
+# osd.window-switcher.style-classic.item.icon.size: 50
 osd.window-switcher.preview.border.width: 1
 osd.window-switcher.preview.border.color: #dddda6,#000000,#dddda6
 
index 68a43f2f9f9ab5146f6d5603ef1580d58bc88d1a..6f4a81c62967a810fda19797bfb00d1c4b8aabe3 100644 (file)
@@ -164,13 +164,22 @@ struct theme {
        float osd_border_color[4];
        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;
-       int osd_window_switcher_item_active_border_width;
-       int osd_window_switcher_item_icon_size;
-       bool osd_window_switcher_width_is_percent;
+       struct window_switcher_classic_theme {
+               int width;
+               int padding;
+               int item_padding_x;
+               int item_padding_y;
+               int item_active_border_width;
+               int item_icon_size;
+               bool width_is_percent;
+
+               /*
+                * Not set in rc.xml/themerc, but derived from the tallest
+                * titlebar object plus 2 * window_titlebar_padding_height
+                */
+               int item_height;
+       } osd_window_switcher_classic;
+
        int osd_window_switcher_preview_border_width;
        float osd_window_switcher_preview_border_color[3][4];
 
@@ -181,12 +190,6 @@ struct theme {
        struct theme_snapping_overlay
                snapping_overlay_region, snapping_overlay_edge;
 
-       /*
-        * Not set in rc.xml/themerc, but derived from the tallest titlebar
-        * object plus 2 * window_titlebar_padding_height
-        */
-       int osd_window_switcher_item_height;
-
        /* magnifier */
        float mag_border_color[4];
        int mag_border_width;
index 24679378e2c055762001b5c368af2089b81a5622..6ec165c54cb4c8c0ebf551643aa1ead763d33e2a 100644 (file)
@@ -33,20 +33,20 @@ osd_classic_create(struct output *output, struct wl_array *views)
 
        struct server *server = output->server;
        struct theme *theme = server->theme;
+       struct window_switcher_classic_theme *switcher_theme =
+               &theme->osd_window_switcher_classic;
        bool show_workspace = wl_list_length(&rc.workspace_config.workspaces) > 1;
        const char *workspace_name = server->workspaces.current->name;
 
-       int w = theme->osd_window_switcher_width;
-       if (theme->osd_window_switcher_width_is_percent) {
-               w = output->wlr_output->width
-                       * theme->osd_window_switcher_width / 100;
+       int w = switcher_theme->width;
+       if (switcher_theme->width_is_percent) {
+               w = output->wlr_output->width * switcher_theme->width / 100;
        }
-       int h = wl_array_len(views) * rc.theme->osd_window_switcher_item_height
-               + 2 * rc.theme->osd_border_width
-               + 2 * rc.theme->osd_window_switcher_padding;
+       int h = wl_array_len(views) * switcher_theme->item_height
+               + 2 * rc.theme->osd_border_width + 2 * switcher_theme->padding;
        if (show_workspace) {
                /* workspace indicator */
-               h += theme->osd_window_switcher_item_height;
+               h += switcher_theme->item_height;
        }
 
        output->osd_scene.tree = wlr_scene_tree_create(output->osd_tree);
@@ -65,7 +65,7 @@ osd_classic_create(struct output *output, struct wl_array *views)
        };
        lab_scene_rect_create(output->osd_scene.tree, &bg_opts);
 
-       int y = theme->osd_border_width + theme->osd_window_switcher_padding;
+       int y = theme->osd_border_width + switcher_theme->padding;
 
        /* Draw workspace indicator */
        if (show_workspace) {
@@ -83,11 +83,10 @@ osd_classic_create(struct output *output, struct wl_array *views)
                struct scaled_font_buffer *font_buffer =
                        scaled_font_buffer_create(output->osd_scene.tree);
                wlr_scene_node_set_position(&font_buffer->scene_buffer->node,
-                       x, y + (theme->osd_window_switcher_item_height
-                               - font_height(&font)) / 2);
+                       x, y + (switcher_theme->item_height - font_height(&font)) / 2);
                scaled_font_buffer_update(font_buffer, workspace_name, 0,
                        &font, text_color, bg_color);
-               y += theme->osd_window_switcher_item_height;
+               y += switcher_theme->item_height;
        }
 
        struct buf buf = BUF_INIT;
@@ -95,9 +94,9 @@ osd_classic_create(struct output *output, struct wl_array *views)
 
        /* This is the width of the area available for text fields */
        int field_widths_sum = w - 2 * theme->osd_border_width
-               - 2 * theme->osd_window_switcher_padding
-               - 2 * theme->osd_window_switcher_item_active_border_width
-               - (nr_fields + 1) * theme->osd_window_switcher_item_padding_x;
+               - 2 * switcher_theme->padding
+               - 2 * switcher_theme->item_active_border_width
+               - (nr_fields + 1) * switcher_theme->item_padding_x;
        if (field_widths_sum <= 0) {
                wlr_log(WLR_ERROR, "Not enough spaces for osd contents");
                goto error;
@@ -126,9 +125,9 @@ osd_classic_create(struct output *output, struct wl_array *views)
                 * +---------------------------------+
                 */
                int x = theme->osd_border_width
-                       + theme->osd_window_switcher_padding
-                       + theme->osd_window_switcher_item_active_border_width
-                       + theme->osd_window_switcher_item_padding_x;
+                       + switcher_theme->padding
+                       + switcher_theme->item_active_border_width
+                       + switcher_theme->item_padding_x;
                struct wlr_scene_tree *item_root =
                        wlr_scene_tree_create(output->osd_scene.tree);
 
@@ -140,7 +139,7 @@ osd_classic_create(struct output *output, struct wl_array *views)
 
                        if (field->content == LAB_FIELD_ICON) {
                                int icon_size = MIN(field_width,
-                                       theme->osd_window_switcher_item_icon_size);
+                                       switcher_theme->item_icon_size);
                                struct scaled_icon_buffer *icon_buffer =
                                        scaled_icon_buffer_create(item_root,
                                                server, icon_size, icon_size);
@@ -163,25 +162,23 @@ osd_classic_create(struct output *output, struct wl_array *views)
                        }
 
                        if (node) {
-                               int item_height =
-                                       theme->osd_window_switcher_item_height;
+                               int item_height = switcher_theme->item_height;
                                wlr_scene_node_set_position(node,
                                        x, y + (item_height - height) / 2);
                        }
-                       x += field_width + theme->osd_window_switcher_item_padding_x;
+                       x += field_width + switcher_theme->item_padding_x;
                }
 
                /* Highlight around selected window's item */
                int highlight_x = theme->osd_border_width
-                               + theme->osd_window_switcher_padding;
+                               + switcher_theme->padding;
                struct lab_scene_rect_options highlight_opts = {
                        .border_colors = (float *[1]) {text_color},
                        .nr_borders = 1,
-                       .border_width =
-                               theme->osd_window_switcher_item_active_border_width,
+                       .border_width = switcher_theme->item_active_border_width,
                        .width = w - 2 * theme->osd_border_width
-                               - 2 * theme->osd_window_switcher_padding,
-                       .height = theme->osd_window_switcher_item_height,
+                               - 2 * switcher_theme->padding,
+                       .height = switcher_theme->item_height,
                };
 
                struct lab_scene_rect *highlight_rect = lab_scene_rect_create(
@@ -190,7 +187,7 @@ osd_classic_create(struct output *output, struct wl_array *views)
                wlr_scene_node_set_position(item->highlight_outline, highlight_x, y);
                wlr_scene_node_set_enabled(item->highlight_outline, false);
 
-               y += theme->osd_window_switcher_item_height;
+               y += switcher_theme->item_height;
        }
        buf_reset(&buf);
 
index 51a0721c353d6f775b7b67f78d3744d3ace7eca3..9bef5ce3129180c170002a9fef0d1bea8914405b 100644 (file)
@@ -272,7 +272,7 @@ update_osd(struct server *server)
                goto out;
        }
 
-       if (rc.window_switcher.show && rc.theme->osd_window_switcher_width > 0) {
+       if (rc.window_switcher.show) {
                /* Display the actual OSD */
                struct output *output;
                wl_list_for_each(output, &server->outputs, link) {
index 10fe3690d86ff9e5561002e2399cdb2c3817937c..cc5731ae47cf999085e6fedb43cff279afa07186 100644 (file)
@@ -12,6 +12,8 @@
 #include "theme.h"
 #include "view.h"
 
+#define PADDING rc.theme->osd_window_switcher_classic.padding
+
 static void
 resize_indicator_reconfigure_view(struct resize_indicator *indicator)
 {
@@ -19,7 +21,7 @@ resize_indicator_reconfigure_view(struct resize_indicator *indicator)
 
        struct theme *theme = rc.theme;
        indicator->height = font_height(&rc.font_osd)
-               + 2 * theme->osd_window_switcher_padding
+               + 2 * PADDING
                + 2 * theme->osd_border_width;
 
        /* Static positions */
@@ -27,8 +29,8 @@ resize_indicator_reconfigure_view(struct resize_indicator *indicator)
                theme->osd_border_width, theme->osd_border_width);
 
        wlr_scene_node_set_position(&indicator->text->scene_buffer->node,
-               theme->osd_border_width + theme->osd_window_switcher_padding,
-               theme->osd_border_width + theme->osd_window_switcher_padding);
+               theme->osd_border_width + PADDING,
+               theme->osd_border_width + PADDING);
 
        /* Colors */
        wlr_scene_rect_set_color(indicator->border, theme->osd_border_color);
@@ -107,7 +109,7 @@ resize_indicator_set_size(struct resize_indicator *indicator, int width)
 
        /* We are not using a width-cache-early-out here to allow for theme changes */
        indicator->width = width
-               + 2 * rc.theme->osd_window_switcher_padding
+               + 2 * PADDING
                + 2 * rc.theme->osd_border_width;
 
        wlr_scene_rect_set_size(indicator->border, indicator->width, indicator->height);
index e16325e8da6d02db929eeb177c0abef3a1704c8d..f874e58580971b168a560dc369240d5b08f1f608 100644 (file)
@@ -608,13 +608,13 @@ theme_builtin(struct theme *theme, struct server *server)
        theme->menu_title_text_justify = parse_justification("Center");
        parse_hexstr("#ffffff", theme->menu_title_text_color);
 
-       theme->osd_window_switcher_width = 600;
-       theme->osd_window_switcher_width_is_percent = false;
-       theme->osd_window_switcher_padding = 4;
-       theme->osd_window_switcher_item_padding_x = 10;
-       theme->osd_window_switcher_item_padding_y = 1;
-       theme->osd_window_switcher_item_active_border_width = 2;
-       theme->osd_window_switcher_item_icon_size = -1;
+       theme->osd_window_switcher_classic.width = 600;
+       theme->osd_window_switcher_classic.width_is_percent = false;
+       theme->osd_window_switcher_classic.padding = 4;
+       theme->osd_window_switcher_classic.item_padding_x = 10;
+       theme->osd_window_switcher_classic.item_padding_y = 1;
+       theme->osd_window_switcher_classic.item_active_border_width = 2;
+       theme->osd_window_switcher_classic.item_icon_size = -1;
 
        /* inherit settings in post_processing() if not set elsewhere */
        theme->osd_window_switcher_preview_border_width = INT_MIN;
@@ -679,6 +679,9 @@ entry(struct theme *theme, const char *key, const char *value)
                return;
        }
 
+       struct window_switcher_classic_theme *switcher_classic_theme =
+               &theme->osd_window_switcher_classic;
+
        /*
         * Note that in order for the pattern match to apply to more than just
         * the first instance, "else if" cannot be used throughout this function
@@ -949,38 +952,45 @@ entry(struct theme *theme, const char *key, const char *value)
        if (match_glob(key, "osd.border.color")) {
                parse_color(value, theme->osd_border_color);
        }
-       if (match_glob(key, "osd.window-switcher.width")) {
+       /* classic window switcher */
+       if (match_glob(key, "osd.window-switcher.style-classic.width")
+                       || match_glob(key, "osd.window-switcher.width")) {
                if (strrchr(value, '%')) {
-                       theme->osd_window_switcher_width_is_percent = true;
+                       switcher_classic_theme->width_is_percent = true;
                } else {
-                       theme->osd_window_switcher_width_is_percent = false;
+                       switcher_classic_theme->width_is_percent = false;
                }
-               theme->osd_window_switcher_width = get_int_if_positive(
-                       value, "osd.window-switcher.width");
-       }
-       if (match_glob(key, "osd.window-switcher.padding")) {
-               theme->osd_window_switcher_padding = get_int_if_positive(
-                       value, "osd.window-switcher.padding");
-       }
-       if (match_glob(key, "osd.window-switcher.item.padding.x")) {
-               theme->osd_window_switcher_item_padding_x =
-                       get_int_if_positive(
-                               value, "osd.window-switcher.item.padding.x");
-       }
-       if (match_glob(key, "osd.window-switcher.item.padding.y")) {
-               theme->osd_window_switcher_item_padding_y =
-                       get_int_if_positive(
-                               value, "osd.window-switcher.item.padding.y");
-       }
-       if (match_glob(key, "osd.window-switcher.item.active.border.width")) {
-               theme->osd_window_switcher_item_active_border_width =
-                       get_int_if_positive(
-                               value, "osd.window-switcher.item.active.border.width");
-       }
-       if (match_glob(key, "osd.window-switcher.item.icon.size")) {
-               theme->osd_window_switcher_item_icon_size =
-                       get_int_if_positive(
-                               value, "osd.window-switcher.item.icon.size");
+               switcher_classic_theme->width = get_int_if_positive(value,
+                       "osd.window-switcher.style-classic.width");
+       }
+       if (match_glob(key, "osd.window-switcher.style-classic.padding")
+                       || match_glob(key, "osd.window-switcher.padding")) {
+               switcher_classic_theme->padding = get_int_if_positive(value,
+                       "osd.window-switcher.style-classic.padding");
+       }
+       if (match_glob(key, "osd.window-switcher.style-classic.item.padding.x")
+                       || match_glob(key, "osd.window-switcher.item.padding.x")) {
+               switcher_classic_theme->item_padding_x =
+                       get_int_if_positive(value,
+                               "osd.window-switcher.style-classic.item.padding.x");
+       }
+       if (match_glob(key, "osd.window-switcher.style-classic.item.padding.y")
+                       || match_glob(key, "osd.window-switcher.item.padding.y")) {
+               switcher_classic_theme->item_padding_y =
+                       get_int_if_positive(value,
+                               "osd.window-switcher.style-classic.item.padding.y");
+       }
+       if (match_glob(key, "osd.window-switcher.style-classic.item.active.border.width")
+                       || match_glob(key, "osd.window-switcher.item.active.border.width")) {
+               switcher_classic_theme->item_active_border_width =
+                       get_int_if_positive(value,
+                               "osd.window-switcher.style-classic.item.active.border.width");
+       }
+       if (match_glob(key, "osd.window-switcher.style-classic.item.icon.size")
+                       || match_glob(key, "osd.window-switcher.item.icon.size")) {
+               switcher_classic_theme->item_icon_size =
+                       get_int_if_positive(value,
+                               "osd.window-switcher.style-classic.item.icon.size");
        }
        if (match_glob(key, "osd.window-switcher.preview.border.width")) {
                theme->osd_window_switcher_preview_border_width =
@@ -1582,6 +1592,9 @@ get_titlebar_height(struct theme *theme)
 static void
 post_processing(struct theme *theme)
 {
+       struct window_switcher_classic_theme *switcher_classic_theme =
+               &theme->osd_window_switcher_classic;
+
        theme->titlebar_height = get_titlebar_height(theme);
 
        fill_background_colors(&theme->window[THEME_INACTIVE].title_bg);
@@ -1594,14 +1607,14 @@ post_processing(struct theme *theme)
                + 2 * theme->menu_items_padding_y;
 
        int osd_font_height = font_height(&rc.font_osd);
-       if (theme->osd_window_switcher_item_icon_size <= 0) {
-               theme->osd_window_switcher_item_icon_size = osd_font_height;
+       if (switcher_classic_theme->item_icon_size <= 0) {
+               switcher_classic_theme->item_icon_size = osd_font_height;
        }
        int osd_field_height =
-               MAX(osd_font_height, theme->osd_window_switcher_item_icon_size);
-       theme->osd_window_switcher_item_height = osd_field_height
-               + 2 * theme->osd_window_switcher_item_padding_y
-               + 2 * theme->osd_window_switcher_item_active_border_width;
+               MAX(osd_font_height, switcher_classic_theme->item_icon_size);
+       switcher_classic_theme->item_height = osd_field_height
+               + 2 * switcher_classic_theme->item_padding_y
+               + 2 * switcher_classic_theme->item_active_border_width;
 
        if (rc.corner_radius >= theme->titlebar_height) {
                rc.corner_radius = theme->titlebar_height - 1;
@@ -1667,9 +1680,9 @@ post_processing(struct theme *theme)
        if (theme->osd_workspace_switcher_boxes_height == 0) {
                theme->osd_workspace_switcher_boxes_width = 0;
        }
-       if (theme->osd_window_switcher_width_is_percent) {
-               theme->osd_window_switcher_width =
-                       MIN(theme->osd_window_switcher_width, 100);
+       if (switcher_classic_theme->width_is_percent) {
+               switcher_classic_theme->width =
+                       MIN(switcher_classic_theme->width, 100);
        }
        if (theme->osd_window_switcher_preview_border_width == INT_MIN) {
                theme->osd_window_switcher_preview_border_width =