Skip to content

Commit 7622cba

Browse files
committed
Avoid rapid transitions between the cells banner and the normal terminal view when live resizing on systems without live resizing notifications
1 parent 53df123 commit 7622cba

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

kitty/child-monitor.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,12 @@ process_pending_resizes(double now) {
831831
if (w->live_resize.from_os_notification) {
832832
if (w->live_resize.os_says_resize_complete || (now - w->live_resize.last_resize_event_at) > 1) update_viewport = true;
833833
} else {
834-
if (now - w->live_resize.last_resize_event_at >= OPT(resize_debounce_time)) update_viewport = true;
834+
double debounce_time = OPT(resize_debounce_time);
835+
// if more than one resize event has occurred, wait at least 0.2 secs
836+
// before repainting, to avoid rapid transitions between the cells banner
837+
// and the normal screen
838+
if (w->live_resize.num_of_resize_events > 1) debounce_time = MAX(0.2, debounce_time);
839+
if (now - w->live_resize.last_resize_event_at >= debounce_time) update_viewport = true;
835840
else {
836841
global_state.has_pending_resizes = true;
837842
set_maximum_wait(OPT(resize_debounce_time) - now + w->live_resize.last_resize_event_at);

kitty/glfw.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ framebuffer_size_callback(GLFWwindow *w, int width, int height) {
159159
window->live_resize.in_progress = true;
160160
window->live_resize.last_resize_event_at = monotonic();
161161
window->live_resize.width = MAX(0, width); window->live_resize.height = MAX(0, height);
162+
window->live_resize.num_of_resize_events++;
162163
make_os_window_context_current(window);
163164
update_surface_size(width, height, window->offscreen_texture_id);
164165
request_tick_callback();

kitty/state.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ typedef struct {
113113
bool in_progress;
114114
bool from_os_notification;
115115
bool os_says_resize_complete;
116-
unsigned int width, height;
116+
unsigned int width, height, num_of_resize_events;
117117
} LiveResizeInfo;
118118

119119

0 commit comments

Comments
 (0)