]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0940: GTK4: columns are lost when a scrollbar appears v9.2.0940
authorHirohito Higashi <h.east.727@gmail.com>
Tue, 11 Aug 2026 19:21:08 +0000 (19:21 +0000)
committerChristian Brabandt <cb@256bit.org>
Tue, 11 Aug 2026 19:21:08 +0000 (19:21 +0000)
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) <noreply@anthropic.com>
Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Foxe Chen <chen.foxe@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/gui.h
src/gui_gtk4.c
src/gui_gtk4_f.c
src/version.c

index 5be8d0fd9b7818493961965cd25c64f6c8189e95..280215515b7fe0ed2830b1cbcf12940a7a50153c 100644 (file)
--- 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;
index c2f2564e6f64ae8d55545c8a5ad2c12bb0f73199..d128a6b9999201427d3b49ba7622d20d6c310f83 100644 (file)
@@ -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();
 
index 195749d2a52b59ccc76b755fe962c4935e0e5239..e61092c669657c6af07bc5937902b4831c8ff340 100644 (file)
@@ -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);
index 6405f229e6b03ac11828a90b463762bed4a9d5a5..5ea5c96e229e36e308705187e8c08ef5a766afeb 100644 (file)
@@ -763,6 +763,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    940,
 /**/
     939,
 /**/