From 942cbea4b572142ad17845753edb7436e20ecfb5 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 19 Jul 2024 08:58:24 +0530 Subject: [PATCH] Fix rendering of semi-transparent cursors --- kitty/cell_fragment.glsl | 2 +- kitty/cell_vertex.glsl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kitty/cell_fragment.glsl b/kitty/cell_fragment.glsl index 5006f4424..eb9d6ae22 100644 --- a/kitty/cell_fragment.glsl +++ b/kitty/cell_fragment.glsl @@ -134,7 +134,7 @@ vec4 calculate_premul_foreground_from_sprites(vec4 text_fg) { float combined_alpha = min(text_fg.a + strike_alpha, 1.0f); // Underline color might be different, so alpha blend vec4 ans = alpha_blend(vec4(text_fg.rgb, combined_alpha * effective_text_alpha), vec4(decoration_fg, underline_alpha * effective_text_alpha)); - return mix(ans, cursor_color_premult, cursor_alpha); + return mix(ans, cursor_color_premult, cursor_alpha * cursor_color_premult.a); } vec4 adjust_foreground_contrast_with_background(vec4 text_fg, vec3 bg) { diff --git a/kitty/cell_vertex.glsl b/kitty/cell_vertex.glsl index b794dd371..d12345c7a 100644 --- a/kitty/cell_vertex.glsl +++ b/kitty/cell_vertex.glsl @@ -186,7 +186,7 @@ void main() { // Cursor cursor_color_premult = vec4(color_to_vec(cursor_bg) * cursor_opacity, cursor_opacity); - vec3 final_cursor_text_color = color_to_vec(cursor_fg); + vec3 final_cursor_text_color = mix(foreground, color_to_vec(cursor_fg), cursor_opacity); foreground = choose_color(cell_data.has_block_cursor, final_cursor_text_color, foreground); decoration_fg = choose_color(cell_data.has_block_cursor, final_cursor_text_color, decoration_fg); cursor_pos = to_sprite_pos(cell_data.pos, cursor_fg_sprite_idx * uint(cell_data.has_cursor), ZERO, ZERO);