Commit: patch 9.2.0940: GTK4: columns are lost when a scrollbar appears

Christian Brabandt <[email protected]> Tue, 11 Aug 2026 21:30:07 +0200
Newsgroups gmane.editors.vim.devel
Message-ID <[email protected]>
patch 9.2.0940: GTK4: columns are lost when a scrollbar appears

Commit: https://github.com/vim/vim/commit/67eee0fc0d7e680ce0837f088e490c1c43258297
Author: Hirohito Higashi <[email protected]>
Date:   Tue Aug 11 19:21:08 2026 +0000

    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) <[email protected]>
    Signed-off-by: Hirohito Higashi <[email protected]>
    Signed-off-by: Foxe Chen <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/src/gui.h b/src/gui.h
index 5be8d0fd9..280215515 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 c2f2564e6..d128a6b99 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 195749d2a..e61092c66 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 6405f229e..5ea5c96e2 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,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/vim_dev/E1wtsAp-007aJU-IR%40256bit.org.