From 6e3242848fd409a65421dd097735170ce99d2982 Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Thu, 8 Feb 2024 10:05:29 -0800 Subject: [PATCH] wm_mousewheel and wm_mousehwheel report mouse coordinates in screen space, not client space; fix to account fo rthat --- src/os/gfx/win32/os_gfx_win32.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/os/gfx/win32/os_gfx_win32.c b/src/os/gfx/win32/os_gfx_win32.c index 740c4936..a4d97f67 100644 --- a/src/os/gfx/win32/os_gfx_win32.c +++ b/src/os/gfx/win32/os_gfx_win32.c @@ -440,8 +440,12 @@ w32_wnd_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { S16 wheel_delta = HIWORD(wParam); OS_Event *event = w32_push_event(OS_EventKind_Scroll, window); - event->pos.x = (F32)LOWORD(lParam); - event->pos.y = (F32)HIWORD(lParam); + POINT p; + p.x = (S32)LOWORD(lParam); + p.y = (S32)HIWORD(lParam); + ScreenToClient(window->hwnd, &p); + event->pos.x = (F32)p.x; + event->pos.y = (F32)p.y; event->delta = v2f32(0.f, -(F32)wheel_delta); }break; @@ -449,8 +453,12 @@ w32_wnd_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { S16 wheel_delta = HIWORD(wParam); OS_Event *event = w32_push_event(OS_EventKind_Scroll, window); - event->pos.x = (F32)LOWORD(lParam); - event->pos.y = (F32)HIWORD(lParam); + POINT p; + p.x = (S32)LOWORD(lParam); + p.y = (S32)HIWORD(lParam); + ScreenToClient(window->hwnd, &p); + event->pos.x = (F32)p.x; + event->pos.y = (F32)p.y; event->delta = v2f32((F32)wheel_delta, 0.f); }break;