1
0
Fork 0
mirror of https://github.com/alacritty/alacritty.git synced 2024-11-11 13:51:01 -05:00

Fix cell opacity when color matches terminal bg

Commit e964af8 introduced a regression, where if cell's bg color was
equal to NamedColor::Background rgb color it was rendered with transparent
background. However the correct behavior is to render bg transparent
only when bg color is actually a NamedColor::Background.

Fixes #2814.
This commit is contained in:
Kirill Chibisov 2019-09-26 17:10:54 +03:00 committed by Christian Duerr
parent ad24485cdb
commit 9a0555bbba
2 changed files with 6 additions and 3 deletions

View file

@ -49,6 +49,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Block URL highlight while a selection is active - Block URL highlight while a selection is active
- Bindings for Alt + F1-F12 - Bindings for Alt + F1-F12
- Discard scrolling region escape with bottom above top - Discard scrolling region escape with bottom above top
- Opacity always applying to cells with their background color matching the teriminal background
### Removed ### Removed

View file

@ -273,11 +273,13 @@ impl RenderableCell {
// Lookup RGB values // Lookup RGB values
let mut fg_rgb = Self::compute_fg_rgb(config, colors, cell.fg, cell.flags); let mut fg_rgb = Self::compute_fg_rgb(config, colors, cell.fg, cell.flags);
let mut bg_rgb = Self::compute_bg_rgb(colors, cell.bg); let mut bg_rgb = Self::compute_bg_rgb(colors, cell.bg);
let mut bg_alpha = Self::compute_bg_alpha(cell.bg);
let selection_background = config.colors.selection.background; let selection_background = config.colors.selection.background;
if let (true, Some(col)) = (selected, selection_background) { if let (true, Some(col)) = (selected, selection_background) {
// Override selection background with config colors // Override selection background with config colors
bg_rgb = col; bg_rgb = col;
bg_alpha = 1.0;
} else if selected ^ cell.inverse() { } else if selected ^ cell.inverse() {
if fg_rgb == bg_rgb && !cell.flags.contains(Flags::HIDDEN) { if fg_rgb == bg_rgb && !cell.flags.contains(Flags::HIDDEN) {
// Reveal inversed text when fg/bg is the same // Reveal inversed text when fg/bg is the same
@ -300,7 +302,7 @@ impl RenderableCell {
inner: RenderableCellContent::Chars(cell.chars()), inner: RenderableCellContent::Chars(cell.chars()),
fg: fg_rgb, fg: fg_rgb,
bg: bg_rgb, bg: bg_rgb,
bg_alpha: Self::compute_bg_alpha(colors, bg_rgb), bg_alpha,
flags: cell.flags, flags: cell.flags,
} }
} }
@ -343,8 +345,8 @@ impl RenderableCell {
} }
#[inline] #[inline]
fn compute_bg_alpha(colors: &color::List, bg: Rgb) -> f32 { fn compute_bg_alpha(bg: Color) -> f32 {
if colors[NamedColor::Background] == bg { if bg == Color::Named(NamedColor::Background) {
0. 0.
} else { } else {
1. 1.