From b4c99f873f97d1107505b94c305624d8e1387346 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 1 May 2021 20:17:54 +0200 Subject: [PATCH] =?UTF-8?q?render:=20only=20apply=20alpha=20when=20we?= =?UTF-8?q?=E2=80=99re=20using=20the=20default=20bg=20for=20background?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In all other cases, alpha is disabled. This includes: * Palette- or RGB-colors matching the default background color * When any kind of reverse video is enabled (e.g. DECSCNM, or ANSI reverse) --- CHANGELOG.md | 2 ++ render.c | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ec26157..4dad6011 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,6 +57,8 @@ to launch (e.g. bad command line option) and -26/230 when the foot server failed to instantiate a new window (https://codeberg.org/dnkl/foot/issues/466). +* Background alpha no longer applied to palette or RGB colors that + matches the background color. ### Deprecated diff --git a/render.c b/render.c index e4387c08..7d5dc8d7 100644 --- a/render.c +++ b/render.c @@ -429,6 +429,8 @@ render_cell(struct terminal *term, pixman_image_t *pix, uint32_t _fg = 0; uint32_t _bg = 0; + bool apply_alpha = false; + if (is_selected && term->colors.use_custom_selection) { _fg = term->colors.selection_fg; _bg = term->colors.selection_bg; @@ -441,12 +443,14 @@ render_cell(struct terminal *term, pixman_image_t *pix, uint32_t swap = _fg; _fg = _bg; _bg = swap; - } + } else + apply_alpha = !cell->attrs.have_bg; } if (unlikely(is_selected && _fg == _bg)) { /* Invert bg when selected/highlighted text has same fg/bg */ _bg = ~_bg; + apply_alpha = false; } if (cell->attrs.dim) @@ -459,9 +463,7 @@ render_cell(struct terminal *term, pixman_image_t *pix, pixman_color_t fg = color_hex_to_pixman(_fg); pixman_color_t bg = color_hex_to_pixman_with_alpha( - _bg, - (_bg == (term->reverse ? term->colors.fg : term->colors.bg) - ? term->colors.alpha : 0xffff)); + _bg, apply_alpha ? term->colors.alpha : 0xffff); if (term->is_searching && !is_selected) { color_dim_for_search(&fg);