0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

patch 8.1.2254: MS-Windows: mouse scroll wheel doesn't work in popup

Problem:    MS-Windows: mouse scroll wheel doesn't work in popup.
Solution:   Handle mouse wheel events separately. (closes #5138)
This commit is contained in:
Bram Moolenaar 2019-11-04 22:52:12 +01:00
parent ad4de52510
commit 0630bb6580
4 changed files with 55 additions and 15 deletions

View File

@ -31,7 +31,7 @@ static void gui_do_scrollbar(win_T *wp, int which, int enable);
static void gui_update_horiz_scrollbar(int); static void gui_update_horiz_scrollbar(int);
static void gui_set_fg_color(char_u *name); static void gui_set_fg_color(char_u *name);
static void gui_set_bg_color(char_u *name); static void gui_set_bg_color(char_u *name);
static win_T *xy2win(int x, int y); static win_T *xy2win(int x, int y, mouse_find_T popup);
#ifdef GUI_MAY_FORK #ifdef GUI_MAY_FORK
static void gui_do_fork(void); static void gui_do_fork(void);
@ -4852,7 +4852,7 @@ gui_mouse_focus(int x, int y)
#ifdef FEAT_MOUSESHAPE #ifdef FEAT_MOUSESHAPE
/* Get window pointer, and update mouse shape as well. */ /* Get window pointer, and update mouse shape as well. */
wp = xy2win(x, y); wp = xy2win(x, y, IGNORE_POPUP);
#endif #endif
/* Only handle this when 'mousefocus' set and ... */ /* Only handle this when 'mousefocus' set and ... */
@ -4868,7 +4868,7 @@ gui_mouse_focus(int x, int y)
if (x < 0 || x > Columns * gui.char_width) if (x < 0 || x > Columns * gui.char_width)
return; return;
#ifndef FEAT_MOUSESHAPE #ifndef FEAT_MOUSESHAPE
wp = xy2win(x, y); wp = xy2win(x, y, IGNORE_POPUP);
#endif #endif
if (wp == curwin || wp == NULL) if (wp == curwin || wp == NULL)
return; /* still in the same old window, or none at all */ return; /* still in the same old window, or none at all */
@ -4929,26 +4929,37 @@ gui_mouse_moved(int x, int y)
#endif #endif
} }
/*
* Get the window where the mouse pointer is on.
* Returns NULL if not found.
*/
win_T *
gui_mouse_window(mouse_find_T popup)
{
int x, y;
if (!(gui.in_use && (p_mousef || popup == FIND_POPUP)))
return NULL;
gui_mch_getmouse(&x, &y);
// Only use the mouse when it's on the Vim window
if (x >= 0 && x <= Columns * gui.char_width
&& y >= 0 && Y_2_ROW(y) >= tabline_height())
return xy2win(x, y, popup);
return NULL;
}
/* /*
* Called when mouse should be moved to window with focus. * Called when mouse should be moved to window with focus.
*/ */
void void
gui_mouse_correct(void) gui_mouse_correct(void)
{ {
int x, y;
win_T *wp = NULL; win_T *wp = NULL;
need_mouse_correct = FALSE; need_mouse_correct = FALSE;
if (!(gui.in_use && p_mousef)) wp = gui_mouse_window(IGNORE_POPUP);
return;
gui_mch_getmouse(&x, &y);
/* Don't move the mouse when it's left or right of the Vim window */
if (x < 0 || x > Columns * gui.char_width)
return;
if (y >= 0 && Y_2_ROW(y) >= tabline_height())
wp = xy2win(x, y);
if (wp != curwin && wp != NULL) /* If in other than current window */ if (wp != curwin && wp != NULL) /* If in other than current window */
{ {
validate_cline_row(); validate_cline_row();
@ -4963,7 +4974,7 @@ gui_mouse_correct(void)
* As a side effect update the shape of the mouse pointer. * As a side effect update the shape of the mouse pointer.
*/ */
static win_T * static win_T *
xy2win(int x, int y) xy2win(int x, int y, mouse_find_T popup)
{ {
int row; int row;
int col; int col;
@ -4973,7 +4984,7 @@ xy2win(int x, int y)
col = X_2_COL(x); col = X_2_COL(x);
if (row < 0 || col < 0) /* before first window */ if (row < 0 || col < 0) /* before first window */
return NULL; return NULL;
wp = mouse_find_win(&row, &col, FALSE); wp = mouse_find_win(&row, &col, popup);
if (wp == NULL) if (wp == NULL)
return NULL; return NULL;
#ifdef FEAT_MOUSESHAPE #ifdef FEAT_MOUSESHAPE

View File

@ -4262,6 +4262,32 @@ _OnMouseWheel(
if (mouse_scroll_lines == 0) if (mouse_scroll_lines == 0)
init_mouse_wheel(); init_mouse_wheel();
#ifdef FEAT_TEXT_PROP
{
win_T *wp = gui_mouse_window(FIND_POPUP);
if (wp != NULL && popup_is_popup(wp))
{
cmdarg_T cap;
oparg_T oa;
// Mouse hovers over popup window, scroll it if possible.
mouse_row = wp->w_winrow;
mouse_col = wp->w_wincol;
vim_memset(&cap, 0, sizeof(cap));
cap.arg = zDelta < 0 ? MSCR_UP : MSCR_DOWN;
cap.cmdchar = zDelta < 0 ? K_MOUSEUP : K_MOUSEDOWN;
clear_oparg(&oa);
cap.oap = &oa;
nv_mousescroll(&cap);
update_screen(0);
setcursor();
out_flush();
return;
}
}
#endif
mch_disable_flush(); mch_disable_flush();
if (mouse_scroll_lines > 0 if (mouse_scroll_lines > 0
&& mouse_scroll_lines < (size > 2 ? size - 2 : 1)) && mouse_scroll_lines < (size > 2 ? size - 2 : 1))

View File

@ -52,6 +52,7 @@ int gui_get_lightness(guicolor_T pixel);
void gui_new_scrollbar_colors(void); void gui_new_scrollbar_colors(void);
void gui_focus_change(int in_focus); void gui_focus_change(int in_focus);
void gui_mouse_moved(int x, int y); void gui_mouse_moved(int x, int y);
win_T *gui_mouse_window(mouse_find_T popup);
void gui_mouse_correct(void); void gui_mouse_correct(void);
void ex_gui(exarg_T *eap); void ex_gui(exarg_T *eap);
int gui_find_bitmap(char_u *name, char_u *buffer, char *ext); int gui_find_bitmap(char_u *name, char_u *buffer, char *ext);

View File

@ -741,6 +741,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 */
/**/
2254,
/**/ /**/
2253, 2253,
/**/ /**/