render: fix colors.alpha-mode=matching

Before this patch, it only matched RGB color sources. It did not match
the default bg color, or indexed colors. That is, e.g. CSI 43m didn't
apply alpha, even if the color3 matched the default background color.
This commit is contained in:
Daniel Eklöf 2025-04-19 07:46:06 +02:00
parent 1bf9156628
commit 1a2e5f4932
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
2 changed files with 12 additions and 1 deletions

View file

@ -66,6 +66,10 @@
### Deprecated
### Removed
### Fixed
* `colors.alpha-mode=matching` not working as intended.
### Security
### Contributors

View file

@ -754,8 +754,15 @@ render_cell(struct terminal *term, pixman_image_t *pix,
}
case ALPHA_MODE_MATCHING: {
if (cell->attrs.bg == term->colors.bg)
if (cell->attrs.bg_src == COLOR_DEFAULT ||
((cell->attrs.bg_src == COLOR_BASE16 ||
cell->attrs.bg_src == COLOR_BASE256) &&
term->colors.table[cell->attrs.bg] == term->colors.bg) ||
(cell->attrs.bg_src == COLOR_RGB &&
cell->attrs.bg == term->colors.bg))
{
alpha = term->colors.alpha;
}
break;
}