[vim/vim] GTK4: window opens two lines too small (PR #21045)

1 view
Skip to first unread message

h_east

unread,
Aug 13, 2026, 9:52:47 PM (2 days ago) Aug 13
to vim/vim, Subscribed
Problem:  On startup the GUI window is the height of the window decorations
          too small, so it shows two lines less than 'lines'.  It only gets
          the right size after the first pointer event.
Solution: Also request the shell size on the form widget, so that GTK derives
          the window height from it with the decorations included.  Drop the
          request again once the size was given, so that the window can still
          be made smaller.

related: #21021


related: #21016

What was confirmed while working on this:

  • The second gtk_window_set_default_size() in gui_mch_open() cannot do
    anything. gui.decor_height is still 0 at that point, so it asks for the
    same size as the call made before gtk_window_present(). The property does
    not change, so no resize is queued.
  • A gtk_window_set_default_size() made right after gtk_window_present() is
    dropped for about 600 to 740 msec here. Retrying every 20 msec and retrying
    every 100 msec end at the same time, so it does not depend on how often it
    is asked. gtk_widget_queue_resize() on the window does not help either.
  • Once startup has settled, :set lines and :set columns resize the window
    through gtk_window_set_default_size() as expected. The problem is limited
    to the window right after it was presented.
  • Blocking in the main loop until the window has the size does work, but it
    costs about half a second of startup time, so it is not an option.
  • A size request on the form widget is honoured in that window, and GTK
    derives the window height from it with the decorations included. So
    gui.decor_height is not needed to get the first size right.
  • The width cannot be left to the content. The natural width of the toolbar is
    wider than what Vim asks for (762 px against 654 px here, about 13 columns),
    so the window would open too wide. That is why the size is still set on the
    window as well.
  • The size request has to be dropped again, otherwise the window cannot be
    made smaller than the size Vim asked for. Dropping it when the form widget
    has been given the size works, but set_form_size() must do nothing when
    the form already has that size: no allocation would follow and the request
    would stay. gui_init() calls gui_set_shellsize() with the same size right
    after gui_mch_open(), so this happens on every startup.

Tested: starts with 80x24, +"set columns=120" opens with 120 columns,
:set lines and :set columns work in both directions, the window can be
resized with the mouse in every direction right after startup.


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/21045

Commit Summary

  • 1c92c29 GTK4: window opens two lines too small

File Changes

(2 files)

Patch Links:


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/21045@github.com>

h_east

unread,
Aug 13, 2026, 9:54:24 PM (2 days ago) Aug 13
to vim/vim, Subscribed
h-east left a comment (vim/vim#21045)

@64-bitman
I was originally planning to leave this to you, but I was curious myself and did some trial and error. After gathering various facts and reaching a better state than the current implementation, I've opened a PR. Could you review it? If you already have a solution that you're satisfied with, I'm happy to withdraw this PR.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/21045/c5288505607@github.com>

Reply all
Reply to author
Forward
0 new messages