0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.1.1609: the user cannot easily close a popup window

Problem:    The user cannot easily close a popup window.
Solution:   Add the "close" property. (mostly by Masato Nishihata,
            closes #4601)
This commit is contained in:
Bram Moolenaar
2019-06-30 18:07:00 +02:00
parent b60d8514b8
commit 2e62b568e9
10 changed files with 224 additions and 21 deletions

View File

@@ -2929,6 +2929,7 @@ jump_to_mouse(
#endif
#ifdef FEAT_TEXT_PROP
static int in_popup_win = FALSE;
static win_T *click_in_popup_win = NULL;
#endif
static int prev_row = -1;
static int prev_col = -1;
@@ -2957,7 +2958,11 @@ jump_to_mouse(
dragwin = NULL;
did_drag = FALSE;
#ifdef FEAT_TEXT_PROP
if (click_in_popup_win != NULL && popup_dragwin == NULL)
popup_close_for_mouse_click(click_in_popup_win);
popup_dragwin = NULL;
click_in_popup_win = NULL;
#endif
}
@@ -3001,6 +3006,7 @@ retnomove:
// Continue a modeless selection in a popup window or dragging it.
if (in_popup_win)
{
click_in_popup_win = NULL; // don't close it on release
if (popup_dragwin != NULL)
{
// dragging a popup window
@@ -3050,13 +3056,27 @@ retnomove:
{
on_sep_line = 0;
in_popup_win = TRUE;
if (wp->w_popup_drag && popup_on_border(wp, row, col))
if (wp->w_popup_close == POPCLOSE_BUTTON
&& which_button == MOUSE_LEFT
&& popup_on_X_button(wp, row, col))
{
popup_close_for_mouse_click(wp);
return IN_UNKNOWN;
}
else if (wp->w_popup_drag && popup_on_border(wp, row, col))
{
popup_dragwin = wp;
popup_start_drag(wp);
return IN_UNKNOWN;
}
if (which_button == MOUSE_LEFT)
// Only close on release, otherwise it's not possible to drag or do
// modeless selection.
else if (wp->w_popup_close == POPCLOSE_CLICK
&& which_button == MOUSE_LEFT)
{
click_in_popup_win = wp;
}
else if (which_button == MOUSE_LEFT)
// If the click is in the scrollbar, may scroll up/down.
popup_handle_scrollbar_click(wp, row, col);
# ifdef FEAT_CLIPBOARD
@@ -3244,6 +3264,7 @@ retnomove:
return IN_UNKNOWN;
}
// continue a modeless selection in a popup window
click_in_popup_win = NULL;
return IN_OTHER_WIN;
}
#endif