Patch 8.2.2803
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.
Files:      src/popupmenu.c, src/proto/popupmenu.pro, src/drawscreen.c,
            src/globals.h


*** ../vim-8.2.2802/src/popupmenu.c     2020-12-24 18:38:37.181858419 +0100
--- src/popupmenu.c     2021-04-23 20:40:25.912883348 +0200
***************
*** 40,49 ****
  // 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
--- 40,45 ----
***************
*** 392,398 ****
            && row >= pum_row
            && row < pum_row + pum_height
            && col >= pum_col - 1
!           && col < pum_col + pum_width;
  }
  
  /*
--- 388,394 ----
            && row >= pum_row
            && row < pum_row + pum_height
            && col >= pum_col - 1
!           && col < pum_col + pum_width + pum_scrollbar;
  }
  
  /*
***************
*** 1049,1054 ****
--- 1045,1076 ----
  }
  
  /*
+  * 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.
   */
      void
***************
*** 1061,1071 ****
      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))
      {
        // window position didn't change, redraw in the same position
        pum_redraw();
--- 1083,1089 ----
      if (!pum_visible() || pum_will_redraw)
        return;  // nothing to do
  
!     if (pum_in_same_position())
      {
        // window position didn't change, redraw in the same position
        pum_redraw();
*** ../vim-8.2.2802/src/proto/popupmenu.pro     2019-12-12 12:55:30.000000000 
+0100
--- src/proto/popupmenu.pro     2021-04-23 20:29:09.274492220 +0200
***************
*** 7,12 ****
--- 7,13 ----
  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);
*** ../vim-8.2.2802/src/drawscreen.c    2021-04-22 21:39:26.239762214 +0200
--- src/drawscreen.c    2021-04-23 20:32:24.370082025 +0200
***************
*** 93,98 ****
--- 93,99 ----
      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,281 ****
--- 277,287 ----
      }
  #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,327 ****
--- 327,335 ----
  #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
*** ../vim-8.2.2802/src/globals.h       2021-04-19 16:48:44.435055499 +0200
--- src/globals.h       2021-04-23 20:34:37.509771547 +0200
***************
*** 741,746 ****
--- 741,750 ----
  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.
*** ../vim-8.2.2802/src/version.c       2021-04-23 19:32:17.165880911 +0200
--- src/version.c       2021-04-23 20:42:22.824568599 +0200
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     2803,
  /**/

-- 
If you feel lonely, try schizophrenia.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202104231902.13NJ2AfY1717934%40masaka.moolenaar.net.

Raspunde prin e-mail lui