diff --git a/kitty/animation.c b/kitty/animation.c index d5bb1487c..e4717ac51 100644 --- a/kitty/animation.c +++ b/kitty/animation.c @@ -159,7 +159,7 @@ cubic_bezier_easing_curve(void *p_, double t, monotonic_t duration) { BezierParameters *p = p_; // The longer the animation, the more precision we need double epsilon = 1.0 / monotonic_t_to_ms(duration); - return solve_unit_bezier(p, t, epsilon); + return fabs(solve_unit_bezier(p, t, epsilon)); } // }}} @@ -180,8 +180,8 @@ apply_easing_curve(const Animation *a, double val, monotonic_t duration) { size_t idx = MIN((size_t)(val * a->count), a->count - 1); animation_function *f = a->functions + idx; double interval_size = 1. / a->count, interval_start = idx * interval_size; - val = (val - interval_start) / interval_size; - double ans = f->curve(&f->params, val, duration); + double scaled_val = (val - interval_start) / interval_size; + double ans = f->curve(&f->params, scaled_val, duration); return f->y_at_start + unit_value(ans) * f->y_size; } diff --git a/kitty/child-monitor.c b/kitty/child-monitor.c index a2cd9b2fb..a59ba6eb6 100644 --- a/kitty/child-monitor.c +++ b/kitty/child-monitor.c @@ -676,14 +676,14 @@ collect_cursor_info(CursorRenderInfo *ans, Window *w, monotonic_t now, OSWindow ans->opacity = 1; if (cursor_blinking) { if (animation_is_valid(OPT(animation.cursor))) { - monotonic_t den = OPT(cursor_blink_interval) * 2; - monotonic_t time_into_cycle = time_since_start_blink % den; - double frac_into_cycle = (double)time_into_cycle / (double)den; - ans->opacity = (float)apply_easing_curve(OPT(animation.cursor), frac_into_cycle, den); - set_maximum_wait(ms_to_monotonic_t(75)); + monotonic_t duration = OPT(cursor_blink_interval) * 2; + monotonic_t time_into_cycle = time_since_start_blink % duration; + double frac_into_cycle = (double)time_into_cycle / (double)duration; + ans->opacity = (float)apply_easing_curve(OPT(animation.cursor), frac_into_cycle, duration); + set_maximum_wait(ms_to_monotonic_t(50)); } else { monotonic_t n = time_since_start_blink / OPT(cursor_blink_interval); - ans->opacity = n % 2 == 0 ? 1 : 0; + ans->opacity = 1 - n % 2; set_maximum_wait((n + 1) * OPT(cursor_blink_interval) - time_since_start_blink); } }