From bcc2cc8722b8f43f3169666d2558a2530d5d18a9 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Fri, 30 May 2014 01:49:26 -0400 Subject: [PATCH] Fixed hit-testing on Windows. Needed to convert from screen to client coords. --- src/video/windows/SDL_windowsevents.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c index 48cf350d39876..b04a7a20ec1d2 100644 --- a/src/video/windows/SDL_windowsevents.c +++ b/src/video/windows/SDL_windowsevents.c @@ -870,10 +870,13 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { SDL_Window *window = data->window; if (window->hit_test) { - const SDL_Point point = { (int) LOWORD(lParam), (int) HIWORD(lParam) }; - const SDL_HitTestResult rc = window->hit_test(window, &point, window->hit_test_data); - if (rc == SDL_HITTEST_DRAGGABLE) { - return HTCAPTION; + POINT winpoint = { (int) LOWORD(lParam), (int) HIWORD(lParam) }; + if (ScreenToClient(data->hwnd, &winpoint)) { + const SDL_Point point = { (int) winpoint.x, (int) winpoint.y }; + const SDL_HitTestResult rc = window->hit_test(window, &point, window->hit_test_data); + if (rc == SDL_HITTEST_DRAGGABLE) { + return HTCAPTION; + } } // if we didn't return, this will call DefWindowProc below. }