aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-06-20 11:53:21 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-06-20 11:53:21 +0000
commit8177dbcc8697c57792b69b7bc0a8be5ffe890388 (patch)
tree363c5a6b25152c16a5e13240aab30a57255c23a2
parenturi: hostname_is_localhost(): don’t crash if hostname == NULL (diff)
parentconfig: add csd.button-color option (diff)
Merge branch 'csd-button-fg-color'
-rw-r--r--CHANGELOG.md1
-rw-r--r--config.c11
-rw-r--r--config.h2
-rw-r--r--doc/foot.ini.5.scd16
-rw-r--r--foot.ini1
-rw-r--r--render.c22
6 files changed, 43 insertions, 10 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0fb4c8e6..0c12f766 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -67,6 +67,7 @@
(https://codeberg.org/dnkl/foot/issues/554).
* `underline-offset` option to `foot.ini`
(https://codeberg.org/dnkl/foot/issues/490).
+* `csd.button-color` option to `foot.ini`.
### Changed
diff --git a/config.c b/config.c
index 9a2af7c3..92d2b69f 100644
--- a/config.c
+++ b/config.c
@@ -1316,6 +1316,17 @@ parse_section_csd(const char *key, const char *value, struct config *conf,
conf->csd.button_width = pixels;
}
+ else if (strcmp(key, "button-color") == 0) {
+ uint32_t color;
+ if (!str_to_color(value, &color, true, conf, path, lineno, "csd", "button-color")) {
+ LOG_AND_NOTIFY_ERR("%s:%d: invalid button-color: %s", path, lineno, value);
+ return false;
+ }
+
+ conf->csd.color.buttons_set = true;
+ conf->csd.color.buttons = color;
+ }
+
else if (strcmp(key, "button-minimize-color") == 0) {
uint32_t color;
if (!str_to_color(value, &color, true, conf, path, lineno, "csd", "button-minimize-color")) {
diff --git a/config.h b/config.h
index 4de024ba..bdb1a109 100644
--- a/config.h
+++ b/config.h
@@ -214,10 +214,12 @@ struct config {
struct {
bool title_set:1;
+ bool buttons_set:1;
bool minimize_set:1;
bool maximize_set:1;
bool close_set:1;
uint32_t title;
+ uint32_t buttons;
uint32_t minimize;
uint32_t maximize;
uint32_t close;
diff --git a/doc/foot.ini.5.scd b/doc/foot.ini.5.scd
index a34a1987..58134060 100644
--- a/doc/foot.ini.5.scd
+++ b/doc/foot.ini.5.scd
@@ -518,17 +518,21 @@ component.
Width, in pixels (subject to output scaling), of the
minimize/maximize/close buttons. Default: _26_.
+*button-color*
+ Foreground color on the minimize/maximize/close buttons. Default:
+ use the default _background_ color.
+
*button-minimize-color*
- Minimize button's AARRGGBB color. Default: use the default
- _regular4_ color (blue).
+ Minimize button's background color, on the format
+ AARRGGBB. Default: use the default _regular4_ color (blue).
*button-maximize-color*
- Maximize button's AARRGGBB color. Default: use the default
- _regular2_ color (green).
+ Maximize button's background color, on the format
+ AARRGGBB. Default: use the default _regular2_ color (green).
*button-close-color*
- Close button's AARRGGBB color. Default: use the default _regular1_
- color (red).
+ Close button's background color, on the format AARRGGBB. Default:
+ use the default _regular1_ color (red).
# SECTION: key-bindings
diff --git a/foot.ini b/foot.ini
index f2e74308..c10ed143 100644
--- a/foot.ini
+++ b/foot.ini
@@ -92,6 +92,7 @@
# size=26
# color=<foreground color>
# button-width=26
+# button-color=<background color>
# button-minimize-color=<regular4>
# button-maximize-color=<regular2>
# button-close-color=<regular1>
diff --git a/render.c b/render.c
index 0bf09bd8..a1f9ee79 100644
--- a/render.c
+++ b/render.c
@@ -1580,10 +1580,24 @@ render_csd_border(struct terminal *term, enum csd_surface surf_idx)
csd_commit(term, surf, buf);
}
+static pixman_color_t
+get_csd_button_fg_color(const struct config *conf)
+{
+ uint32_t _color = conf->colors.bg;
+ uint16_t alpha = 0xffff;
+
+ if (conf->csd.color.buttons_set) {
+ _color = conf->csd.color.buttons;
+ alpha = _color >> 24 | (_color >> 24 << 8);
+ }
+
+ return color_hex_to_pixman_with_alpha(_color, alpha);
+}
+
static void
render_csd_button_minimize(struct terminal *term, struct buffer *buf)
{
- pixman_color_t color = color_hex_to_pixman(term->conf->colors.bg);
+ pixman_color_t color = get_csd_button_fg_color(term->conf);
pixman_image_t *src = pixman_image_create_solid_fill(&color);
const int max_height = buf->height / 2;
@@ -1628,7 +1642,7 @@ static void
render_csd_button_maximize_maximized(
struct terminal *term, struct buffer *buf)
{
- pixman_color_t color = color_hex_to_pixman(term->conf->colors.bg);
+ pixman_color_t color = get_csd_button_fg_color(term->conf);
pixman_image_t *src = pixman_image_create_solid_fill(&color);
const int max_height = buf->height / 3;
@@ -1656,7 +1670,7 @@ static void
render_csd_button_maximize_window(
struct terminal *term, struct buffer *buf)
{
- pixman_color_t color = color_hex_to_pixman(term->conf->colors.bg);
+ pixman_color_t color = get_csd_button_fg_color(term->conf);
pixman_image_t *src = pixman_image_create_solid_fill(&color);
const int max_height = buf->height / 2;
@@ -1710,7 +1724,7 @@ render_csd_button_maximize(struct terminal *term, struct buffer *buf)
static void
render_csd_button_close(struct terminal *term, struct buffer *buf)
{
- pixman_color_t color = color_hex_to_pixman(term->conf->colors.bg);
+ pixman_color_t color = get_csd_button_fg_color(term->conf);
pixman_image_t *src = pixman_image_create_solid_fill(&color);
const int max_height = buf->height / 3;