]> git.mdlowis.com Git - proto/labwc.git/commitdiff
osd: add theme settings for window-switcher preview
authortokyo4j <hrak1529@gmail.com>
Mon, 15 Apr 2024 11:22:44 +0000 (20:22 +0900)
committerConsolatis <35009135+Consolatis@users.noreply.github.com>
Tue, 16 Apr 2024 07:58:34 +0000 (09:58 +0200)
Adds theme settings like:
osd.window-switcher.preview.border.width: 2
osd.window-switcher.preview.border.color: #ffffff,#00a2ff,#ffffff

docs/labwc-theme.5.scd
docs/themerc
include/theme.h
src/osd.c
src/theme.c

index ba8c23ffb8ea2f2db73e4f9fe303d1c6b8a6e249..6e59a3c1733730759edbbe6e062a65aa2706e3a8 100644 (file)
@@ -190,6 +190,18 @@ elements are not listed here, but are supported.
        Border width of the selection box in the window switcher in pixels.
        Default is 2.
 
+*osd.window-switcher.preview.border.width*
+       Border width of the outlines shown as the preview of the window selected by
+       window switcher. Inherits *osd.border.width* if not set.
+
+*osd.window-switcher.preview.border.color*
+       Color(s) of the outlines shown as the preview of the window selected by
+       window switcher. Possible value is a color or up to 3 colors separated
+       by commas (e.g. "#ffffff,#000000,#ffffff"). When multiple colors are
+       specified, a multi-line rectangle with each line having the specified color
+       is drawn. If not set, this inherits the on-screen-display theme
+       ("[*osd.bg.color*],[*osd.label.text.color*],[*osd.bg.color*]").
+
 *osd.workspace-switcher.boxes.width*
        Width of boxes in workspace switcher in pixels. Setting to 0 disables
        boxes. Default is 20.
@@ -226,15 +238,13 @@ elements are not listed here, but are supported.
 
 *snapping.preview.region.border.color*
        Color(s) of an outlined rectangle shown as the preview when a window is
-       snapped to a region. Possible value is a color or up to 3 colors separated
-       by commas (e.g. "#ffffff,#000000,#ffffff"). When multiple colors are
-       specified, a multi-line rectangle with each line having the specified color
-       is drawn. If not set, this inherits the on-screen-display theme
-       ("[*osd.bg.color*],[*osd.label.text.color*],[*osd.bg.color*]").
+       snapped to a region. Possible values and the default value are the same as
+       those of *osd.window-switcher.preview.border.color*.
 
 *snapping.preview.edge.border.color*
        Color(s) of an outlined rectangle shown as the preview when a window is
-       snapped to an edge. See *snapping.preview.region.border.color* for details.
+       snapped to an edge. Possible values and the default value are the same as
+       those of *osd.window-switcher.preview.border.color*.
 
 *border.color*
        Set both *window.active.border.color* and *window.inactive.border.color*.
index efb650e60263198b66572dcd6ffc1e4b31760e15..23f32ac75023a9524fa5587be2bc5d83e9d23b35 100644 (file)
@@ -68,6 +68,8 @@ 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.preview.border.width: 1
+osd.window-switcher.preview.border.color: #dddda6,#000000,#dddda6
 
 osd.workspace-switcher.boxes.width: 20
 osd.workspace-switcher.boxes.height: 20
index ba4e3357d88df409a5213606f354cf7e7bb60a61..ddbe1fb6ece1c0d862d0e67ed24797567afbcabd 100644 (file)
@@ -76,6 +76,8 @@ struct theme {
        int osd_window_switcher_item_padding_y;
        int osd_window_switcher_item_active_border_width;
        bool osd_window_switcher_width_is_percent;
+       int osd_window_switcher_preview_border_width;
+       float osd_window_switcher_preview_border_color[3][4];
 
        int osd_workspace_switcher_boxes_width;
        int osd_workspace_switcher_boxes_height;
index caefe66d57802e3045a78cec85a16e06e86e1e3a..69feb4c82a25342e80a8f6b175747375c69810ab 100644 (file)
--- a/src/osd.c
+++ b/src/osd.c
@@ -38,11 +38,11 @@ osd_update_preview_outlines(struct view *view)
        struct server *server = view->server;
        struct multi_rect *rect = view->server->osd_state.preview_outline;
        if (!rect) {
-               int line_width = server->theme->osd_border_width;
+               int line_width = server->theme->osd_window_switcher_preview_border_width;
                float *colors[] = {
-                       server->theme->osd_bg_color,
-                       server->theme->osd_label_text_color,
-                       server->theme->osd_bg_color
+                       server->theme->osd_window_switcher_preview_border_color[0],
+                       server->theme->osd_window_switcher_preview_border_color[1],
+                       server->theme->osd_window_switcher_preview_border_color[2],
                };
                rect = multi_rect_create(&server->scene->tree, colors, line_width);
                wlr_scene_node_place_above(&rect->tree->node, &server->menu_tree->node);
index ac33e0f1ec6517a78db7cafe450699b817c808ca..49176901b784267a455c074627e5a8d0235b8907 100644 (file)
@@ -523,6 +523,12 @@ theme_builtin(struct theme *theme)
        theme->osd_window_switcher_item_padding_y = 1;
        theme->osd_window_switcher_item_active_border_width = 2;
 
+       /* inherit settings in post_processing() if not set elsewhere */
+       theme->osd_window_switcher_preview_border_width = INT_MIN;
+       memset(theme->osd_window_switcher_preview_border_color, 0,
+               sizeof(theme->osd_window_switcher_preview_border_color));
+       theme->osd_window_switcher_preview_border_color[0][0] = FLT_MIN;
+
        theme->osd_workspace_switcher_boxes_width = 20;
        theme->osd_workspace_switcher_boxes_height = 20;
 
@@ -733,6 +739,12 @@ entry(struct theme *theme, const char *key, const char *value)
        if (match_glob(key, "osd.window-switcher.item.active.border.width")) {
                theme->osd_window_switcher_item_active_border_width = atoi(value);
        }
+       if (match_glob(key, "osd.window-switcher.preview.border.width")) {
+               theme->osd_window_switcher_preview_border_width = atoi(value);
+       }
+       if (match_glob(key, "osd.window-switcher.preview.border.color")) {
+               parse_hexstrs(value, theme->osd_window_switcher_preview_border_color);
+       }
        if (match_glob(key, "osd.workspace-switcher.boxes.width")) {
                theme->osd_workspace_switcher_boxes_width = atoi(value);
        }
@@ -1092,6 +1104,14 @@ post_processing(struct theme *theme)
                theme->osd_window_switcher_width =
                        MIN(theme->osd_window_switcher_width, 100);
        }
+       if (theme->osd_window_switcher_preview_border_width == INT_MIN) {
+               theme->osd_window_switcher_preview_border_width =
+                       theme->osd_border_width;
+       }
+       if (theme->osd_window_switcher_preview_border_color[0][0] == FLT_MIN) {
+               fill_colors_with_osd_theme(theme,
+                       theme->osd_window_switcher_preview_border_color);
+       }
 
        if (theme->snapping_preview_region_border_width == INT_MIN) {
                theme->snapping_preview_region_border_width =