diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-08-01 15:52:45 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-08-01 15:52:45 +0200 |
commit | 13b11eddcaf5176fb1127c8bc8f4b4f46bd05488 (patch) | |
tree | 94341003d3cead6759dbbeae715acd04776bd9a2 | |
parent | b66bab381c8ba71fd6e92327d1d34c6f8a65f2a7 (diff) | |
download | vim-git-13b11eddcaf5176fb1127c8bc8f4b4f46bd05488.tar.gz |
patch 8.1.1786: double click in popup scrollbar starts selectionv8.1.1786
Problem: Double click in popup scrollbar starts selection.
Solution: Ignore the double click.
-rw-r--r-- | src/popupwin.c | 19 | ||||
-rw-r--r-- | src/proto/popupwin.pro | 1 | ||||
-rw-r--r-- | src/ui.c | 50 | ||||
-rw-r--r-- | src/version.c | 2 |
4 files changed, 44 insertions, 28 deletions
diff --git a/src/popupwin.c b/src/popupwin.c index 856409798..ed01693d5 100644 --- a/src/popupwin.c +++ b/src/popupwin.c @@ -305,6 +305,19 @@ popup_set_firstline(win_T *wp) } /* + * Return TRUE if the position is in the popup window scrollbar. + */ + int +popup_is_in_scrollbar(win_T *wp, int row, int col) +{ + return wp->w_has_scrollbar + && row >= wp->w_popup_border[0] + && row < popup_height(wp) - wp->w_popup_border[2] + && col == popup_width(wp) - wp->w_popup_border[1] - 1; +} + + +/* * Handle a click in a popup window, if it is in the scrollbar. */ void @@ -313,11 +326,7 @@ popup_handle_scrollbar_click(win_T *wp, int row, int col) int height = popup_height(wp); int old_topline = wp->w_topline; - if (wp->w_has_scrollbar == 0) - return; - if (row >= wp->w_popup_border[0] - && row < height - wp->w_popup_border[2] - && col == popup_width(wp) - wp->w_popup_border[1] - 1) + if (popup_is_in_scrollbar(wp, row, col)) { if (row >= height / 2) { diff --git a/src/proto/popupwin.pro b/src/proto/popupwin.pro index 0a5db0c48..145cbea25 100644 --- a/src/proto/popupwin.pro +++ b/src/proto/popupwin.pro @@ -4,6 +4,7 @@ int popup_on_X_button(win_T *wp, int row, int col); void popup_start_drag(win_T *wp); void popup_drag(win_T *wp); void popup_set_firstline(win_T *wp); +int popup_is_in_scrollbar(win_T *wp, int row, int col); void popup_handle_scrollbar_click(win_T *wp, int row, int col); int popup_height(win_T *wp); int popup_width(win_T *wp); @@ -1058,6 +1058,17 @@ clip_compare_pos( clip_start_selection(int col, int row, int repeated_click) { Clipboard_T *cb = &clip_star; +#ifdef FEAT_TEXT_PROP + win_T *wp; + int row_cp = row; + int col_cp = col; + + wp = mouse_find_win(&row_cp, &col_cp, FIND_POPUP); + if (wp != NULL && WIN_IS_POPUP(wp) + && popup_is_in_scrollbar(wp, row_cp, col_cp)) + // click or double click in scrollbar does not start a selection + return; +#endif if (cb->state == SELECT_DONE) clip_clear_selection(cb); @@ -1072,30 +1083,23 @@ clip_start_selection(int col, int row, int repeated_click) cb->origin_row = (short_u)cb->start.lnum; cb->state = SELECT_IN_PROGRESS; #ifdef FEAT_TEXT_PROP + if (wp != NULL && WIN_IS_POPUP(wp)) { - win_T *wp; - int row_cp = row; - int col_cp = col; - - wp = mouse_find_win(&row_cp, &col_cp, FIND_POPUP); - if (wp != NULL && WIN_IS_POPUP(wp)) - { - // Click in a popup window restricts selection to that window, - // excluding the border. - cb->min_col = wp->w_wincol + wp->w_popup_border[3]; - cb->max_col = wp->w_wincol + popup_width(wp) - 1 - - wp->w_popup_border[1]; - cb->min_row = wp->w_winrow + wp->w_popup_border[0]; - cb->max_row = wp->w_winrow + popup_height(wp) - 1 - - wp->w_popup_border[2]; - } - else - { - cb->min_col = 0; - cb->max_col = screen_Columns; - cb->min_row = 0; - cb->max_row = screen_Rows; - } + // Click in a popup window restricts selection to that window, + // excluding the border. + cb->min_col = wp->w_wincol + wp->w_popup_border[3]; + cb->max_col = wp->w_wincol + popup_width(wp) - 1 + - wp->w_popup_border[1]; + cb->min_row = wp->w_winrow + wp->w_popup_border[0]; + cb->max_row = wp->w_winrow + popup_height(wp) - 1 + - wp->w_popup_border[2]; + } + else + { + cb->min_col = 0; + cb->max_col = screen_Columns; + cb->min_row = 0; + cb->max_row = screen_Rows; } #endif diff --git a/src/version.c b/src/version.c index 53ab0c90a..0e30df7cd 100644 --- a/src/version.c +++ b/src/version.c @@ -774,6 +774,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1786, +/**/ 1785, /**/ 1784, |