0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

patch 8.1.1400: using global pointer for tab-local popups is clumsy

Problem:    Using global pointer for tab-local popups is clumsy.
Solution:   Use the pointer in tabpage_T.
This commit is contained in:
Bram Moolenaar 2019-05-26 18:48:13 +02:00
parent ec58384afa
commit 9c27b1c6d1
6 changed files with 17 additions and 49 deletions

View File

@ -5589,12 +5589,8 @@ garbage_collect(int testing)
for (wp = first_popupwin; wp != NULL; wp = wp->w_next) for (wp = first_popupwin; wp != NULL; wp = wp->w_next)
abort = abort || set_ref_in_item(&wp->w_winvar.di_tv, copyID, abort = abort || set_ref_in_item(&wp->w_winvar.di_tv, copyID,
NULL, NULL); NULL, NULL);
for (wp = first_tab_popupwin; wp != NULL; wp = wp->w_next)
abort = abort || set_ref_in_item(&wp->w_winvar.di_tv, copyID,
NULL, NULL);
FOR_ALL_TABPAGES(tp) FOR_ALL_TABPAGES(tp)
if (tp != curtab) for (wp = tp->tp_first_popupwin; wp != NULL; wp = wp->w_next)
for (wp = tp->tp_first_popupwin; wp != NULL; wp = wp->w_next)
abort = abort || set_ref_in_item(&wp->w_winvar.di_tv, copyID, abort = abort || set_ref_in_item(&wp->w_winvar.di_tv, copyID,
NULL, NULL); NULL, NULL);
#endif #endif
@ -8816,12 +8812,11 @@ find_win_by_nr(
if (nr >= LOWEST_WIN_ID) if (nr >= LOWEST_WIN_ID)
{ {
#ifdef FEAT_TEXT_PROP #ifdef FEAT_TEXT_PROP
// popup windows are in a separate list // check tab-local popup windows
for (wp = (tp == NULL || tp == curtab) for (wp = tp->tp_first_popupwin; wp != NULL; wp = wp->w_next)
? first_tab_popupwin : tp->tp_first_popupwin;
wp != NULL; wp = wp->w_next)
if (wp->w_id == nr) if (wp->w_id == nr)
return wp; return wp;
// check global popup windows
for (wp = first_popupwin; wp != NULL; wp = wp->w_next) for (wp = first_popupwin; wp != NULL; wp = wp->w_next)
if (wp->w_id == nr) if (wp->w_id == nr)
return wp; return wp;

View File

@ -582,7 +582,6 @@ EXTERN win_T *aucmd_win; /* window used in aucmd_prepbuf() */
EXTERN int aucmd_win_used INIT(= FALSE); /* aucmd_win is being used */ EXTERN int aucmd_win_used INIT(= FALSE); /* aucmd_win is being used */
#ifdef FEAT_TEXT_PROP #ifdef FEAT_TEXT_PROP
EXTERN win_T *first_tab_popupwin; // first popup window local to tab page
EXTERN win_T *first_popupwin; // first global popup window EXTERN win_T *first_popupwin; // first global popup window
#endif #endif

View File

@ -85,8 +85,8 @@ f_popup_create(typval_T *argvars, typval_T *rettv)
if (nr == 0) if (nr == 0)
{ {
// popup on current tab // popup on current tab
wp->w_next = first_tab_popupwin; wp->w_next = curtab->tp_first_popupwin;
first_tab_popupwin = wp; curtab->tp_first_popupwin = wp;
} }
else if (nr < 0) else if (nr < 0)
{ {
@ -212,13 +212,9 @@ popup_close(int id)
popup_close_tabpage(tabpage_T *tp, int id) popup_close_tabpage(tabpage_T *tp, int id)
{ {
win_T *wp; win_T *wp;
win_T **root; win_T **root = &tp->tp_first_popupwin;
win_T *prev = NULL; win_T *prev = NULL;
if (tp == curtab)
root = &first_tab_popupwin;
else
root = &tp->tp_first_popupwin;
for (wp = *root; wp != NULL; prev = wp, wp = wp->w_next) for (wp = *root; wp != NULL; prev = wp, wp = wp->w_next)
if (wp->w_id == id) if (wp->w_id == id)
{ {
@ -237,8 +233,8 @@ close_all_popups(void)
{ {
while (first_popupwin != NULL) while (first_popupwin != NULL)
popup_close(first_popupwin->w_id); popup_close(first_popupwin->w_id);
while (first_tab_popupwin != NULL) while (curtab->tp_first_popupwin != NULL)
popup_close(first_tab_popupwin->w_id); popup_close(curtab->tp_first_popupwin->w_id);
} }
void void

View File

@ -610,7 +610,7 @@ update_screen(int type_arg)
} }
#ifdef FEAT_TEXT_PROP #ifdef FEAT_TEXT_PROP
// TODO: avoid redrawing everything when there is a popup window. // TODO: avoid redrawing everything when there is a popup window.
if (first_popupwin != NULL || first_tab_popupwin != NULL) if (first_popupwin != NULL || curtab->tp_first_popupwin != NULL)
type = NOT_VALID; type = NOT_VALID;
#endif #endif
@ -1000,7 +1000,7 @@ update_popups(void)
// Reset all the VALID_POPUP flags. // Reset all the VALID_POPUP flags.
for (wp = first_popupwin; wp != NULL; wp = wp->w_next) for (wp = first_popupwin; wp != NULL; wp = wp->w_next)
wp->w_valid &= ~VALID_POPUP; wp->w_valid &= ~VALID_POPUP;
for (wp = first_tab_popupwin; wp != NULL; wp = wp->w_next) for (wp = curtab->tp_first_popupwin; wp != NULL; wp = wp->w_next)
wp->w_valid &= ~VALID_POPUP; wp->w_valid &= ~VALID_POPUP;
// TODO: don't redraw every popup every time. // TODO: don't redraw every popup every time.
@ -1018,7 +1018,7 @@ update_popups(void)
lowest_zindex = wp->w_zindex; lowest_zindex = wp->w_zindex;
lowest_wp = wp; lowest_wp = wp;
} }
for (wp = first_tab_popupwin; wp != NULL; wp = wp->w_next) for (wp = curtab->tp_first_popupwin; wp != NULL; wp = wp->w_next)
if ((wp->w_valid & VALID_POPUP) == 0 if ((wp->w_valid & VALID_POPUP) == 0
&& wp->w_zindex < lowest_zindex) && wp->w_zindex < lowest_zindex)
{ {

View File

@ -767,6 +767,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1400,
/**/ /**/
1399, 1399,
/**/ /**/

View File

@ -1371,7 +1371,7 @@ win_valid_popup(win_T *win UNUSED)
for (wp = first_popupwin; wp != NULL; wp = wp->w_next) for (wp = first_popupwin; wp != NULL; wp = wp->w_next)
if (wp == win) if (wp == win)
return TRUE; return TRUE;
for (wp = first_tab_popupwin; wp != NULL; wp = wp->w_next) for (wp = curtab->tp_first_popupwin; wp != NULL; wp = wp->w_next)
if (wp == win) if (wp == win)
return TRUE; return TRUE;
#endif #endif
@ -3673,13 +3673,8 @@ free_tabpage(tabpage_T *tp)
{ {
win_T *wp; win_T *wp;
for (;;) while (tp->tp_first_popupwin != NULL)
{ popup_close_tabpage(tp, tp->tp_first_popupwin->w_id);
wp = tp == curtab ? first_tab_popupwin : tp->tp_first_popupwin;
if (wp == NULL)
break;
popup_close_tabpage(tp, wp->w_id);
}
} }
#endif #endif
for (idx = 0; idx < SNAP_COUNT; ++idx) for (idx = 0; idx < SNAP_COUNT; ++idx)
@ -3973,10 +3968,6 @@ leave_tabpage(
tp->tp_prevwin = prevwin; tp->tp_prevwin = prevwin;
tp->tp_firstwin = firstwin; tp->tp_firstwin = firstwin;
tp->tp_lastwin = lastwin; tp->tp_lastwin = lastwin;
#ifdef FEAT_TEXT_PROP
tp->tp_first_popupwin = first_tab_popupwin;
first_tab_popupwin = NULL;
#endif
tp->tp_old_Rows = Rows; tp->tp_old_Rows = Rows;
tp->tp_old_Columns = Columns; tp->tp_old_Columns = Columns;
firstwin = NULL; firstwin = NULL;
@ -4004,9 +3995,6 @@ enter_tabpage(
firstwin = tp->tp_firstwin; firstwin = tp->tp_firstwin;
lastwin = tp->tp_lastwin; lastwin = tp->tp_lastwin;
topframe = tp->tp_topframe; topframe = tp->tp_topframe;
#ifdef FEAT_TEXT_PROP
first_tab_popupwin = tp->tp_first_popupwin;
#endif
/* We would like doing the TabEnter event first, but we don't have a /* We would like doing the TabEnter event first, but we don't have a
* valid current window yet, which may break some commands. * valid current window yet, which may break some commands.
@ -6513,15 +6501,9 @@ switch_win(
{ {
curtab->tp_firstwin = firstwin; curtab->tp_firstwin = firstwin;
curtab->tp_lastwin = lastwin; curtab->tp_lastwin = lastwin;
#ifdef FEAT_TEXT_PROP
curtab->tp_first_popupwin = first_tab_popupwin ;
#endif
curtab = tp; curtab = tp;
firstwin = curtab->tp_firstwin; firstwin = curtab->tp_firstwin;
lastwin = curtab->tp_lastwin; lastwin = curtab->tp_lastwin;
#ifdef FEAT_TEXT_PROP
first_tab_popupwin = curtab->tp_first_popupwin;
#endif
} }
else else
goto_tabpage_tp(tp, FALSE, FALSE); goto_tabpage_tp(tp, FALSE, FALSE);
@ -6550,15 +6532,9 @@ restore_win(
{ {
curtab->tp_firstwin = firstwin; curtab->tp_firstwin = firstwin;
curtab->tp_lastwin = lastwin; curtab->tp_lastwin = lastwin;
#ifdef FEAT_TEXT_PROP
curtab->tp_first_popupwin = first_tab_popupwin ;
#endif
curtab = save_curtab; curtab = save_curtab;
firstwin = curtab->tp_firstwin; firstwin = curtab->tp_firstwin;
lastwin = curtab->tp_lastwin; lastwin = curtab->tp_lastwin;
#ifdef FEAT_TEXT_PROP
first_tab_popupwin = curtab->tp_first_popupwin;
#endif
} }
else else
goto_tabpage_tp(save_curtab, FALSE, FALSE); goto_tabpage_tp(save_curtab, FALSE, FALSE);