From 5e4de143de6c43ab54a5df7cea169674f8ea79a3 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Wed, 27 Oct 2021 18:27:08 +0200 Subject: csd: add support for a visible border MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When we’re using CSDs, we’ve up until now rendered a 5px invisible border. This border handles interactive resizing. I.e. hovering it changes the mouse cursor, and mouse button events are used to start an interactive resize. This patch makes it possible to color part of (or the entire) border, with a configurable color. To facilitate this, two new options have been added: * csd.border-width * csd.border-color border-width defaults to 0, resulting in the look we’re used to. border-color defaults to the title bar color. If the title bar color hasn’t been set, it defaults to the default foreground color (just like the title bar color does). This means that, setting border-width but not border-color, results in a border that blends with the title bar. --- config.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'config.c') diff --git a/config.c b/config.c index bd9ebbf2..4e772aa1 100644 --- a/config.c +++ b/config.c @@ -1489,7 +1489,9 @@ parse_section_csd(const char *key, const char *value, struct config *conf, else if (strcmp(key, "size") == 0) { unsigned long pixels; if (!str_to_ulong(value, 10, &pixels)) { - LOG_AND_NOTIFY_ERR("%s:%d: expected an integer, got '%s'", path, lineno, value); + LOG_AND_NOTIFY_ERR( + "%s:%d: [csd]: size: expected an integer, got '%s'", + path, lineno, value); return false; } @@ -1499,7 +1501,9 @@ parse_section_csd(const char *key, const char *value, struct config *conf, else if (strcmp(key, "button-width") == 0) { unsigned long pixels; if (!str_to_ulong(value, 10, &pixels)) { - LOG_AND_NOTIFY_ERR("%s:%d: expected an integer, got '%s'", path, lineno, value); + LOG_AND_NOTIFY_ERR( + "%s:%d: [csd]: button-width: expected an integer, got '%s'", + path, lineno, value); return false; } @@ -1542,6 +1546,27 @@ parse_section_csd(const char *key, const char *value, struct config *conf, conf->csd.color.close = color; } + else if (strcmp(key, "border-color") == 0) { + uint32_t color; + if (!str_to_color(value, &color, true, conf, path, lineno, "csd", "border-color")) + return false; + + conf->csd.color.border_set = true; + conf->csd.color.border = color; + } + + else if (strcmp(key, "border-width") == 0) { + unsigned long width; + if (!str_to_ulong(value, 10, &width)) { + LOG_AND_NOTIFY_ERR( + "%s:%u: [csd]: border-width: expected an integer, got '%s'", + path, lineno, value); + return false; + } + + conf->csd.border_width_visible = width; + } + else { LOG_AND_NOTIFY_ERR("%s:%u: [csd]: %s: invalid action", path, lineno, key); -- cgit v1.3