From ec28187f6f5b4db6c2e23e95a322be512ddb5b95 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 16 Nov 2026 07:45:22 +0530 Subject: [PATCH] Fix newly displayed images sometimes not being rendered until the next redraw prepare_to_render_os_window() decided whether a window needs to be rendered in layers before calling send_cell_data_to_gpu(), which is what updates the graphics layers. So on the frame in which an image first becomes visible grman_has_images() returned a stale false, the window was rendered without the image, and if nothing else triggered a redraw (for example, the cursor is hidden so not blinking) the image did not appear until some unrelated event such as mouse movement. Fixes #10875 --- docs/changelog.rst | 4 ++++ kitty/child-monitor.c | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 89ea5c846..cea639189 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -168,6 +168,10 @@ Detailed list of changes :code:`--base-dir` into account, and file name completion is relative to that directory (:pull:`10851`, :pull:`10852`, :disc:`10867`) +- Graphics protocol: Fix a newly displayed image sometimes not being rendered + until something else, such as mouse movement, causes the window to be redrawn + (:iss:`10875`) + - Fix the scrolled back view jumping, and images, the cursor and the scrollbar getting out of sync with the text, when new output arrives (:pull:`10841`, :pull:`10847`) diff --git a/kitty/child-monitor.c b/kitty/child-monitor.c index e1d60e614..e4d82b52f 100644 --- a/kitty/child-monitor.c +++ b/kitty/child-monitor.c @@ -946,7 +946,6 @@ prepare_to_render_os_window( Window *w = tab->windows + i; #define WD w->render_data if (w->visible && WD.screen) { - os_window->needs_layers = os_window->needs_layers || screen_needs_rendering_in_layers(os_window, w, WD.screen); screen_check_pause_rendering(WD.screen, now); *num_visible_windows += 1; color_type window_bg = @@ -1037,6 +1036,10 @@ prepare_to_render_os_window( } } if (send_cell_data_to_gpu(WD.vao_idx, WD.screen, os_window)) needs_render = true; + // Must be after send_cell_data_to_gpu() as that updates the graphics layers, which + // determine whether there are images that need rendering in layers. Otherwise, a newly + // placed image is not drawn until something else causes a re-render, see #10875 + os_window->needs_layers = os_window->needs_layers || screen_needs_rendering_in_layers(os_window, w, WD.screen); if (WD.screen->start_visual_bell_at | WD.screen->start_drag_overlay_at) needs_render = true; if (OPT(progress_bar) != PROGRESS_BAR_HIDDEN && WD.screen->progress_state == PROGRESS_STATE_INDETERMINATE) needs_render = true; // Prepare window title bar screen data for GPU