Gtk-X11, gui.num_rows, window height and font height
Scott Dillard <sedillard <at> ucdavis.edu>
2008-02-02 18:45:02 GMT
This is in regards to an old bug report from 2004:
At the time, the problem was dismissed as the window manager's
(metacity) fault, but I don't think this is the case. The code in
question is this part of src/gui.c, ~line 1296 (from vim-7.1.tar.bz,
downloaded from the website)
gui.num_rows = (pixel_height - gui_get_base_height()
#if !defined(FEAT_GUI_PHOTON) && !defined(FEAT_GUI_MSWIN)
+ (gui.char_height / 2)
) / gui.char_height;
I experience this behavior, where the bottom line of text is cut-off,
because gui.num_rows is over-estimated. But my window manager
(metacity, gnome 2.18.1) is correctly reporting the window height.
When I put gvim in fullscreen mode, pixel_height has the correct value
of 1024. The function gui_get_base_height() gives a value of 4,
because in src/gui_gtk_x11.c, line 3437, the field gui.border_width is
initialized to 2, and gui_get_base_height() doubles this. Why is that?
What is the "border width"? When I run gvim in full screen, I can't
see any border -- gvim has use of all 1280x1024 pixels. But setting
this initial value to 0 still does not solve the problem. The only
other value affecting this expression in gui.char_height, which
appears to be set using information from pango, not metacity. So I
don't think this is metacity's fault.
In between the #if..#endif you add half a character's worth of height.
Why is that? If I take this out, as Tony Houghton did originally, the
problem is fixed. It seems to me that you want the quotient (pixels /
char_height) to be consistently rounded down, to take the floor of it.
Rounding to the nearest integer is not the right thing to do.
I realize this is something of a heisenbug. It will or will not happen
depending on your screen resolution, and which font you use. But I'm
just wondering about these things: Why is gui.border_width initialized
to 2, why is a half-character of height added to the expression, and
what role does the window manager play in all this? Also I don't
really know the vim sources inside and out, so if I'm missing
something please let me know.
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php