From a720ef691730dafd7a3e531a8a453f3236608934 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 24 May 2023 15:18:58 +0530 Subject: [PATCH] Graphics: Move images up along with text when the window is shrunk vertically Fixes #6278 --- docs/changelog.rst | 2 ++ kitty/graphics.c | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index d6599827b..00e9fbdf3 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -67,6 +67,8 @@ Detailed list of changes - ssh kitten: Fix a regression in 0.28.0 that caused interrupt during setup to not be handled gracefully (:iss:`6254`) +- Graphics: Move images up along with text when the window is shrunk vertically (:iss:`6278`) + 0.28.1 [2023-04-21] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/kitty/graphics.c b/kitty/graphics.c index 868bc9b55..542ae6413 100644 --- a/kitty/graphics.c +++ b/kitty/graphics.c @@ -1791,8 +1791,20 @@ handle_delete_command(GraphicsManager *self, const GraphicsCommand *g, Cursor *c // }}} void -grman_resize(GraphicsManager *self, index_type UNUSED old_lines, index_type UNUSED lines, index_type UNUSED old_columns, index_type UNUSED columns) { +grman_resize(GraphicsManager *self, index_type old_lines, index_type lines, index_type old_columns, index_type columns) { + ImageRef *ref; Image *img; self->layers_dirty = true; + if (columns == old_columns && old_lines > lines) { + const unsigned int vertical_shrink_size = old_lines - lines; + for (size_t i = self->image_count; i-- > 0;) { + img = self->images + i; + for (size_t j = img->refcnt; j-- > 0;) { + ref = img->refs + j; + if (ref->is_virtual_ref || ref->is_cell_image) continue; + ref->start_row -= vertical_shrink_size; + } + } + } } void