csd: add support for a visible border

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.
This commit is contained in:
Daniel Eklöf 2021-10-27 18:27:08 +02:00
parent eebec8e38d
commit 5e4de143de
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
6 changed files with 99 additions and 7 deletions

View file

@ -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);