From: Hirohito Higashi Date: Tue, 11 Aug 2026 19:21:08 +0000 (+0000) Subject: patch 9.2.0940: GTK4: columns are lost when a scrollbar appears X-Git-Tag: v9.2.0940^0 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=67eee0fc0d7e680ce0837f088e490c1c43258297;p=thirdparty%2Fvim.git patch 9.2.0940: GTK4: columns are lost when a scrollbar appears Problem: With the GTK4 GUI the shell loses columns every time a window is split, so that the text area keeps getting narrower. Solution: Ignore a size allocation that was computed before the size that was last asked for, instead of computing Rows and Columns from the old size together with the new base size. closes: #21006 Co-Authored-By: Claude Opus 5 (1M context) Signed-off-by: Hirohito Higashi Signed-off-by: Foxe Chen Signed-off-by: Christian Brabandt --- diff --git a/src/gui.h b/src/gui.h index 5be8d0fd9b..280215515b 100644 --- a/src/gui.h +++ b/src/gui.h @@ -505,6 +505,13 @@ typedef struct Gui #if defined(FEAT_GUI_GTK) && defined(USE_GTK4) int decor_height; + // Size of the form widget last asked for with gui_mch_set_shellsize(). + // "pending_form_skip" counts how many allocations that do not answer it + // may still be ignored. + int pending_form_w; + int pending_form_h; + int pending_form_skip; + // Used for clipboard functionality in GTK4 GUI GdkContentProvider *regular_provider; GdkContentProvider *primary_provider; diff --git a/src/gui_gtk4.c b/src/gui_gtk4.c index c2f2564e6f..d128a6b999 100644 --- a/src/gui_gtk4.c +++ b/src/gui_gtk4.c @@ -959,6 +959,13 @@ gui_mch_set_shellsize(int width, int height, int base_width UNUSED, int base_height UNUSED, int direction UNUSED) { + // Remember the size the form widget is supposed to get. An allocation + // that arrives before the compositor has answered this request still has + // the previous size and must not be used. + gui.pending_form_w = width; + gui.pending_form_h = height; + gui.pending_form_skip = 1; + width += get_menu_tool_width(); height += get_menu_tool_height(); diff --git a/src/gui_gtk4_f.c b/src/gui_gtk4_f.c index 195749d2a5..e61092c669 100644 --- a/src/gui_gtk4_f.c +++ b/src/gui_gtk4_f.c @@ -216,7 +216,21 @@ vim_form_resize_idle_cb(VimForm *self) goto exit; if (self->last_width > 1 && self->last_height > 1) + { + // Ignore an allocation that does not answer the size that was last + // asked for: it was computed before the request and using it would + // compute Rows and Columns from the old size together with the new + // base size, losing columns. Give up after one allocation in case + // the request is never answered exactly. + if (gui.pending_form_w > 0 + && (self->last_width != gui.pending_form_w + || self->last_height != gui.pending_form_h) + && --gui.pending_form_skip >= 0) + goto exit; + + gui.pending_form_w = 0; gui_resize_shell(self->last_width, self->last_height); + } exit: g_object_unref(self); diff --git a/src/version.c b/src/version.c index 6405f229e6..5ea5c96e22 100644 --- a/src/version.c +++ b/src/version.c @@ -763,6 +763,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 940, /**/ 939, /**/