Fix background_opacity incorrectly applying to selected text and reverse video text

Fixes #2177
This commit is contained in:
Kovid Goyal 2019-12-01 15:14:15 +05:30
parent 769998adca
commit 24e17cb7d8
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 16 additions and 10 deletions

View File

@ -13,6 +13,8 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
- hints kitten: Add an option :option:`kitty +kitten hints --ascending` to - hints kitten: Add an option :option:`kitty +kitten hints --ascending` to
control if the hints numbers increase or decrease from top to bottom control if the hints numbers increase or decrease from top to bottom
- Fix :opt:`background_opacity` incorrectly applying to selected text and
reverse video text (:iss:`2177`)
0.15.0 [2019-11-27] 0.15.0 [2019-11-27]
-------------------- --------------------

View File

@ -151,7 +151,8 @@ void main() {
// set cell color indices {{{ // set cell color indices {{{
uvec2 default_colors = uvec2(default_fg, default_bg); uvec2 default_colors = uvec2(default_fg, default_bg);
uint text_attrs = sprite_coords[3]; uint text_attrs = sprite_coords[3];
uint is_inverted = ((text_attrs >> REVERSE_SHIFT) & ONE) + inverted; uint is_reversed = ((text_attrs >> REVERSE_SHIFT) & ONE);
uint is_inverted = is_reversed + inverted;
int fg_index = fg_index_map[is_inverted]; int fg_index = fg_index_map[is_inverted];
int bg_index = 1 - fg_index; int bg_index = 1 - fg_index;
float cell_has_cursor = is_cursor(c, r); float cell_has_cursor = is_cursor(c, r);
@ -200,22 +201,25 @@ void main() {
background = bg; background = bg;
#endif #endif
#if defined(TRANSPARENT) && !defined(SPECIAL) #if defined(TRANSPARENT)
// If the background color is default, set its opacity to background_opacity, otherwise it should be opaque // Set bg_alpha to background_opacity on cells that have the default background color
bg_alpha = step(0.5, float(colors[bg_index] & BYTE_MASK)); // Which means they must not have a block cursor or a selection or reverse video
// Cursor must not be affected by background_opacity // On other cells it should be 1. For the SPECIAL program it should be 1 on cells with
bg_alpha = mix(bg_alpha, 1.0, cell_has_block_cursor); // selections/block cursor and 0 everywhere else.
float is_special_cell = cell_has_block_cursor + float(is_selected & ONE);
#ifndef SPECIAL
is_special_cell += float(colors[bg_index] & BYTE_MASK) + float(is_reversed);
#endif
bg_alpha = step(0.5, is_special_cell);
#ifndef SPECIAL
bg_alpha = bg_alpha + (1.0f - bg_alpha) * background_opacity; bg_alpha = bg_alpha + (1.0f - bg_alpha) * background_opacity;
#endif #endif
#endif
#if defined(SPECIAL) || defined(SIMPLE) #if defined(SPECIAL) || defined(SIMPLE)
// Selection and cursor // Selection and cursor
bg = choose_color(float(is_selected & ONE), color_to_vec(highlight_bg), bg); bg = choose_color(float(is_selected & ONE), color_to_vec(highlight_bg), bg);
background = choose_color(cell_has_block_cursor, color_to_vec(cursor_color), bg); background = choose_color(cell_has_block_cursor, color_to_vec(cursor_color), bg);
#ifdef SPECIAL
// bg_alpha should be 1 if cursor/selection otherwise 0
bg_alpha = mix(0.0, 1.0, step(0.5, float(is_selected & ONE) + cell_has_block_cursor));
#endif
#endif #endif
#endif #endif