Fixed hit-testing on Windows.
authorRyan C. Gordon <icculus@icculus.org>
Fri, 30 May 2014 01:49:26 -0400
changeset 8941 9229a54e4952
parent 8940 850e149d02d8
child 8942 3d84839c97b2
Fixed hit-testing on Windows. Needed to convert from screen to client coords.
src/video/windows/SDL_windowsevents.c
--- a/src/video/windows/SDL_windowsevents.c	Fri May 30 01:48:26 2014 -0400
+++ b/src/video/windows/SDL_windowsevents.c	Fri May 30 01:49:26 2014 -0400
@@ -870,10 +870,13 @@
         {
             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.
             }