diff --git a/kitty/cursor_trail.c b/kitty/cursor_trail.c index abe4f441a..429597eab 100644 --- a/kitty/cursor_trail.c +++ b/kitty/cursor_trail.c @@ -12,6 +12,7 @@ get_cursor_edge(float *left, float *right, float *top, float *bottom, Window *w) *bottom = WD.ystart - (WD.screen->cursor_render_info.y + 1) * WD.dy; switch (WD.screen->cursor->shape) { case CURSOR_BLOCK: + case CURSOR_HOLLOW: *right = *left + WD.dx; *top = *bottom + WD.dy; return true; @@ -23,8 +24,6 @@ get_cursor_edge(float *left, float *right, float *top, float *bottom, Window *w) *right = *left + WD.dx; *top = *bottom + WD.dy / WD.screen->cell_size.height * OPT(cursor_underline_thickness); return true; - case CURSOR_HOLLOW: - // TODO - implement default: return false; } @@ -49,7 +48,7 @@ update_cursor_trail(CursorTrail *ct, Window *w, monotonic_t now) { // todo - make these configurable // the decay time for the trail to reach 1/1024 of its distance from the cursor corner float decay_fast = 0.10f; - float decay_slow = 0.80f; + float decay_slow = 0.30f; if (OPT(input_delay) < now - WD.screen->cursor->updated_at && ct->updated_at < now) { float cursor_center_x = (ct->cursor_edge_x[0] + ct->cursor_edge_x[1]) * 0.5f; float cursor_center_y = (ct->cursor_edge_y[0] + ct->cursor_edge_y[1]) * 0.5f; @@ -87,6 +86,12 @@ update_cursor_trail(CursorTrail *ct, Window *w, monotonic_t now) { break; } } + + if (ct->needs_render) { + ColorProfile *cp = WD.screen->color_profile; + ct->color = colorprofile_to_color(cp, cp->overridden.cursor_color, cp->configured.cursor_color).rgb; + } + #undef WD // returning true here will cause the cells to be drawn return ct->needs_render || needs_render_prev; diff --git a/kitty/shaders.c b/kitty/shaders.c index da8c2614e..38a5cc3ab 100644 --- a/kitty/shaders.c +++ b/kitty/shaders.c @@ -1146,8 +1146,6 @@ init_trail_program(void) { void draw_cursor_trail(CursorTrail *trail) { - glEnable(GL_BLEND); - BLEND_ONTO_OPAQUE; bind_program(TRAIL_PROGRAM); glUniform4fv(trail_program_layout.uniforms.x_coords, 1, trail->corner_x); @@ -1156,13 +1154,10 @@ draw_cursor_trail(CursorTrail *trail) { glUniform2fv(trail_program_layout.uniforms.cursor_edge_x, 1, trail->cursor_edge_x); glUniform2fv(trail_program_layout.uniforms.cursor_edge_y, 1, trail->cursor_edge_y); - // todo - get cursor color from opt - float trail_color[4] = {1.0f, 1.0f, 1.0f, 1.0f}; - glUniform4fv(trail_program_layout.uniforms.trail_color, 1, trail_color); + color_vec3(trail_program_layout.uniforms.trail_color, trail->color); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); - glDisable(GL_BLEND); unbind_program(); } diff --git a/kitty/state.h b/kitty/state.h index ae6f83b1a..b9d487c7c 100644 --- a/kitty/state.h +++ b/kitty/state.h @@ -213,8 +213,9 @@ typedef struct { } BorderRects; typedef struct { - monotonic_t updated_at; bool needs_render; + monotonic_t updated_at; + color_type color; float corner_x[4]; float corner_y[4]; float cursor_edge_x[2]; diff --git a/kitty/trail_fragment.glsl b/kitty/trail_fragment.glsl index 5f64ee230..b9dadb866 100644 --- a/kitty/trail_fragment.glsl +++ b/kitty/trail_fragment.glsl @@ -1,6 +1,7 @@ uniform vec2 cursor_edge_x; uniform vec2 cursor_edge_y; -uniform vec4 trail_color; +uniform vec3 trail_color; + in vec2 frag_pos; out vec4 final_color; @@ -9,6 +10,6 @@ void main() { cursor_edge_y[1] <= frag_pos.y && frag_pos.y <= cursor_edge_y[0]) { discard; } else { - final_color = trail_color; + final_color = vec4(trail_color, 1.0); } }