0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 8.1.1786: double click in popup scrollbar starts selection

Problem:    Double click in popup scrollbar starts selection.
Solution:   Ignore the double click.
This commit is contained in:
Bram Moolenaar
2019-08-01 15:52:45 +02:00
parent b66bab381c
commit 13b11eddca
4 changed files with 44 additions and 28 deletions

View File

@@ -304,6 +304,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. * Handle a click in a popup window, if it is in the scrollbar.
*/ */
@@ -313,11 +326,7 @@ popup_handle_scrollbar_click(win_T *wp, int row, int col)
int height = popup_height(wp); int height = popup_height(wp);
int old_topline = wp->w_topline; int old_topline = wp->w_topline;
if (wp->w_has_scrollbar == 0) if (popup_is_in_scrollbar(wp, row, col))
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 (row >= height / 2) if (row >= height / 2)
{ {

View File

@@ -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_start_drag(win_T *wp);
void popup_drag(win_T *wp); void popup_drag(win_T *wp);
void popup_set_firstline(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); void popup_handle_scrollbar_click(win_T *wp, int row, int col);
int popup_height(win_T *wp); int popup_height(win_T *wp);
int popup_width(win_T *wp); int popup_width(win_T *wp);

View File

@@ -1058,6 +1058,17 @@ clip_compare_pos(
clip_start_selection(int col, int row, int repeated_click) clip_start_selection(int col, int row, int repeated_click)
{ {
Clipboard_T *cb = &clip_star; 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) if (cb->state == SELECT_DONE)
clip_clear_selection(cb); 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->origin_row = (short_u)cb->start.lnum;
cb->state = SELECT_IN_PROGRESS; cb->state = SELECT_IN_PROGRESS;
#ifdef FEAT_TEXT_PROP #ifdef FEAT_TEXT_PROP
if (wp != NULL && WIN_IS_POPUP(wp))
{ {
win_T *wp; // Click in a popup window restricts selection to that window,
int row_cp = row; // excluding the border.
int col_cp = col; cb->min_col = wp->w_wincol + wp->w_popup_border[3];
cb->max_col = wp->w_wincol + popup_width(wp) - 1
wp = mouse_find_win(&row_cp, &col_cp, FIND_POPUP); - wp->w_popup_border[1];
if (wp != NULL && WIN_IS_POPUP(wp)) cb->min_row = wp->w_winrow + wp->w_popup_border[0];
{ cb->max_row = wp->w_winrow + popup_height(wp) - 1
// Click in a popup window restricts selection to that window, - wp->w_popup_border[2];
// excluding the border. }
cb->min_col = wp->w_wincol + wp->w_popup_border[3]; else
cb->max_col = wp->w_wincol + popup_width(wp) - 1 {
- wp->w_popup_border[1]; cb->min_col = 0;
cb->min_row = wp->w_winrow + wp->w_popup_border[0]; cb->max_col = screen_Columns;
cb->max_row = wp->w_winrow + popup_height(wp) - 1 cb->min_row = 0;
- wp->w_popup_border[2]; cb->max_row = screen_Rows;
}
else
{
cb->min_col = 0;
cb->max_col = screen_Columns;
cb->min_row = 0;
cb->max_row = screen_Rows;
}
} }
#endif #endif

View File

@@ -773,6 +773,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1786,
/**/ /**/
1785, 1785,
/**/ /**/