Mercurial > vim
comparison src/window.c @ 12998:dd734ee3e2fe v8.0.1375
patch 8.0.1375: window size wrong after maximizing with WinBar
commit https://github.com/vim/vim/commit/415a6939a4e8d4e26b4af26c24eb75243d3a2756
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Dec 5 20:31:07 2017 +0100
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)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 05 Dec 2017 20:45:05 +0100 |
parents | af2e0401eb8c |
children | 788d01164bb2 |
comparison
equal
deleted
inserted
replaced
12997:f0c85ce3dd06 | 12998:dd734ee3e2fe |
---|---|
780 oldwin = curwin; | 780 oldwin = curwin; |
781 | 781 |
782 /* add a status line when p_ls == 1 and splitting the first window */ | 782 /* add a status line when p_ls == 1 and splitting the first window */ |
783 if (ONE_WINDOW && p_ls == 1 && oldwin->w_status_height == 0) | 783 if (ONE_WINDOW && p_ls == 1 && oldwin->w_status_height == 0) |
784 { | 784 { |
785 if (oldwin->w_height <= p_wmh && new_wp == NULL) | 785 if (VISIBLE_HEIGHT(oldwin) <= p_wmh && new_wp == NULL) |
786 { | 786 { |
787 EMSG(_(e_noroom)); | 787 EMSG(_(e_noroom)); |
788 return FAIL; | 788 return FAIL; |
789 } | 789 } |
790 need_status = STATUS_HEIGHT; | 790 need_status = STATUS_HEIGHT; |
890 /* | 890 /* |
891 * Check if we are able to split the current window and compute its | 891 * Check if we are able to split the current window and compute its |
892 * height. | 892 * height. |
893 */ | 893 */ |
894 /* Current window requires at least 1 space. */ | 894 /* Current window requires at least 1 space. */ |
895 wmh1 = (p_wmh == 0 ? 1 : p_wmh); | 895 wmh1 = (p_wmh == 0 ? 1 : p_wmh) + WINBAR_HEIGHT(curwin); |
896 needed = wmh1 + STATUS_HEIGHT; | 896 needed = wmh1 + STATUS_HEIGHT; |
897 if (flags & WSP_ROOM) | 897 if (flags & WSP_ROOM) |
898 needed += p_wh - wmh1; | 898 needed += p_wh - wmh1; |
899 if (flags & (WSP_BOT | WSP_TOP)) | 899 if (flags & (WSP_BOT | WSP_TOP)) |
900 { | 900 { |
1103 } | 1103 } |
1104 else | 1104 else |
1105 { | 1105 { |
1106 /* height and row of new window is same as current window */ | 1106 /* height and row of new window is same as current window */ |
1107 wp->w_winrow = oldwin->w_winrow; | 1107 wp->w_winrow = oldwin->w_winrow; |
1108 win_new_height(wp, oldwin->w_height + WINBAR_HEIGHT(oldwin)); | 1108 win_new_height(wp, VISIBLE_HEIGHT(oldwin)); |
1109 wp->w_status_height = oldwin->w_status_height; | 1109 wp->w_status_height = oldwin->w_status_height; |
1110 } | 1110 } |
1111 frp->fr_height = curfrp->fr_height; | 1111 frp->fr_height = curfrp->fr_height; |
1112 | 1112 |
1113 /* "new_size" of the current window goes to the new window, use | 1113 /* "new_size" of the current window goes to the new window, use |
1178 wp->w_status_height = STATUS_HEIGHT; | 1178 wp->w_status_height = STATUS_HEIGHT; |
1179 oldwin->w_winrow += wp->w_height + STATUS_HEIGHT; | 1179 oldwin->w_winrow += wp->w_height + STATUS_HEIGHT; |
1180 } | 1180 } |
1181 else /* new window below current one */ | 1181 else /* new window below current one */ |
1182 { | 1182 { |
1183 wp->w_winrow = oldwin->w_winrow + oldwin->w_height | 1183 wp->w_winrow = oldwin->w_winrow + VISIBLE_HEIGHT(oldwin) |
1184 + STATUS_HEIGHT + WINBAR_HEIGHT(oldwin); | 1184 + STATUS_HEIGHT; |
1185 wp->w_status_height = oldwin->w_status_height; | 1185 wp->w_status_height = oldwin->w_status_height; |
1186 if (!(flags & WSP_BOT)) | 1186 if (!(flags & WSP_BOT)) |
1187 oldwin->w_status_height = STATUS_HEIGHT; | 1187 oldwin->w_status_height = STATUS_HEIGHT; |
1188 } | 1188 } |
1189 if (flags & WSP_BOT) | 1189 if (flags & WSP_BOT) |
1420 - (p_wiw - p_wmw)) / (p_wmw + 1); | 1420 - (p_wiw - p_wmw)) / (p_wmw + 1); |
1421 } | 1421 } |
1422 else | 1422 else |
1423 { | 1423 { |
1424 /* Each window needs at least 'winminheight' lines and a status line. */ | 1424 /* Each window needs at least 'winminheight' lines and a status line. */ |
1425 maxcount = (curwin->w_height + curwin->w_status_height | 1425 maxcount = (VISIBLE_HEIGHT(curwin) + curwin->w_status_height |
1426 - (p_wh - p_wmh)) / (p_wmh + STATUS_HEIGHT); | 1426 - (p_wh - p_wmh)) / (p_wmh + STATUS_HEIGHT); |
1427 } | 1427 } |
1428 | 1428 |
1429 if (maxcount < 2) | 1429 if (maxcount < 2) |
1430 maxcount = 2; | 1430 maxcount = 2; |
3202 * Set frame height from the window it contains. | 3202 * Set frame height from the window it contains. |
3203 */ | 3203 */ |
3204 static void | 3204 static void |
3205 frame_fix_height(win_T *wp) | 3205 frame_fix_height(win_T *wp) |
3206 { | 3206 { |
3207 wp->w_frame->fr_height = wp->w_height + wp->w_status_height | 3207 wp->w_frame->fr_height = VISIBLE_HEIGHT(wp) + wp->w_status_height; |
3208 + WINBAR_HEIGHT(wp) ; | |
3209 } | 3208 } |
3210 | 3209 |
3211 /* | 3210 /* |
3212 * Compute the minimal height for frame "topfrp". | 3211 * Compute the minimal height for frame "topfrp". |
3213 * Uses the 'winminheight' option. | 3212 * Uses the 'winminheight' option. |
3228 m = p_wh + topfrp->fr_win->w_status_height; | 3227 m = p_wh + topfrp->fr_win->w_status_height; |
3229 else | 3228 else |
3230 { | 3229 { |
3231 /* window: minimal height of the window plus status line */ | 3230 /* window: minimal height of the window plus status line */ |
3232 m = p_wmh + topfrp->fr_win->w_status_height; | 3231 m = p_wmh + topfrp->fr_win->w_status_height; |
3233 /* Current window is minimal one line high */ | 3232 if (topfrp->fr_win == curwin && next_curwin == NULL) |
3234 if (p_wmh == 0 && topfrp->fr_win == curwin && next_curwin == NULL) | 3233 { |
3235 ++m; | 3234 /* Current window is minimal one line high and WinBar is |
3235 * visible. */ | |
3236 if (p_wmh == 0) | |
3237 ++m; | |
3238 m += WINBAR_HEIGHT(curwin); | |
3239 } | |
3236 } | 3240 } |
3237 } | 3241 } |
3238 else if (topfrp->fr_layout == FR_ROW) | 3242 else if (topfrp->fr_layout == FR_ROW) |
3239 { | 3243 { |
3240 /* get the minimal height from each frame in this row */ | 3244 /* get the minimal height from each frame in this row */ |
4970 { | 4974 { |
4971 win_T *wp; | 4975 win_T *wp; |
4972 frame_T *frp; | 4976 frame_T *frp; |
4973 int startcol; | 4977 int startcol; |
4974 int startrow; | 4978 int startrow; |
4979 int h; | |
4975 | 4980 |
4976 wp = topfrp->fr_win; | 4981 wp = topfrp->fr_win; |
4977 if (wp != NULL) | 4982 if (wp != NULL) |
4978 { | 4983 { |
4979 if (wp->w_winrow != *row || wp->w_wincol != *col) | 4984 if (wp->w_winrow != *row || wp->w_wincol != *col) |
4982 wp->w_winrow = *row; | 4987 wp->w_winrow = *row; |
4983 wp->w_wincol = *col; | 4988 wp->w_wincol = *col; |
4984 redraw_win_later(wp, NOT_VALID); | 4989 redraw_win_later(wp, NOT_VALID); |
4985 wp->w_redr_status = TRUE; | 4990 wp->w_redr_status = TRUE; |
4986 } | 4991 } |
4987 *row += wp->w_height + wp->w_status_height; | 4992 /* WinBar will not show if the window height is zero */ |
4993 h = VISIBLE_HEIGHT(wp) + wp->w_status_height; | |
4994 *row += h > topfrp->fr_height ? topfrp->fr_height : h; | |
4988 *col += wp->w_width + wp->w_vsep_width; | 4995 *col += wp->w_width + wp->w_vsep_width; |
4989 } | 4996 } |
4990 else | 4997 else |
4991 { | 4998 { |
4992 startrow = *row; | 4999 startrow = *row; |
5027 * 'winminheight' is zero. */ | 5034 * 'winminheight' is zero. */ |
5028 if (height < p_wmh) | 5035 if (height < p_wmh) |
5029 height = p_wmh; | 5036 height = p_wmh; |
5030 if (height == 0) | 5037 if (height == 0) |
5031 height = 1; | 5038 height = 1; |
5039 height += WINBAR_HEIGHT(curwin); | |
5032 } | 5040 } |
5033 | 5041 |
5034 frame_setheight(win->w_frame, height + win->w_status_height); | 5042 frame_setheight(win->w_frame, height + win->w_status_height); |
5035 | 5043 |
5036 /* recompute the window positions */ | 5044 /* recompute the window positions */ |
5124 if (curfrp->fr_width != Columns) | 5132 if (curfrp->fr_width != Columns) |
5125 room_cmdline = 0; | 5133 room_cmdline = 0; |
5126 else | 5134 else |
5127 { | 5135 { |
5128 room_cmdline = Rows - p_ch - (lastwin->w_winrow | 5136 room_cmdline = Rows - p_ch - (lastwin->w_winrow |
5129 + lastwin->w_height + lastwin->w_status_height); | 5137 + VISIBLE_HEIGHT(lastwin) |
5138 + lastwin->w_status_height); | |
5130 if (room_cmdline < 0) | 5139 if (room_cmdline < 0) |
5131 room_cmdline = 0; | 5140 room_cmdline = 0; |
5132 } | 5141 } |
5133 | 5142 |
5134 if (height <= room + room_cmdline) | 5143 if (height <= room + room_cmdline) |
5413 while (p_wmh > 0) | 5422 while (p_wmh > 0) |
5414 { | 5423 { |
5415 /* TODO: handle vertical splits */ | 5424 /* TODO: handle vertical splits */ |
5416 room = -p_wh; | 5425 room = -p_wh; |
5417 FOR_ALL_WINDOWS(wp) | 5426 FOR_ALL_WINDOWS(wp) |
5418 room += wp->w_height - p_wmh; | 5427 room += VISIBLE_HEIGHT(wp) - p_wmh; |
5419 if (room >= 0) | 5428 if (room >= 0) |
5420 break; | 5429 break; |
5421 --p_wmh; | 5430 --p_wmh; |
5422 if (first) | 5431 if (first) |
5423 { | 5432 { |