Mercurial > vim
changeset 17578:696030820746 v8.1.1786
patch 8.1.1786: double click in popup scrollbar starts selection
commit https://github.com/vim/vim/commit/13b11eddcaf5176fb1127c8bc8f4b4f46bd05488
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Aug 1 15:52:45 2019 +0200
patch 8.1.1786: double click in popup scrollbar starts selection
Problem: Double click in popup scrollbar starts selection.
Solution: Ignore the double click.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 01 Aug 2019 16:00:07 +0200 |
parents | bfc0be715b0d |
children | 8c91fe192c56 |
files | src/popupwin.c src/proto/popupwin.pro src/ui.c src/version.c |
diffstat | 4 files changed, 44 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- 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 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) {
--- a/src/proto/popupwin.pro +++ b/src/proto/popupwin.pro @@ -4,6 +4,7 @@ int popup_on_X_button(win_T *wp, int row 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);
--- a/src/ui.c +++ b/src/ui.c @@ -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, i 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