summaryrefslogtreecommitdiff
path: root/src/popupwin.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-08-24 19:36:00 +0200
committerBram Moolenaar <Bram@vim.org>2019-08-24 19:36:00 +0200
commitf63962378dc32c7253e4825b4b0f414a81c1dd3e (patch)
tree46ec1a7ae20b1e6d2b5e3ecf3a4c241b9791639c /src/popupwin.c
parent4645104be4c521dfdd43621c19e96bda3cac7be2 (diff)
downloadvim-git-f63962378dc32c7253e4825b4b0f414a81c1dd3e.tar.gz
patch 8.1.1920: cannot always close a popup when filter consumes all eventsv8.1.1920
Problem: Cannot close a popup by the X when a filter consumes all events. Solution: Check for a click on the close button before invoking filters. (closes #4858)
Diffstat (limited to 'src/popupwin.c')
-rw-r--r--src/popupwin.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/popupwin.c b/src/popupwin.c
index e8abf6dc3..7aef27358 100644
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -222,14 +222,22 @@ popup_on_border(win_T *wp, int row, int col)
}
/*
- * Return TRUE if "row"/"col" is on the "X" button of the popup.
+ * Return TRUE and close the popup if "row"/"col" is on the "X" button of the
+ * popup and w_popup_close is POPCLOSE_BUTTON.
* The values are relative to the top-left corner.
- * Caller should check w_popup_close is POPCLOSE_BUTTON.
+ * Caller should check the left mouse button was clicked.
+ * Return TRUE if the popup was closed.
*/
int
-popup_on_X_button(win_T *wp, int row, int col)
+popup_close_if_on_X(win_T *wp, int row, int col)
{
- return row == 0 && col == popup_width(wp) - 1;
+ if (wp->w_popup_close == POPCLOSE_BUTTON
+ && row == 0 && col == popup_width(wp) - 1)
+ {
+ popup_close_for_mouse_click(wp);
+ return TRUE;
+ }
+ return FALSE;
}
// Values set when dragging a popup window starts.
@@ -2635,6 +2643,16 @@ popup_do_filter(int c)
popup_reset_handled();
+ if (c == K_LEFTMOUSE)
+ {
+ int row = mouse_row;
+ int col = mouse_col;
+
+ wp = mouse_find_win(&row, &col, FIND_POPUP);
+ if (wp != NULL && popup_close_if_on_X(wp, row, col))
+ return TRUE;
+ }
+
while (!res && (wp = find_next_popup(FALSE)) != NULL)
if (wp->w_filter_cb.cb_name != NULL)
res = invoke_popup_filter(wp, c);