mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-04 01:40:21 -05:00
Merge branch 'csd-button-fg-color'
This commit is contained in:
commit
8177dbcc86
6 changed files with 43 additions and 10 deletions
|
|
@ -67,6 +67,7 @@
|
||||||
(https://codeberg.org/dnkl/foot/issues/554).
|
(https://codeberg.org/dnkl/foot/issues/554).
|
||||||
* `underline-offset` option to `foot.ini`
|
* `underline-offset` option to `foot.ini`
|
||||||
(https://codeberg.org/dnkl/foot/issues/490).
|
(https://codeberg.org/dnkl/foot/issues/490).
|
||||||
|
* `csd.button-color` option to `foot.ini`.
|
||||||
|
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
|
||||||
11
config.c
11
config.c
|
|
@ -1316,6 +1316,17 @@ parse_section_csd(const char *key, const char *value, struct config *conf,
|
||||||
conf->csd.button_width = pixels;
|
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) {
|
else if (strcmp(key, "button-minimize-color") == 0) {
|
||||||
uint32_t color;
|
uint32_t color;
|
||||||
if (!str_to_color(value, &color, true, conf, path, lineno, "csd", "button-minimize-color")) {
|
if (!str_to_color(value, &color, true, conf, path, lineno, "csd", "button-minimize-color")) {
|
||||||
|
|
|
||||||
2
config.h
2
config.h
|
|
@ -214,10 +214,12 @@ struct config {
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
bool title_set:1;
|
bool title_set:1;
|
||||||
|
bool buttons_set:1;
|
||||||
bool minimize_set:1;
|
bool minimize_set:1;
|
||||||
bool maximize_set:1;
|
bool maximize_set:1;
|
||||||
bool close_set:1;
|
bool close_set:1;
|
||||||
uint32_t title;
|
uint32_t title;
|
||||||
|
uint32_t buttons;
|
||||||
uint32_t minimize;
|
uint32_t minimize;
|
||||||
uint32_t maximize;
|
uint32_t maximize;
|
||||||
uint32_t close;
|
uint32_t close;
|
||||||
|
|
|
||||||
|
|
@ -518,17 +518,21 @@ component.
|
||||||
Width, in pixels (subject to output scaling), of the
|
Width, in pixels (subject to output scaling), of the
|
||||||
minimize/maximize/close buttons. Default: _26_.
|
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*
|
*button-minimize-color*
|
||||||
Minimize button's AARRGGBB color. Default: use the default
|
Minimize button's background color, on the format
|
||||||
_regular4_ color (blue).
|
AARRGGBB. Default: use the default _regular4_ color (blue).
|
||||||
|
|
||||||
*button-maximize-color*
|
*button-maximize-color*
|
||||||
Maximize button's AARRGGBB color. Default: use the default
|
Maximize button's background color, on the format
|
||||||
_regular2_ color (green).
|
AARRGGBB. Default: use the default _regular2_ color (green).
|
||||||
|
|
||||||
*button-close-color*
|
*button-close-color*
|
||||||
Close button's AARRGGBB color. Default: use the default _regular1_
|
Close button's background color, on the format AARRGGBB. Default:
|
||||||
color (red).
|
use the default _regular1_ color (red).
|
||||||
|
|
||||||
|
|
||||||
# SECTION: key-bindings
|
# SECTION: key-bindings
|
||||||
|
|
|
||||||
1
foot.ini
1
foot.ini
|
|
@ -92,6 +92,7 @@
|
||||||
# size=26
|
# size=26
|
||||||
# color=<foreground color>
|
# color=<foreground color>
|
||||||
# button-width=26
|
# button-width=26
|
||||||
|
# button-color=<background color>
|
||||||
# button-minimize-color=<regular4>
|
# button-minimize-color=<regular4>
|
||||||
# button-maximize-color=<regular2>
|
# button-maximize-color=<regular2>
|
||||||
# button-close-color=<regular1>
|
# button-close-color=<regular1>
|
||||||
|
|
|
||||||
22
render.c
22
render.c
|
|
@ -1580,10 +1580,24 @@ render_csd_border(struct terminal *term, enum csd_surface surf_idx)
|
||||||
csd_commit(term, surf, buf);
|
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
|
static void
|
||||||
render_csd_button_minimize(struct terminal *term, struct buffer *buf)
|
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);
|
pixman_image_t *src = pixman_image_create_solid_fill(&color);
|
||||||
|
|
||||||
const int max_height = buf->height / 2;
|
const int max_height = buf->height / 2;
|
||||||
|
|
@ -1628,7 +1642,7 @@ static void
|
||||||
render_csd_button_maximize_maximized(
|
render_csd_button_maximize_maximized(
|
||||||
struct terminal *term, struct buffer *buf)
|
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);
|
pixman_image_t *src = pixman_image_create_solid_fill(&color);
|
||||||
|
|
||||||
const int max_height = buf->height / 3;
|
const int max_height = buf->height / 3;
|
||||||
|
|
@ -1656,7 +1670,7 @@ static void
|
||||||
render_csd_button_maximize_window(
|
render_csd_button_maximize_window(
|
||||||
struct terminal *term, struct buffer *buf)
|
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);
|
pixman_image_t *src = pixman_image_create_solid_fill(&color);
|
||||||
|
|
||||||
const int max_height = buf->height / 2;
|
const int max_height = buf->height / 2;
|
||||||
|
|
@ -1710,7 +1724,7 @@ render_csd_button_maximize(struct terminal *term, struct buffer *buf)
|
||||||
static void
|
static void
|
||||||
render_csd_button_close(struct terminal *term, struct buffer *buf)
|
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);
|
pixman_image_t *src = pixman_image_create_solid_fill(&color);
|
||||||
|
|
||||||
const int max_height = buf->height / 3;
|
const int max_height = buf->height / 3;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue