Skip to content

Commit 8ac4415

Browse files
committed
patch 8.0.1278: GUI window always resizes when adding scrollbar
Problem: GUI window always resizes when adding/removing a scrollbar, toolbar, etc. Solution: Add the 'k' flag in 'guioptions' to keep the GUI window size and change the number of lines/columns instead. (Ychin, closes #703)
1 parent 26d205d commit 8ac4415

6 files changed

Lines changed: 26 additions & 12 deletions

File tree

runtime/doc/options.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3939,7 +3939,13 @@ A jump table for the options with a short description can be found at |Q_op|.
39393939
removing it after the GUI has started has no effect.
39403940
*'go-F'*
39413941
'F' Add a footer. Only for Motif. See |gui-footer|.
3942-
3942+
*'go-k'*
3943+
'k' Keep the GUI window size when adding/removing a scrollbar, or
3944+
toolbar, tabline, etc. Instead, the behavior is similar to
3945+
when the window is maximized and will adjust 'lines' and
3946+
'columns' to fit to the window. Without the 'k' flag Vim will
3947+
try to keep 'lines' and 'columns the same when adding and
3948+
removing GUI components.
39433949

39443950
*'guipty'* *'noguipty'*
39453951
'guipty' boolean (default on)

src/gui.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ gui_init(void)
693693
#ifndef FEAT_GUI_GTK
694694
/* Set the shell size, adjusted for the screen size. For GTK this only
695695
* works after the shell has been opened, thus it is further down. */
696-
gui_set_shellsize(FALSE, TRUE, RESIZE_BOTH);
696+
gui_set_shellsize(TRUE, TRUE, RESIZE_BOTH);
697697
#endif
698698
#if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU)
699699
/* Need to set the size of the menubar after all the menus have been
@@ -732,7 +732,7 @@ gui_init(void)
732732
# endif
733733

734734
/* Now make sure the shell fits on the screen. */
735-
gui_set_shellsize(FALSE, TRUE, RESIZE_BOTH);
735+
gui_set_shellsize(TRUE, TRUE, RESIZE_BOTH);
736736
#endif
737737
/* When 'lines' was set while starting up the topframe may have to be
738738
* resized. */
@@ -909,7 +909,7 @@ gui_init_font(char_u *font_list, int fontset UNUSED)
909909
# endif
910910
gui_mch_set_font(gui.norm_font);
911911
#endif
912-
gui_set_shellsize(FALSE, TRUE, RESIZE_BOTH);
912+
gui_set_shellsize(TRUE, TRUE, RESIZE_BOTH);
913913
}
914914

915915
return ret;
@@ -1553,10 +1553,12 @@ gui_get_shellsize(void)
15531553
* Set the size of the Vim shell according to Rows and Columns.
15541554
* If "fit_to_display" is TRUE then the size may be reduced to fit the window
15551555
* on the screen.
1556+
* When "mustset" is TRUE the size was set by the user. When FALSE a UI
1557+
* component was added or removed (e.g., a scrollbar).
15561558
*/
15571559
void
15581560
gui_set_shellsize(
1559-
int mustset UNUSED, /* set by the user */
1561+
int mustset UNUSED,
15601562
int fit_to_display,
15611563
int direction) /* RESIZE_HOR, RESIZE_VER */
15621564
{
@@ -1580,7 +1582,8 @@ gui_set_shellsize(
15801582
#if defined(MSWIN) || defined(FEAT_GUI_GTK)
15811583
/* If not setting to a user specified size and maximized, calculate the
15821584
* number of characters that fit in the maximized window. */
1583-
if (!mustset && gui_mch_maximized())
1585+
if (!mustset && (vim_strchr(p_go, GO_KEEPWINSIZE) != NULL
1586+
|| gui_mch_maximized()))
15841587
{
15851588
gui_mch_newfont();
15861589
return;

src/gui_gtk_x11.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2938,7 +2938,7 @@ mainwin_screen_changed_cb(GtkWidget *widget,
29382938
if (gui.norm_font != NULL)
29392939
{
29402940
gui_mch_init_font(p_guifont, FALSE);
2941-
gui_set_shellsize(FALSE, FALSE, RESIZE_BOTH);
2941+
gui_set_shellsize(TRUE, FALSE, RESIZE_BOTH);
29422942
}
29432943
}
29442944

@@ -4909,8 +4909,9 @@ gui_mch_unmaximize(void)
49094909
}
49104910

49114911
/*
4912-
* Called when the font changed while the window is maximized. Compute the
4913-
* new Rows and Columns. This is like resizing the window.
4912+
* Called when the font changed while the window is maximized or GO_KEEPWINSIZE
4913+
* is set. Compute the new Rows and Columns. This is like resizing the
4914+
* window.
49144915
*/
49154916
void
49164917
gui_mch_newfont(void)

src/gui_w32.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3385,8 +3385,9 @@ gui_mch_maximized(void)
33853385
}
33863386

33873387
/*
3388-
* Called when the font changed while the window is maximized. Compute the
3389-
* new Rows and Columns. This is like resizing the window.
3388+
* Called when the font changed while the window is maximized or GO_KEEPWINSIZE
3389+
* is set. Compute the new Rows and Columns. This is like resizing the
3390+
* window.
33903391
*/
33913392
void
33923393
gui_mch_newfont(void)

src/option.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,8 @@
235235
#define GO_TOOLBAR 'T' /* add toolbar */
236236
#define GO_FOOTER 'F' /* add footer */
237237
#define GO_VERTICAL 'v' /* arrange dialog buttons vertically */
238-
#define GO_ALL "aAbcefFghilmMprtTv" /* all possible flags for 'go' */
238+
#define GO_KEEPWINSIZE 'k' /* keep GUI window size */
239+
#define GO_ALL "aAbcefFghilmMprtTvk" /* all possible flags for 'go' */
239240

240241
/* flags for 'comments' option */
241242
#define COM_NEST 'n' /* comments strings nest */

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,8 @@ static char *(features[]) =
761761

762762
static int included_patches[] =
763763
{ /* Add new patch number below this line */
764+
/**/
765+
1278,
764766
/**/
765767
1277,
766768
/**/

0 commit comments

Comments
 (0)