Mercurial > vim
comparison src/gui.c @ 18520:6067fbb46625 v8.1.2254
patch 8.1.2254: MS-Windows: mouse scroll wheel doesn't work in popup
Commit: https://github.com/vim/vim/commit/0630bb6580237fe01db22a84885c10f12580f7af
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Nov 4 22:52:12 2019 +0100
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 https://github.com/vim/vim/issues/5138)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 04 Nov 2019 23:00:04 +0100 |
parents | 34d5cd432cac |
children | bbea1f108187 |
comparison
equal
deleted
inserted
replaced
18519:66bcf00b61df | 18520:6067fbb46625 |
---|---|
29 #endif | 29 #endif |
30 static void gui_do_scrollbar(win_T *wp, int which, int enable); | 30 static void gui_do_scrollbar(win_T *wp, int which, int enable); |
31 static void gui_update_horiz_scrollbar(int); | 31 static void gui_update_horiz_scrollbar(int); |
32 static void gui_set_fg_color(char_u *name); | 32 static void gui_set_fg_color(char_u *name); |
33 static void gui_set_bg_color(char_u *name); | 33 static void gui_set_bg_color(char_u *name); |
34 static win_T *xy2win(int x, int y); | 34 static win_T *xy2win(int x, int y, mouse_find_T popup); |
35 | 35 |
36 #ifdef GUI_MAY_FORK | 36 #ifdef GUI_MAY_FORK |
37 static void gui_do_fork(void); | 37 static void gui_do_fork(void); |
38 | 38 |
39 static int gui_read_child_pipe(int fd); | 39 static int gui_read_child_pipe(int fd); |
4850 win_T *wp; | 4850 win_T *wp; |
4851 char_u st[8]; | 4851 char_u st[8]; |
4852 | 4852 |
4853 #ifdef FEAT_MOUSESHAPE | 4853 #ifdef FEAT_MOUSESHAPE |
4854 /* Get window pointer, and update mouse shape as well. */ | 4854 /* Get window pointer, and update mouse shape as well. */ |
4855 wp = xy2win(x, y); | 4855 wp = xy2win(x, y, IGNORE_POPUP); |
4856 #endif | 4856 #endif |
4857 | 4857 |
4858 /* Only handle this when 'mousefocus' set and ... */ | 4858 /* Only handle this when 'mousefocus' set and ... */ |
4859 if (p_mousef | 4859 if (p_mousef |
4860 && !hold_gui_events /* not holding events */ | 4860 && !hold_gui_events /* not holding events */ |
4866 { | 4866 { |
4867 /* Don't move the mouse when it's left or right of the Vim window */ | 4867 /* Don't move the mouse when it's left or right of the Vim window */ |
4868 if (x < 0 || x > Columns * gui.char_width) | 4868 if (x < 0 || x > Columns * gui.char_width) |
4869 return; | 4869 return; |
4870 #ifndef FEAT_MOUSESHAPE | 4870 #ifndef FEAT_MOUSESHAPE |
4871 wp = xy2win(x, y); | 4871 wp = xy2win(x, y, IGNORE_POPUP); |
4872 #endif | 4872 #endif |
4873 if (wp == curwin || wp == NULL) | 4873 if (wp == curwin || wp == NULL) |
4874 return; /* still in the same old window, or none at all */ | 4874 return; /* still in the same old window, or none at all */ |
4875 | 4875 |
4876 /* Ignore position in the tab pages line. */ | 4876 /* Ignore position in the tab pages line. */ |
4928 gui_send_mouse_event(MOUSE_DRAG, x, y, FALSE, 0); | 4928 gui_send_mouse_event(MOUSE_DRAG, x, y, FALSE, 0); |
4929 #endif | 4929 #endif |
4930 } | 4930 } |
4931 | 4931 |
4932 /* | 4932 /* |
4933 * Get the window where the mouse pointer is on. | |
4934 * Returns NULL if not found. | |
4935 */ | |
4936 win_T * | |
4937 gui_mouse_window(mouse_find_T popup) | |
4938 { | |
4939 int x, y; | |
4940 | |
4941 if (!(gui.in_use && (p_mousef || popup == FIND_POPUP))) | |
4942 return NULL; | |
4943 gui_mch_getmouse(&x, &y); | |
4944 | |
4945 // Only use the mouse when it's on the Vim window | |
4946 if (x >= 0 && x <= Columns * gui.char_width | |
4947 && y >= 0 && Y_2_ROW(y) >= tabline_height()) | |
4948 return xy2win(x, y, popup); | |
4949 return NULL; | |
4950 } | |
4951 | |
4952 /* | |
4933 * Called when mouse should be moved to window with focus. | 4953 * Called when mouse should be moved to window with focus. |
4934 */ | 4954 */ |
4935 void | 4955 void |
4936 gui_mouse_correct(void) | 4956 gui_mouse_correct(void) |
4937 { | 4957 { |
4938 int x, y; | |
4939 win_T *wp = NULL; | 4958 win_T *wp = NULL; |
4940 | 4959 |
4941 need_mouse_correct = FALSE; | 4960 need_mouse_correct = FALSE; |
4942 | 4961 |
4943 if (!(gui.in_use && p_mousef)) | 4962 wp = gui_mouse_window(IGNORE_POPUP); |
4944 return; | |
4945 | |
4946 gui_mch_getmouse(&x, &y); | |
4947 /* Don't move the mouse when it's left or right of the Vim window */ | |
4948 if (x < 0 || x > Columns * gui.char_width) | |
4949 return; | |
4950 if (y >= 0 && Y_2_ROW(y) >= tabline_height()) | |
4951 wp = xy2win(x, y); | |
4952 if (wp != curwin && wp != NULL) /* If in other than current window */ | 4963 if (wp != curwin && wp != NULL) /* If in other than current window */ |
4953 { | 4964 { |
4954 validate_cline_row(); | 4965 validate_cline_row(); |
4955 gui_mch_setmouse((int)W_ENDCOL(curwin) * gui.char_width - 3, | 4966 gui_mch_setmouse((int)W_ENDCOL(curwin) * gui.char_width - 3, |
4956 (W_WINROW(curwin) + curwin->w_wrow) * gui.char_height | 4967 (W_WINROW(curwin) + curwin->w_wrow) * gui.char_height |
4961 /* | 4972 /* |
4962 * Find window where the mouse pointer "x" / "y" coordinate is in. | 4973 * Find window where the mouse pointer "x" / "y" coordinate is in. |
4963 * As a side effect update the shape of the mouse pointer. | 4974 * As a side effect update the shape of the mouse pointer. |
4964 */ | 4975 */ |
4965 static win_T * | 4976 static win_T * |
4966 xy2win(int x, int y) | 4977 xy2win(int x, int y, mouse_find_T popup) |
4967 { | 4978 { |
4968 int row; | 4979 int row; |
4969 int col; | 4980 int col; |
4970 win_T *wp; | 4981 win_T *wp; |
4971 | 4982 |
4972 row = Y_2_ROW(y); | 4983 row = Y_2_ROW(y); |
4973 col = X_2_COL(x); | 4984 col = X_2_COL(x); |
4974 if (row < 0 || col < 0) /* before first window */ | 4985 if (row < 0 || col < 0) /* before first window */ |
4975 return NULL; | 4986 return NULL; |
4976 wp = mouse_find_win(&row, &col, FALSE); | 4987 wp = mouse_find_win(&row, &col, popup); |
4977 if (wp == NULL) | 4988 if (wp == NULL) |
4978 return NULL; | 4989 return NULL; |
4979 #ifdef FEAT_MOUSESHAPE | 4990 #ifdef FEAT_MOUSESHAPE |
4980 if (State == HITRETURN || State == ASKMORE) | 4991 if (State == HITRETURN || State == ASKMORE) |
4981 { | 4992 { |