comparison src/gui_w32.c @ 28825:4c749f9b97fd v8.2.4936

patch 8.2.4936: MS-Windows: mouse coordinates for scroll event are wrong Commit: https://github.com/vim/vim/commit/a773d84570e224035389f6697ac5634d7f27cccc Author: LemonBoy <thatlemon@gmail.com> Date: Tue May 10 20:54:46 2022 +0100 patch 8.2.4936: MS-Windows: mouse coordinates for scroll event are wrong Problem: MS-Windows: mouse coordinates for scroll event are wrong. Solution: Convert coordinates to the text area coordinates. (closes https://github.com/vim/vim/issues/10400)
author Bram Moolenaar <Bram@vim.org>
date Tue, 10 May 2022 22:00:02 +0200
parents a4f439f4df0b
children d2ef7d649fcb
comparison
equal deleted inserted replaced
28824:08e9b779b213 28825:4c749f9b97fd
4144 mouse_set_vert_scroll_step(mouse_vertical_scroll_step()); 4144 mouse_set_vert_scroll_step(mouse_vertical_scroll_step());
4145 mouse_set_hor_scroll_step(mouse_horizontal_scroll_step()); 4145 mouse_set_hor_scroll_step(mouse_horizontal_scroll_step());
4146 } 4146 }
4147 4147
4148 /* 4148 /*
4149 * Intellimouse wheel handler. 4149 * Mouse scroll event handler.
4150 * Treat a mouse wheel event as if it were a scroll request.
4151 */ 4150 */
4152 static void 4151 static void
4153 _OnMouseWheel(HWND hwnd, short zDelta, LPARAM param, int horizontal) 4152 _OnMouseWheel(HWND hwnd, WPARAM wParam, LPARAM lParam, int horizontal)
4154 { 4153 {
4155 int button; 4154 int button;
4156 win_T *wp; 4155 win_T *wp;
4157 int modifiers, kbd_modifiers; 4156 int modifiers, kbd_modifiers;
4157 int zDelta = GET_WHEEL_DELTA_WPARAM(wParam);
4158 POINT pt;
4158 4159
4159 wp = gui_mouse_window(FIND_POPUP); 4160 wp = gui_mouse_window(FIND_POPUP);
4160 4161
4161 #ifdef FEAT_PROP_POPUP 4162 #ifdef FEAT_PROP_POPUP
4162 if (wp != NULL && popup_is_popup(wp)) 4163 if (wp != NULL && popup_is_popup(wp))
4205 if ((kbd_modifiers & MOD_MASK_CTRL) != 0) 4206 if ((kbd_modifiers & MOD_MASK_CTRL) != 0)
4206 modifiers |= MOUSE_CTRL; 4207 modifiers |= MOUSE_CTRL;
4207 if ((kbd_modifiers & MOD_MASK_ALT) != 0) 4208 if ((kbd_modifiers & MOD_MASK_ALT) != 0)
4208 modifiers |= MOUSE_ALT; 4209 modifiers |= MOUSE_ALT;
4209 4210
4210 mch_disable_flush(); 4211 // The cursor position is relative to the upper-left corner of the screen.
4211 gui_send_mouse_event(button, GET_X_LPARAM(param), GET_Y_LPARAM(param), 4212 pt.x = GET_X_LPARAM(lParam);
4212 FALSE, kbd_modifiers); 4213 pt.y = GET_Y_LPARAM(lParam);
4213 mch_enable_flush(); 4214 ScreenToClient(s_textArea, &pt);
4214 gui_may_flush(); 4215
4216 gui_send_mouse_event(button, pt.x, pt.y, FALSE, kbd_modifiers);
4215 } 4217 }
4216 4218
4217 #ifdef USE_SYSMENU_FONT 4219 #ifdef USE_SYSMENU_FONT
4218 /* 4220 /*
4219 * Get Menu Font. 4221 * Get Menu Font.
4661 HWND hwnd, 4663 HWND hwnd,
4662 UINT uMsg, 4664 UINT uMsg,
4663 WPARAM wParam, 4665 WPARAM wParam,
4664 LPARAM lParam) 4666 LPARAM lParam)
4665 { 4667 {
4666 // TRACE("WndProc: hwnd = %08x, msg = %x, wParam = %x, lParam = %x\n", 4668 // ch_log(NULL, "WndProc: hwnd = %08x, msg = %x, wParam = %x, lParam = %x",
4667 // hwnd, uMsg, wParam, lParam); 4669 // hwnd, uMsg, wParam, lParam);
4668 4670
4669 HandleMouseHide(uMsg, lParam); 4671 HandleMouseHide(uMsg, lParam);
4670 4672
4671 s_uMsg = uMsg; 4673 s_uMsg = uMsg;
4672 s_wParam = wParam; 4674 s_wParam = wParam;
4761 case WM_SIZING: // HANDLE_MSG doesn't seem to handle this one 4763 case WM_SIZING: // HANDLE_MSG doesn't seem to handle this one
4762 return _DuringSizing((UINT)wParam, (LPRECT)lParam); 4764 return _DuringSizing((UINT)wParam, (LPRECT)lParam);
4763 4765
4764 case WM_MOUSEWHEEL: 4766 case WM_MOUSEWHEEL:
4765 case WM_MOUSEHWHEEL: 4767 case WM_MOUSEHWHEEL:
4766 _OnMouseWheel(hwnd, HIWORD(wParam), lParam, uMsg == WM_MOUSEHWHEEL); 4768 _OnMouseWheel(hwnd, wParam, lParam, uMsg == WM_MOUSEHWHEEL);
4767 return 0L; 4769 return 0L;
4768 4770
4769 // Notification for change in SystemParametersInfo() 4771 // Notification for change in SystemParametersInfo()
4770 case WM_SETTINGCHANGE: 4772 case WM_SETTINGCHANGE:
4771 return _OnSettingChange((UINT)wParam); 4773 return _OnSettingChange((UINT)wParam);