From faac8649e4b694a21b32a83667c3cabe228816ad Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 27 Mar 2018 10:46:26 +0530 Subject: [PATCH] Fix a regression that broke visual bell and invert screen colors escape code. Fixes #419 --- kitty/cell_vertex.glsl | 12 +++++------- kitty/screen.c | 3 ++- kitty/shaders.c | 6 ++---- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/kitty/cell_vertex.glsl b/kitty/cell_vertex.glsl index 09d89d12d..4cd5a1ea9 100644 --- a/kitty/cell_vertex.glsl +++ b/kitty/cell_vertex.glsl @@ -6,9 +6,7 @@ layout(std140) uniform CellRenderData { float xstart, ystart, dx, dy, sprite_dx, sprite_dy, background_opacity; - uint default_fg, default_bg, highlight_fg, highlight_bg, cursor_color, url_color, url_style; - - int color1, color2; + uint default_fg, default_bg, highlight_fg, highlight_bg, cursor_color, url_color, url_style, inverted; uint xnum, ynum, cursor_x, cursor_y, cursor_w; @@ -21,7 +19,7 @@ layout(location=1) in uvec4 sprite_coords; layout(location=2) in uint is_selected; - +const int fg_index_map[] = int[3](0, 1, 0); const uvec2 cell_pos_map[] = uvec2[4]( uvec2(1, 0), // right, top uvec2(1, 1), // right, bottom @@ -135,10 +133,10 @@ void main() { // set cell color indices {{{ uvec2 default_colors = uvec2(default_fg, default_bg); - ivec2 color_indices = ivec2(color1, color2); uint text_attrs = sprite_coords[3]; - int fg_index = color_indices[(text_attrs >> 6) & REVERSE_MASK]; - int bg_index = color_indices[1 - fg_index]; + uint is_inverted = ((text_attrs >> 6) & REVERSE_MASK) + inverted; + int fg_index = fg_index_map[is_inverted]; + int bg_index = 1 - fg_index; float cursor = is_cursor(c, r); vec3 bg = to_color(colors[bg_index], default_colors[bg_index]); // }}} diff --git a/kitty/screen.c b/kitty/screen.c index 9c55fb263..5bbe90b6c 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -1066,7 +1066,7 @@ bool screen_invert_colors(Screen *self) { bool inverted = false; if (self->start_visual_bell_at > 0) { - if (monotonic() - self->start_visual_bell_at <= global_state.opts.visual_bell_duration) inverted = true; + if (monotonic() - self->start_visual_bell_at <= OPT(visual_bell_duration)) inverted = true; else self->start_visual_bell_at = 0; } if (self->modes.mDECSCNM) inverted = inverted ? false : true; @@ -1076,6 +1076,7 @@ screen_invert_colors(Screen *self) { void screen_bell(Screen *self) { request_window_attention(self->window_id, OPT(enable_audio_bell)); + if (OPT(visual_bell_duration) > 0.0f) self->start_visual_bell_at = monotonic(); } void diff --git a/kitty/shaders.c b/kitty/shaders.c index dcae8356c..2d652de06 100644 --- a/kitty/shaders.c +++ b/kitty/shaders.c @@ -214,9 +214,7 @@ cell_update_uniform_block(ssize_t vao_idx, Screen *screen, int uniform_buffer, G struct CellRenderData { GLfloat xstart, ystart, dx, dy, sprite_dx, sprite_dy, background_opacity; - GLuint default_fg, default_bg, highlight_fg, highlight_bg, cursor_color, url_color, url_style; - - GLint color1, color2; + GLuint default_fg, default_bg, highlight_fg, highlight_bg, cursor_color, url_color, url_style, inverted; GLuint xnum, ynum, cursor_x, cursor_y, cursor_w; }; @@ -241,7 +239,7 @@ cell_update_uniform_block(ssize_t vao_idx, Screen *screen, int uniform_buffer, G unsigned int x, y, z; sprite_tracker_current_layout(&x, &y, &z); rd->sprite_dx = 1.0f / (float)x; rd->sprite_dy = 1.0f / (float)y; - rd->color1 = inverted & 1; rd->color2 = 1 - (inverted & 1); + rd->inverted = inverted ? 1 : 0; rd->background_opacity = OPT(background_opacity); #define COLOR(name) colorprofile_to_color(screen->color_profile, screen->color_profile->overridden.name, screen->color_profile->configured.name)