diff --git a/kitty/animation.h b/kitty/animation.h index 0f24ca5ac..275323b9c 100644 --- a/kitty/animation.h +++ b/kitty/animation.h @@ -15,6 +15,8 @@ typedef enum { EASING_STEP_START, EASING_STEP_END, EASING_STEP_NONE, EASING_STEP #ifndef ANIMATION_INTERNAL_API typedef struct {int x;} *Animation; #endif +#define EASE_IN_OUT 0.42, 0, 0.58, 1 +#define ANIMATION_SAMPLE_WAIT (50 * MONOTONIC_T_1e6) Animation* alloc_animation(void); double apply_easing_curve(const Animation *a, double t /* must be between 0 and 1*/, monotonic_t duration); bool animation_is_valid(const Animation *a); diff --git a/kitty/child-monitor.c b/kitty/child-monitor.c index a59ba6eb6..f0b0ceb5c 100644 --- a/kitty/child-monitor.c +++ b/kitty/child-monitor.c @@ -680,7 +680,7 @@ collect_cursor_info(CursorRenderInfo *ans, Window *w, monotonic_t now, OSWindow 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)); + set_maximum_wait(ANIMATION_SAMPLE_WAIT); } else { monotonic_t n = time_since_start_blink / OPT(cursor_blink_interval); ans->opacity = 1 - n % 2; @@ -802,9 +802,7 @@ render_prepared_os_window(OSWindow *os_window, unsigned int active_window_id, co if (w->visible && WD.screen) { bool is_active_window = i == tab->active_window; draw_cells(WD.vao_idx, &WD, os_window, is_active_window, false, num_of_visible_windows == 1, w); - if (WD.screen->start_visual_bell_at != 0) { - set_maximum_wait(OPT(repaint_delay)); - } + if (WD.screen->start_visual_bell_at != 0) set_maximum_wait(ANIMATION_SAMPLE_WAIT); w->cursor_opacity_at_last_render = WD.screen->cursor_render_info.opacity; w->last_cursor_shape = WD.screen->cursor_render_info.shape; } } diff --git a/kitty/shaders.c b/kitty/shaders.c index 74d2c5448..6af3ea1a2 100644 --- a/kitty/shaders.c +++ b/kitty/shaders.c @@ -982,8 +982,8 @@ get_visual_bell_intensity(Screen *screen) { if (!default_visual_bell_animation) { default_visual_bell_animation = alloc_animation(); if (!default_visual_bell_animation) fatal("Out of memory"); - add_cubic_bezier_animation(default_visual_bell_animation, 0, 1, 0.42, 0, 0.58, 1); - add_cubic_bezier_animation(default_visual_bell_animation, 1, 0, 0.42, 0, 0.58, 1); + add_cubic_bezier_animation(default_visual_bell_animation, 0, 1, EASE_IN_OUT); + add_cubic_bezier_animation(default_visual_bell_animation, 1, 0, EASE_IN_OUT); } const monotonic_t progress = monotonic() - screen->start_visual_bell_at; const monotonic_t duration = OPT(visual_bell_duration) / 2;