diff --git a/include/common/borderset.h b/include/common/borderset.h index b1906668..d3bd8860 100644 --- a/include/common/borderset.h +++ b/include/common/borderset.h @@ -1,4 +1,5 @@ #include +#include /* SPDX-License-Identifier: GPL-2.0-only */ #ifndef LABWC_BORDERSET_H #define LABWC_BORDERSET_H diff --git a/include/theme.h b/include/theme.h index 123558f5..1ab6e323 100644 --- a/include/theme.h +++ b/include/theme.h @@ -11,6 +11,7 @@ #include #include #include "common/node-type.h" +#include "common/borderset.h" struct lab_img; @@ -98,6 +99,8 @@ struct theme { float border_color[4]; float toggled_keybinds_color[4]; float label_text_color[4]; + enum border_type border_type; + int bevel_width; /* window drop-shadows */ int shadow_size; diff --git a/src/common/borderset.c b/src/common/borderset.c index 13826161..083d451a 100644 --- a/src/common/borderset.c +++ b/src/common/borderset.c @@ -53,6 +53,7 @@ struct borderset * createBuffer(uint32_t id, int size, enum border_type type, i newBorderset->bevelSize = bevelSize; + // Use ID as a AARRGGBB colour uint8_t a = id >> 24 & 255; uint8_t r = id >> 16 & 255; diff --git a/src/ssd/ssd-border.c b/src/ssd/ssd-border.c index 4bfd40b5..e26b80bf 100644 --- a/src/ssd/ssd-border.c +++ b/src/ssd/ssd-border.c @@ -39,7 +39,7 @@ ssd_border_create(struct ssd *ssd) struct wlr_scene_tree *parent = subtree->tree; wlr_scene_node_set_enabled(&parent->node, active); float *color = theme->window[active].border_color; - if (theme->beveled_border) { + if (theme->window[active].border_type) { // These will otherwise get left under the window when we reload @@ -51,10 +51,6 @@ ssd_border_create(struct ssd *ssd) subtree->bottom = lab_wlr_scene_rect_create(parent, 1, 1, color); subtree->top = lab_wlr_scene_rect_create(parent, 1, 1, color); - - - - int bevelSize = theme->border_bevel_width; /* From Pull request 3382 */ float r = color[0]; @@ -63,7 +59,7 @@ ssd_border_create(struct ssd *ssd) float a = color[3]; uint32_t colour32 = (uint32_t)(a*255) << 24 | (uint32_t)(r*255) << 16 | (uint32_t)(g*255) << 8 | (uint32_t)(b*255); - struct borderset * renderedborders = getBorders(colour32, bw, BORDER_DOUBLE, bevelSize); + struct borderset * renderedborders = getBorders(colour32, bw, theme->window[active].border_type, theme->window[active].bevel_width); subtree->texturedBorders = generateBufferset(subtree->tree, renderedborders, bw); } else { subtree->left = lab_wlr_scene_rect_create(parent, @@ -172,7 +168,7 @@ ssd_border_update(struct ssd *ssd) struct ssd_border_subtree *subtree = &ssd->border.subtrees[active]; - if (theme->beveled_border) { + if (theme->window[active].border_type) { renderBufferset(subtree->texturedBorders, full_width, side_height+(ssd->titlebar.height + 2*theme->border_width), -ssd->titlebar.height-theme->border_width); } else { wlr_scene_rect_set_size(subtree->left, diff --git a/src/theme.c b/src/theme.c index c831599d..9e517a2d 100644 --- a/src/theme.c +++ b/src/theme.c @@ -450,6 +450,18 @@ parse_hexstrs(const char *hexes, float colors[3][4]) g_strfreev(elements); } +static enum border_type parse_border_type(const char *str) { + char *lower = g_ascii_strdown(str, -1); + if (strstr(lower, "doublesunken")) return BORDER_DOUBLE_INSET; + if (strstr(lower, "sunken")) return BORDER_INSET; + if (strstr(lower, "doubleraised")) return BORDER_DOUBLE; + if (strstr(lower, "raised")) return BORDER_SINGLE; + return BORDER_FLAT; + + + +} + static void parse_color(const char *str, float *rgba) { @@ -552,6 +564,10 @@ theme_builtin(struct theme *theme) theme->window[SSD_INACTIVE].title_bg.color_to[0] = FLT_MIN; theme->window[SSD_ACTIVE].title_bg.color_to_split_to[0] = FLT_MIN; theme->window[SSD_INACTIVE].title_bg.color_to_split_to[0] = FLT_MIN; + theme->window[SSD_ACTIVE].bevel_width = 0; + theme->window[SSD_ACTIVE].border_type = BORDER_FLAT; + theme->window[SSD_INACTIVE].bevel_width = 0; + theme->window[SSD_INACTIVE].border_type = BORDER_FLAT; parse_hexstr("#000000", theme->window[SSD_ACTIVE].label_text_color); parse_hexstr("#000000", theme->window[SSD_INACTIVE].label_text_color); @@ -722,9 +738,25 @@ entry(struct theme *theme, const char *key, const char *value) if (match_glob(key, "window.active.border.color")) { parse_color(value, theme->window[SSD_ACTIVE].border_color); } + + if (match_glob(key, "window.active.border.type")) { + theme->window[SSD_ACTIVE].border_type = parse_border_type(value); + } + if (match_glob(key, "window.active.border.bevel-width")) { + theme->window[SSD_ACTIVE].bevel_width = get_int_if_positive(value, "window.active.border.bevel-width"); + } + if (match_glob(key, "window.inactive.border.color")) { parse_color(value, theme->window[SSD_INACTIVE].border_color); } + + if (match_glob(key, "window.inactive.border.bevel-width")) { + theme->window[SSD_INACTIVE].bevel_width = get_int_if_positive(value, "window.inactive.border.bevel-width"); + } + + if (match_glob(key, "window.inactive.border.type")) { + theme->window[SSD_INACTIVE].border_type = parse_border_type(value); + } /* border.color is obsolete, but handled for backward compatibility */ if (match_glob(key, "border.color")) { parse_color(value, theme->window[SSD_ACTIVE].border_color);