multigrid: send win_hide events when changing tabpage

This commit is contained in:
Björn Linse 2018-10-18 19:06:21 +02:00
parent ebe16cd9bd
commit c3e2e40e02
2 changed files with 33 additions and 4 deletions

View File

@ -85,7 +85,9 @@ void grid_destroy(Integer grid)
FUNC_API_SINCE(5) FUNC_API_REMOTE_ONLY;
void win_position(Integer win, Integer grid, Integer startrow,
Integer startcol, Integer width, Integer height)
FUNC_API_SINCE(4) FUNC_API_REMOTE_ONLY;
FUNC_API_SINCE(5) FUNC_API_REMOTE_ONLY;
void win_hide(Integer win, Integer grid)
FUNC_API_SINCE(5) FUNC_API_REMOTE_ONLY;
void popupmenu_show(Array items, Integer selected,
Integer row, Integer col, Integer grid)

View File

@ -3118,6 +3118,10 @@ int win_new_tabpage(int after, char_u *filename)
redraw_all_later(NOT_VALID);
if (ui_is_external(kUIMultigrid)) {
tabpage_check_windows(tp);
}
apply_autocmds(EVENT_WINNEW, NULL, NULL, false, curbuf);
apply_autocmds(EVENT_WINENTER, NULL, NULL, false, curbuf);
apply_autocmds(EVENT_TABNEW, filename, filename, false, curbuf);
@ -3309,11 +3313,16 @@ static void enter_tabpage(tabpage_T *tp, buf_T *old_curbuf, int trigger_enter_au
int old_off = tp->tp_firstwin->w_winrow;
win_T *next_prevwin = tp->tp_prevwin;
tabpage_T *old_curtab = curtab;
curtab = tp;
firstwin = tp->tp_firstwin;
lastwin = tp->tp_lastwin;
topframe = tp->tp_topframe;
if (old_curtab != curtab && ui_is_external(kUIMultigrid)) {
tabpage_check_windows(old_curtab);
}
/* We would like doing the TabEnter event first, but we don't have a
* valid current window yet, which may break some commands.
* This triggers autocommands, thus may make "tp" invalid. */
@ -3349,6 +3358,20 @@ static void enter_tabpage(tabpage_T *tp, buf_T *old_curbuf, int trigger_enter_au
must_redraw = NOT_VALID;
}
/// called when changing current tabpage from old_curtab to curtab
static void tabpage_check_windows(tabpage_T *old_curtab)
{
win_T *next_wp;
for (win_T *wp = old_curtab->tp_firstwin; wp; wp = next_wp) {
next_wp = wp->w_next;
wp->w_pos_changed = true;
}
for (win_T *wp = firstwin; wp; wp = wp->w_next) {
wp->w_pos_changed = true;
}
}
/*
* Go to tab page "n". For ":tab N" and "Ngt".
* When "n" is 9999 go to the last tab page.
@ -6074,10 +6097,14 @@ void win_ui_flush(void)
return;
}
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
FOR_ALL_TAB_WINDOWS(tp, wp) {
if (wp->w_pos_changed && wp->w_grid.ScreenLines != NULL) {
ui_call_win_position(wp->handle, wp->w_grid.handle, wp->w_winrow,
wp->w_wincol, wp->w_width, wp->w_height);
if (tp == curtab) {
ui_call_win_position(wp->handle, wp->w_grid.handle, wp->w_winrow,
wp->w_wincol, wp->w_width, wp->w_height);
} else {
ui_call_win_hide(wp->handle, wp->w_grid.handle);
}
wp->w_pos_changed = false;
}
}