Mercurial > vim
diff src/popupwin.c @ 17847:bdddd215bf09 v8.1.1920
patch 8.1.1920: cannot always close a popup when filter consumes all events
Commit: https://github.com/vim/vim/commit/f63962378dc32c7253e4825b4b0f414a81c1dd3e
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Aug 24 19:36:00 2019 +0200
patch 8.1.1920: cannot always close a popup when filter consumes all events
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)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 24 Aug 2019 19:45:03 +0200 |
parents | b6acc24df7de |
children | 08f1dd29550e |
line wrap: on
line diff
--- a/src/popupwin.c +++ b/src/popupwin.c @@ -222,14 +222,22 @@ popup_on_border(win_T *wp, int row, int } /* - * 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);