[vim/vim] GTK4: window opens two lines too small (PR #21045)
h_east (Vim Github Repository) <[email protected]>
| Newsgroups | gmane.editors.vim.devel |
|---|---|
| Message-ID | <vim/vim/pull/[email protected]> |
```
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 --
* GTK4: window opens two lines too small
-- File Changes --
M src/gui_gtk4.c (54)
M src/gui_gtk4_f.c (14)
-- Patch Links --
https://github.com/vim/vim/pull/21045.patch
https://github.com/vim/vim/pull/21045.diff
--
Reply to this email directly or view it on GitHub:
https://github.com/vim/vim/pull/21045
You are receiving this because you are subscribed to this thread.
Message ID: <vim/vim/pull/[email protected]>
--
--
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/vim/vim/pull/21045%40github.com.