]> git.mdlowis.com Git - proto/labwc.git/commitdiff
theme: add option osd.window-switcher.padding
authorJohan Malm <jgm323@gmail.com>
Thu, 29 Jun 2023 20:29:43 +0000 (21:29 +0100)
committerJohan Malm <johanmalm@users.noreply.github.com>
Wed, 5 Jul 2023 20:31:30 +0000 (21:31 +0100)
Fixes: issue #969
docs/labwc-theme.5.scd
docs/themerc
include/theme.h
src/osd.c
src/theme.c

index 2a530f3572a5d6a7a42985a11888ddcd6601cb5e..6142f085887f64f14f6ee7dec15913356a65f4da 100644 (file)
@@ -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.
index 0ad6e3db06fdeeb5040503fc6a00850f21f07e67..03bb3216c22f507acab7959a28a6812d844c5142 100644 (file)
@@ -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
index 4183cfd5011c71853464a11313d8a8930fa79b0d..df6fbab22362bbb39487f64fa62f207bfc6e3bdb 100644 (file)
@@ -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;
 
index 29f126a7760b7015d74cf4bc1772a2486a1f8caf..f95d8031e0e7d72e336df419220480926fde5a34 100644 (file)
--- 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,
                        };
index d1aed200849ca232d6cde2877e1b1d3783e56066..03d54a9ef39fa26f8e53aa314cd4adad5ebc122c 100644 (file)
@@ -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,