]> granicus.if.org Git - vim/commitdiff
patch 8.2.2803: flicker when the popup menu has an info popup v8.2.2803
authorBram Moolenaar <Bram@vim.org>
Fri, 23 Apr 2021 19:01:34 +0000 (21:01 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 23 Apr 2021 19:01:34 +0000 (21:01 +0200)
Problem:    Flicker when the popup menu has an info popup.
Solution:   Avoid drawing over the popup when it's going to be redrawn in the
            same position. (closes #8131)  Also avoid redrawing the scrollbar.

src/drawscreen.c
src/globals.h
src/popupmenu.c
src/proto/popupmenu.pro
src/version.c

index 4a716b29de1f8515d49e77b299ef5c0404b707f4..bb0d8878e843a5e1280aad217d072dc503a52f4c 100644 (file)
@@ -93,6 +93,7 @@ update_screen(int type_arg)
     int                gui_cursor_row = 0;
 #endif
     int                no_update = FALSE;
+    int                save_pum_will_redraw = pum_will_redraw;
 
     // Don't do anything if the screen structures are (not yet) valid.
     if (!screen_valid(TRUE))
@@ -276,6 +277,11 @@ update_screen(int type_arg)
     }
 #endif
 
+    if (pum_redraw_in_same_position())
+       // Avoid flicker if the popup menu is going to be redrawn in the same
+       // position.
+       pum_will_redraw = TRUE;
+
     // Go from top to bottom through the windows, redrawing the ones that need
     // it.
 #if defined(FEAT_SEARCH_EXTRA) || defined(FEAT_CLIPBOARD)
@@ -321,7 +327,9 @@ update_screen(int type_arg)
 #if defined(FEAT_SEARCH_EXTRA)
     end_search_hl();
 #endif
+
     // May need to redraw the popup menu.
+    pum_will_redraw = save_pum_will_redraw;
     pum_may_redraw();
 
     // Reset b_mod_set flags.  Going through all windows is probably faster
index 017c059a484d9069176709617bf0b3b6bfe411b7..5e6b6461d9bac294d17393bcc398ac295badfb44 100644 (file)
@@ -741,6 +741,10 @@ EXTERN int popup_visible INIT(= FALSE);
 EXTERN int     text_prop_frozen INIT(= 0);
 #endif
 
+// When set the popup menu will redraw soon using the pum_win_ values. Do not
+// draw over the poup menu area to avoid flicker.
+EXTERN int     pum_will_redraw INIT(= FALSE);
+
 /*
  * The window layout is kept in a tree of frames.  topframe points to the top
  * of the tree.
index 1f9840804027d63ec520e260ae5fb3e25e198f01..d2a73c0e0e9aed219ee4a8ce2a845e2b6f2aa833 100644 (file)
@@ -40,10 +40,6 @@ static int pum_win_width;
 // makes pum_visible() return FALSE even when there is a popup menu.
 static int pum_pretend_not_visible = FALSE;
 
-// When set the popup menu will redraw soon using the pum_win_ values. Do not
-// draw over the poup menu area to avoid flicker.
-static int pum_will_redraw = FALSE;
-
 static int pum_set_selected(int n, int repeat);
 
 #define PUM_DEF_HEIGHT 10
@@ -392,7 +388,7 @@ pum_under_menu(int row, int col)
            && row >= pum_row
            && row < pum_row + pum_height
            && col >= pum_col - 1
-           && col < pum_col + pum_width;
+           && col < pum_col + pum_width + pum_scrollbar;
 }
 
 /*
@@ -1048,6 +1044,32 @@ pum_visible(void)
     return !pum_pretend_not_visible && pum_array != NULL;
 }
 
+/*
+ * Return TRUE if the popup can be redrawn in the same position.
+ */
+    static int
+pum_in_same_position(void)
+{
+    return pum_window != curwin
+           || (pum_win_row == curwin->w_wrow + W_WINROW(curwin)
+               && pum_win_height == curwin->w_height
+               && pum_win_col == curwin->w_wincol
+               && pum_win_width == curwin->w_width);
+}
+
+/*
+ * Return TRUE when pum_may_redraw() will call pum_redraw().
+ * This means that the pum area should not be overwritten to avoid flicker.
+ */
+    int
+pum_redraw_in_same_position(void)
+{
+    if (!pum_visible() || pum_will_redraw)
+       return FALSE;  // nothing to do
+
+    return pum_in_same_position();
+}
+
 /*
  * Reposition the popup menu to adjust for window layout changes.
  */
@@ -1061,11 +1083,7 @@ pum_may_redraw(void)
     if (!pum_visible() || pum_will_redraw)
        return;  // nothing to do
 
-    if (pum_window != curwin
-           || (pum_win_row == curwin->w_wrow + W_WINROW(curwin)
-               && pum_win_height == curwin->w_height
-               && pum_win_col == curwin->w_wincol
-               && pum_win_width == curwin->w_width))
+    if (pum_in_same_position())
     {
        // window position didn't change, redraw in the same position
        pum_redraw();
index c6527b8598a3cf2cb33c5c28b5bc7d8f22d46bbb..03019dcefb743a3cacf3df71b8771a6e57465ab4 100644 (file)
@@ -7,6 +7,7 @@ void pum_position_info_popup(win_T *wp);
 void pum_undisplay(void);
 void pum_clear(void);
 int pum_visible(void);
+int pum_redraw_in_same_position(void);
 void pum_may_redraw(void);
 int pum_get_height(void);
 void pum_set_event_info(dict_T *dict);
index 0918d5c084db4e086d5b6d51aa85a5c8a8ef3647..a6667e97183da53b50ad4f15a57569e546402648 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2803,
 /**/
     2802,
 /**/