summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-12-05 20:31:07 +0100
committerBram Moolenaar <Bram@vim.org>2017-12-05 20:31:07 +0100
commit415a6939a4e8d4e26b4af26c24eb75243d3a2756 (patch)
treeb282dacb3270498516e2cc937658bb931216b120
parent5fe6bdf858a7f2f288d599ffb5efb3c08449c817 (diff)
downloadvim-415a6939a4e8d4e26b4af26c24eb75243d3a2756.zip
patch 8.0.1375: window size wrong after maximizing with WinBar
Problem: Window size wrong after maximizing with WinBar. (Lifepillar) Solution: Fix height computations. Redraw window when it is zero height but has a WinBar. (closes #2356)
-rw-r--r--src/screen.c2
-rw-r--r--src/version.c2
-rw-r--r--src/vim.h2
-rw-r--r--src/window.c37
4 files changed, 28 insertions, 15 deletions
diff --git a/src/screen.c b/src/screen.c
index 4d277e3c8..a74f75071 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -1154,7 +1154,7 @@ win_update(win_T *wp)
}
/* Window is zero-height: nothing to draw. */
- if (wp->w_height == 0)
+ if (wp->w_height + WINBAR_HEIGHT(wp) == 0)
{
wp->w_redr_type = 0;
return;
diff --git a/src/version.c b/src/version.c
index 9df11cc26..c41aed0d6 100644
--- a/src/version.c
+++ b/src/version.c
@@ -772,6 +772,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1375,
+/**/
1374,
/**/
1373,
diff --git a/src/vim.h b/src/vim.h
index bf6c3d3ff..b43c210a6 100644
--- a/src/vim.h
+++ b/src/vim.h
@@ -1478,8 +1478,10 @@ typedef UINT32_TYPEDEF UINT32_T;
#define STATUS_HEIGHT 1 /* height of a status line under a window */
#ifdef FEAT_MENU /* height of a status line under a window */
# define WINBAR_HEIGHT(wp) (wp)->w_winbar_height
+# define VISIBLE_HEIGHT(wp) ((wp)->w_height + (wp)->w_winbar_height)
#else
# define WINBAR_HEIGHT(wp) 0
+# define VISIBLE_HEIGHT(wp) (wp)->w_height
#endif
#define QF_WINHEIGHT 10 /* default height for quickfix window */
diff --git a/src/window.c b/src/window.c
index 7d58c8a60..ffe4e38f8 100644
--- a/src/window.c
+++ b/src/window.c
@@ -782,7 +782,7 @@ win_split_ins(
/* add a status line when p_ls == 1 and splitting the first window */
if (ONE_WINDOW && p_ls == 1 && oldwin->w_status_height == 0)
{
- if (oldwin->w_height <= p_wmh && new_wp == NULL)
+ if (VISIBLE_HEIGHT(oldwin) <= p_wmh && new_wp == NULL)
{
EMSG(_(e_noroom));
return FAIL;
@@ -892,7 +892,7 @@ win_split_ins(
* height.
*/
/* Current window requires at least 1 space. */
- wmh1 = (p_wmh == 0 ? 1 : p_wmh);
+ wmh1 = (p_wmh == 0 ? 1 : p_wmh) + WINBAR_HEIGHT(curwin);
needed = wmh1 + STATUS_HEIGHT;
if (flags & WSP_ROOM)
needed += p_wh - wmh1;
@@ -1105,7 +1105,7 @@ win_split_ins(
{
/* height and row of new window is same as current window */
wp->w_winrow = oldwin->w_winrow;
- win_new_height(wp, oldwin->w_height + WINBAR_HEIGHT(oldwin));
+ win_new_height(wp, VISIBLE_HEIGHT(oldwin));
wp->w_status_height = oldwin->w_status_height;
}
frp->fr_height = curfrp->fr_height;
@@ -1180,8 +1180,8 @@ win_split_ins(
}
else /* new window below current one */
{
- wp->w_winrow = oldwin->w_winrow + oldwin->w_height
- + STATUS_HEIGHT + WINBAR_HEIGHT(oldwin);
+ wp->w_winrow = oldwin->w_winrow + VISIBLE_HEIGHT(oldwin)
+ + STATUS_HEIGHT;
wp->w_status_height = oldwin->w_status_height;
if (!(flags & WSP_BOT))
oldwin->w_status_height = STATUS_HEIGHT;
@@ -1422,7 +1422,7 @@ make_windows(
else
{
/* Each window needs at least 'winminheight' lines and a status line. */
- maxcount = (curwin->w_height + curwin->w_status_height
+ maxcount = (VISIBLE_HEIGHT(curwin) + curwin->w_status_height
- (p_wh - p_wmh)) / (p_wmh + STATUS_HEIGHT);
}
@@ -3204,8 +3204,7 @@ frame_fix_width(win_T *wp)
static void
frame_fix_height(win_T *wp)
{
- wp->w_frame->fr_height = wp->w_height + wp->w_status_height
- + WINBAR_HEIGHT(wp) ;
+ wp->w_frame->fr_height = VISIBLE_HEIGHT(wp) + wp->w_status_height;
}
/*
@@ -3230,9 +3229,14 @@ frame_minheight(frame_T *topfrp, win_T *next_curwin)
{
/* window: minimal height of the window plus status line */
m = p_wmh + topfrp->fr_win->w_status_height;
- /* Current window is minimal one line high */
- if (p_wmh == 0 && topfrp->fr_win == curwin && next_curwin == NULL)
- ++m;
+ if (topfrp->fr_win == curwin && next_curwin == NULL)
+ {
+ /* Current window is minimal one line high and WinBar is
+ * visible. */
+ if (p_wmh == 0)
+ ++m;
+ m += WINBAR_HEIGHT(curwin);
+ }
}
}
else if (topfrp->fr_layout == FR_ROW)
@@ -4972,6 +4976,7 @@ frame_comp_pos(frame_T *topfrp, int *row, int *col)
frame_T *frp;
int startcol;
int startrow;
+ int h;
wp = topfrp->fr_win;
if (wp != NULL)
@@ -4984,7 +4989,9 @@ frame_comp_pos(frame_T *topfrp, int *row, int *col)
redraw_win_later(wp, NOT_VALID);
wp->w_redr_status = TRUE;
}
- *row += wp->w_height + wp->w_status_height;
+ /* WinBar will not show if the window height is zero */
+ h = VISIBLE_HEIGHT(wp) + wp->w_status_height;
+ *row += h > topfrp->fr_height ? topfrp->fr_height : h;
*col += wp->w_width + wp->w_vsep_width;
}
else
@@ -5029,6 +5036,7 @@ win_setheight_win(int height, win_T *win)
height = p_wmh;
if (height == 0)
height = 1;
+ height += WINBAR_HEIGHT(curwin);
}
frame_setheight(win->w_frame, height + win->w_status_height);
@@ -5126,7 +5134,8 @@ frame_setheight(frame_T *curfrp, int height)
else
{
room_cmdline = Rows - p_ch - (lastwin->w_winrow
- + lastwin->w_height + lastwin->w_status_height);
+ + VISIBLE_HEIGHT(lastwin)
+ + lastwin->w_status_height);
if (room_cmdline < 0)
room_cmdline = 0;
}
@@ -5415,7 +5424,7 @@ win_setminheight(void)
/* TODO: handle vertical splits */
room = -p_wh;
FOR_ALL_WINDOWS(wp)
- room += wp->w_height - p_wmh;
+ room += VISIBLE_HEIGHT(wp) - p_wmh;
if (room >= 0)
break;
--p_wmh;