diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-06-30 18:07:00 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-06-30 18:07:00 +0200 |
commit | 2e62b568e91c36adb16dbcc609665170f09f3845 (patch) | |
tree | fef2344429e26ba99e52315b28fc979477e23d7b /src/ui.c | |
parent | b60d8514b8813e2f3acefd454efcccbe04ac135a (diff) | |
download | vim-git-2e62b568e91c36adb16dbcc609665170f09f3845.tar.gz |
patch 8.1.1609: the user cannot easily close a popup windowv8.1.1609
Problem: The user cannot easily close a popup window.
Solution: Add the "close" property. (mostly by Masato Nishihata,
closes #4601)
Diffstat (limited to 'src/ui.c')
-rw-r--r-- | src/ui.c | 25 |
1 files changed, 23 insertions, 2 deletions
@@ -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 |