Mercurial > vim
comparison 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 |
comparison
equal
deleted
inserted
replaced
17846:6b66c868f9aa | 17847:bdddd215bf09 |
---|---|
220 || (col == 0 && wp->w_popup_border[3] > 0) | 220 || (col == 0 && wp->w_popup_border[3] > 0) |
221 || (col == popup_width(wp) - 1 && wp->w_popup_border[1] > 0); | 221 || (col == popup_width(wp) - 1 && wp->w_popup_border[1] > 0); |
222 } | 222 } |
223 | 223 |
224 /* | 224 /* |
225 * Return TRUE if "row"/"col" is on the "X" button of the popup. | 225 * Return TRUE and close the popup if "row"/"col" is on the "X" button of the |
226 * popup and w_popup_close is POPCLOSE_BUTTON. | |
226 * The values are relative to the top-left corner. | 227 * The values are relative to the top-left corner. |
227 * Caller should check w_popup_close is POPCLOSE_BUTTON. | 228 * Caller should check the left mouse button was clicked. |
229 * Return TRUE if the popup was closed. | |
228 */ | 230 */ |
229 int | 231 int |
230 popup_on_X_button(win_T *wp, int row, int col) | 232 popup_close_if_on_X(win_T *wp, int row, int col) |
231 { | 233 { |
232 return row == 0 && col == popup_width(wp) - 1; | 234 if (wp->w_popup_close == POPCLOSE_BUTTON |
235 && row == 0 && col == popup_width(wp) - 1) | |
236 { | |
237 popup_close_for_mouse_click(wp); | |
238 return TRUE; | |
239 } | |
240 return FALSE; | |
233 } | 241 } |
234 | 242 |
235 // Values set when dragging a popup window starts. | 243 // Values set when dragging a popup window starts. |
236 static int drag_start_row; | 244 static int drag_start_row; |
237 static int drag_start_col; | 245 static int drag_start_col; |
2633 int res = FALSE; | 2641 int res = FALSE; |
2634 win_T *wp; | 2642 win_T *wp; |
2635 | 2643 |
2636 popup_reset_handled(); | 2644 popup_reset_handled(); |
2637 | 2645 |
2646 if (c == K_LEFTMOUSE) | |
2647 { | |
2648 int row = mouse_row; | |
2649 int col = mouse_col; | |
2650 | |
2651 wp = mouse_find_win(&row, &col, FIND_POPUP); | |
2652 if (wp != NULL && popup_close_if_on_X(wp, row, col)) | |
2653 return TRUE; | |
2654 } | |
2655 | |
2638 while (!res && (wp = find_next_popup(FALSE)) != NULL) | 2656 while (!res && (wp = find_next_popup(FALSE)) != NULL) |
2639 if (wp->w_filter_cb.cb_name != NULL) | 2657 if (wp->w_filter_cb.cb_name != NULL) |
2640 res = invoke_popup_filter(wp, c); | 2658 res = invoke_popup_filter(wp, c); |
2641 | 2659 |
2642 return res; | 2660 return res; |