]> granicus.if.org Git - vim/commitdiff
patch 8.2.4619: mapping is cancelled when mouse moves and popup is visible v8.2.4619
authorBram Moolenaar <Bram@vim.org>
Thu, 24 Mar 2022 15:15:15 +0000 (15:15 +0000)
committerBram Moolenaar <Bram@vim.org>
Thu, 24 Mar 2022 15:15:15 +0000 (15:15 +0000)
Problem:    Mapping is cancelled when mouse moves and popup is visible.
Solution:   Only generate mouse moved events when a popup may use them.
            (closes #10004)

src/globals.h
src/gui.c
src/popupwin.c
src/version.c

index 1a50649a1185948b35ee9439e6d5e0da446895a7..cd8893b307212be2c658139eb516df36731db7e2 100644 (file)
@@ -736,6 +736,9 @@ EXTERN win_T        *popup_dragwin INIT(= NULL);    // popup window being dragged
 // Set to TRUE if there is any visible popup window.
 EXTERN int     popup_visible INIT(= FALSE);
 
+// Set to TRUE if a visible popup window may use a MOUSE_MOVE event
+EXTERN int     popup_uses_mouse_move INIT(= FALSE);
+
 EXTERN int     text_prop_frozen INIT(= 0);
 #endif
 
index fb589fc1c790d972e552f09361de5540dac5a611..3e383a4b4e6aaa1d3b8fdbd854a51fe13620dbc1 100644 (file)
--- a/src/gui.c
+++ b/src/gui.c
@@ -4968,7 +4968,7 @@ gui_mouse_moved(int x, int y)
     gui_mouse_focus(x, y);
 
 #ifdef FEAT_PROP_POPUP
-    if (popup_visible)
+    if (popup_uses_mouse_move)
        // Generate a mouse-moved event, so that the popup can perhaps be
        // closed, just like in the terminal.
        gui_send_mouse_event(MOUSE_MOVE, x, y, FALSE, 0);
index 0aca7d324672ed7cb4ead7bbfe2bb64ac4bbe6c3..55f98f8a6f94778a552634c326b659bda811fbf5 100644 (file)
@@ -150,6 +150,29 @@ set_mousemoved_values(win_T *wp)
     wp->w_popup_mouse_maxcol = mouse_col;
 }
 
+    static void
+update_popup_uses_mouse_move(void)
+{
+    popup_uses_mouse_move = FALSE;
+    if (popup_visible)
+    {
+       win_T *wp;
+
+       FOR_ALL_POPUPWINS(wp)
+           if (wp->w_popup_mouse_row != 0)
+           {
+               popup_uses_mouse_move = TRUE;
+               return;
+           }
+       FOR_ALL_POPUPWINS_IN_TAB(curtab, wp)
+           if (wp->w_popup_mouse_row != 0)
+           {
+               popup_uses_mouse_move = TRUE;
+               return;
+           }
+    }
+}
+
 /*
  * Used when popup options contain "moved" with "word" or "WORD".
  */
@@ -3586,7 +3609,7 @@ popup_need_position_adjust(win_T *wp)
 /*
  * Update "popup_mask" if needed.
  * Also recomputes the popup size and positions.
- * Also updates "popup_visible".
+ * Also updates "popup_visible" and "popup_uses_mouse_move".
  * Also marks window lines for redrawing.
  */
     void
@@ -3755,6 +3778,8 @@ may_update_popup_mask(int type)
 
        vim_free(plines_cache);
     }
+
+    update_popup_uses_mouse_move();
 }
 
 /*
index 39eefb5f64d9ac90f8b530ceb2371d0c40af2dd8..693cebc06afaba761369fb87878ad789f2aa38f5 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4619,
 /**/
     4618,
 /**/