From 7622cbaed5376c9246b6cb62ee443dd5013d814e Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 29 Apr 2019 18:19:03 +0530 Subject: [PATCH] Avoid rapid transitions between the cells banner and the normal terminal view when live resizing on systems without live resizing notifications --- kitty/child-monitor.c | 7 ++++++- kitty/glfw.c | 1 + kitty/state.h | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/kitty/child-monitor.c b/kitty/child-monitor.c index ade021cca..e5f0a2eb7 100644 --- a/kitty/child-monitor.c +++ b/kitty/child-monitor.c @@ -831,7 +831,12 @@ process_pending_resizes(double now) { if (w->live_resize.from_os_notification) { if (w->live_resize.os_says_resize_complete || (now - w->live_resize.last_resize_event_at) > 1) update_viewport = true; } else { - if (now - w->live_resize.last_resize_event_at >= OPT(resize_debounce_time)) update_viewport = true; + double debounce_time = OPT(resize_debounce_time); + // if more than one resize event has occurred, wait at least 0.2 secs + // before repainting, to avoid rapid transitions between the cells banner + // and the normal screen + if (w->live_resize.num_of_resize_events > 1) debounce_time = MAX(0.2, debounce_time); + if (now - w->live_resize.last_resize_event_at >= debounce_time) update_viewport = true; else { global_state.has_pending_resizes = true; set_maximum_wait(OPT(resize_debounce_time) - now + w->live_resize.last_resize_event_at); diff --git a/kitty/glfw.c b/kitty/glfw.c index f2c9b643f..2f1317323 100644 --- a/kitty/glfw.c +++ b/kitty/glfw.c @@ -159,6 +159,7 @@ framebuffer_size_callback(GLFWwindow *w, int width, int height) { window->live_resize.in_progress = true; window->live_resize.last_resize_event_at = monotonic(); window->live_resize.width = MAX(0, width); window->live_resize.height = MAX(0, height); + window->live_resize.num_of_resize_events++; make_os_window_context_current(window); update_surface_size(width, height, window->offscreen_texture_id); request_tick_callback(); diff --git a/kitty/state.h b/kitty/state.h index 3a1278a1b..b58a5020f 100644 --- a/kitty/state.h +++ b/kitty/state.h @@ -113,7 +113,7 @@ typedef struct { bool in_progress; bool from_os_notification; bool os_says_resize_complete; - unsigned int width, height; + unsigned int width, height, num_of_resize_events; } LiveResizeInfo;