diff src/popupwin.c @ 17604:506dd2efcbb2 v8.1.1799

patch 8.1.1799: cannot avoid mapping for a popup window commit https://github.com/vim/vim/commit/749fa0af85232be1d44b77a09161f71cdbace62c Author: Bram Moolenaar <Bram@vim.org> Date: Sat Aug 3 16:18:07 2019 +0200 patch 8.1.1799: cannot avoid mapping for a popup window Problem: Cannot avoid mapping for a popup window. Solution: Add the "mapping" property, default TRUE.
author Bram Moolenaar <Bram@vim.org>
date Sat, 03 Aug 2019 16:30:06 +0200
parents 65a8099fc0e8
children ff097edaae89
line wrap: on
line diff
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -800,6 +800,15 @@ apply_general_options(win_T *wp, dict_T 
 	    set_callback(&wp->w_filter_cb, &callback);
 	}
     }
+    di = dict_find(dict, (char_u *)"mapping", -1);
+    if (di != NULL)
+    {
+	nr = dict_get_number(dict, (char_u *)"mapping");
+	if (nr)
+	    wp->w_popup_flags |= POPF_MAPPING;
+	else
+	    wp->w_popup_flags &= ~POPF_MAPPING;
+    }
 
     di = dict_find(dict, (char_u *)"callback", -1);
     if (di != NULL)
@@ -1413,7 +1422,7 @@ popup_create(typval_T *argvars, typval_T
     if (rettv != NULL)
 	rettv->vval.v_number = wp->w_id;
     wp->w_popup_pos = POPPOS_TOPLEFT;
-    wp->w_popup_flags = POPF_IS_POPUP;
+    wp->w_popup_flags = POPF_IS_POPUP | POPF_MAPPING;
 
     if (buf != NULL)
     {
@@ -1561,6 +1570,7 @@ popup_create(typval_T *argvars, typval_T
 	wp->w_popup_pos = POPPOS_CENTER;
 	wp->w_zindex = POPUPWIN_DIALOG_ZINDEX;
 	wp->w_popup_flags |= POPF_DRAG;
+	wp->w_popup_flags &= ~POPF_MAPPING;
 	for (i = 0; i < 4; ++i)
 	{
 	    wp->w_popup_border[i] = 1;
@@ -2502,6 +2512,25 @@ popup_do_filter(int c)
 }
 
 /*
+ * Return TRUE if there is a popup visible with a filter callback and the
+ * "mapping" property off.
+ */
+    int
+popup_no_mapping(void)
+{
+    int	    round;
+    win_T   *wp;
+
+    for (round = 1; round <= 2; ++round)
+	for (wp = round == 1 ? first_popupwin : curtab->tp_first_popupwin;
+						   wp != NULL; wp = wp->w_next)
+	    if (wp->w_filter_cb.cb_name != NULL
+		    && (wp->w_popup_flags & (POPF_HIDDEN | POPF_MAPPING)) == 0)
+		return TRUE;
+    return FALSE;
+}
+
+/*
  * Called when the cursor moved: check if any popup needs to be closed if the
  * cursor moved far enough.
  */