From 12c37c9df3ded28958ace59d21f1188b8b560245 Mon Sep 17 00:00:00 2001 From: Rick Choi Date: Sun, 27 Oct 2024 13:07:10 +0900 Subject: [PATCH] rename fn update_cursor_trail_corners t just update_cursor_trail_states now it also updates cursor_trail.needs_render in place, because it is also a feedback state. --- kitty/cursor_trail.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/kitty/cursor_trail.c b/kitty/cursor_trail.c index 62da6ee84..21cb3a1c2 100644 --- a/kitty/cursor_trail.c +++ b/kitty/cursor_trail.c @@ -62,8 +62,8 @@ should_skip_cursor_trail_update(CursorTrail *ct, Window *w, OSWindow *os_window) return false; } -static bool -update_cursor_trail_corners(CursorTrail *ct, Window *w, monotonic_t now, OSWindow *os_window) { +static void +update_cursor_trail_state(CursorTrail *ct, Window *w, monotonic_t now, OSWindow *os_window) { // the trail corners move towards the cursor corner at a speed proportional to their distance from the cursor corner. // equivalent to exponential ease out animation. static const int ci[4][2] = {{1, 0}, {1, 1}, {0, 1}, {0, 0}}; @@ -124,16 +124,17 @@ update_cursor_trail_corners(CursorTrail *ct, Window *w, monotonic_t now, OSWindo } ct->updated_at = now; + ct->needs_render = false; // check if any corner is still far from the cursor corner, so it should be rendered for (int i = 0; i < 4; ++i) { float dx = fabsf(EDGE(x, ci[i][0]) - ct->corner_x[i]); float dy = fabsf(EDGE(y, ci[i][1]) - ct->corner_y[i]); if (dx_threshold <= dx || dy_threshold <= dy) { - return true; + ct->needs_render = true; + break; } } - return false; } bool @@ -143,7 +144,7 @@ update_cursor_trail(CursorTrail *ct, Window *w, monotonic_t now, OSWindow *os_wi } bool needs_render_prev = ct->needs_render; - ct->needs_render = update_cursor_trail_corners(ct, w, now, os_window); + update_cursor_trail_state(ct, w, now, os_window); // returning true here will cause the cells to be drawn return ct->needs_render || needs_render_prev;