To: vim_dev@googlegroups.com Subject: Patch 8.1.2254 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.2254 Problem: MS-Windows: mouse scroll wheel doesn't work in popup. Solution: Handle mouse wheel events separately. (closes #5138) Files: src/gui_w32.c, src/gui.c, src/proto/gui.pro *** ../vim-8.1.2253/src/gui_w32.c 2019-10-23 21:43:13.368623922 +0200 --- src/gui_w32.c 2019-11-04 22:48:17.783480656 +0100 *************** *** 4262,4267 **** --- 4262,4293 ---- if (mouse_scroll_lines == 0) 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(); if (mouse_scroll_lines > 0 && mouse_scroll_lines < (size > 2 ? size - 2 : 1)) *** ../vim-8.1.2253/src/gui.c 2019-10-18 20:53:30.697741631 +0200 --- src/gui.c 2019-11-04 22:31:23.439740964 +0100 *************** *** 31,37 **** static void gui_update_horiz_scrollbar(int); static void gui_set_fg_color(char_u *name); static void gui_set_bg_color(char_u *name); ! static win_T *xy2win(int x, int y); #ifdef GUI_MAY_FORK static void gui_do_fork(void); --- 31,37 ---- static void gui_update_horiz_scrollbar(int); static void gui_set_fg_color(char_u *name); static void gui_set_bg_color(char_u *name); ! static win_T *xy2win(int x, int y, mouse_find_T popup); #ifdef GUI_MAY_FORK static void gui_do_fork(void); *************** *** 4852,4858 **** #ifdef FEAT_MOUSESHAPE /* Get window pointer, and update mouse shape as well. */ ! wp = xy2win(x, y); #endif /* Only handle this when 'mousefocus' set and ... */ --- 4852,4858 ---- #ifdef FEAT_MOUSESHAPE /* Get window pointer, and update mouse shape as well. */ ! wp = xy2win(x, y, IGNORE_POPUP); #endif /* Only handle this when 'mousefocus' set and ... */ *************** *** 4868,4874 **** if (x < 0 || x > Columns * gui.char_width) return; #ifndef FEAT_MOUSESHAPE ! wp = xy2win(x, y); #endif if (wp == curwin || wp == NULL) return; /* still in the same old window, or none at all */ --- 4868,4874 ---- if (x < 0 || x > Columns * gui.char_width) return; #ifndef FEAT_MOUSESHAPE ! wp = xy2win(x, y, IGNORE_POPUP); #endif if (wp == curwin || wp == NULL) return; /* still in the same old window, or none at all */ *************** *** 4930,4954 **** } /* * Called when mouse should be moved to window with focus. */ void gui_mouse_correct(void) { - int x, y; win_T *wp = NULL; need_mouse_correct = FALSE; ! if (!(gui.in_use && p_mousef)) ! 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 */ { validate_cline_row(); --- 4930,4965 ---- } /* + * 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. */ void gui_mouse_correct(void) { win_T *wp = NULL; need_mouse_correct = FALSE; ! wp = gui_mouse_window(IGNORE_POPUP); if (wp != curwin && wp != NULL) /* If in other than current window */ { validate_cline_row(); *************** *** 4963,4969 **** * As a side effect update the shape of the mouse pointer. */ static win_T * ! xy2win(int x, int y) { int row; int col; --- 4974,4980 ---- * As a side effect update the shape of the mouse pointer. */ static win_T * ! xy2win(int x, int y, mouse_find_T popup) { int row; int col; *************** *** 4973,4979 **** col = X_2_COL(x); if (row < 0 || col < 0) /* before first window */ return NULL; ! wp = mouse_find_win(&row, &col, FALSE); if (wp == NULL) return NULL; #ifdef FEAT_MOUSESHAPE --- 4984,4990 ---- col = X_2_COL(x); if (row < 0 || col < 0) /* before first window */ return NULL; ! wp = mouse_find_win(&row, &col, popup); if (wp == NULL) return NULL; #ifdef FEAT_MOUSESHAPE *** ../vim-8.1.2253/src/proto/gui.pro 2019-08-20 20:13:40.330821936 +0200 --- src/proto/gui.pro 2019-11-04 22:00:13.883637966 +0100 *************** *** 52,57 **** --- 52,58 ---- void gui_new_scrollbar_colors(void); void gui_focus_change(int in_focus); void gui_mouse_moved(int x, int y); + win_T *gui_mouse_window(mouse_find_T popup); void gui_mouse_correct(void); void ex_gui(exarg_T *eap); int gui_find_bitmap(char_u *name, char_u *buffer, char *ext); *** ../vim-8.1.2253/src/version.c 2019-11-04 21:24:45.508780574 +0100 --- src/version.c 2019-11-04 22:50:43.454869021 +0100 *************** *** 743,744 **** --- 743,746 ---- { /* Add new patch number below this line */ + /**/ + 2254, /**/ -- Time is an illusion. Lunchtime doubly so. -- Ford Prefect, in Douglas Adams' "The Hitchhiker's Guide to the Galaxy" /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///