First shot (not even compiled) at Windows hit-testing support.
authorRyan C. Gordon <icculus@icculus.org>
Thu, 29 May 2014 13:39:02 -0400
changeset 8938 c73bac338b90
parent 8937 e5caf226926d
child 8939 caaa7653f02b
First shot (not even compiled) at Windows hit-testing support.
src/video/windows/SDL_windowsevents.c
src/video/windows/SDL_windowsvideo.c
src/video/windows/SDL_windowswindow.c
src/video/windows/SDL_windowswindow.h
--- a/src/video/windows/SDL_windowsevents.c	Thu May 29 13:38:39 2014 -0400
+++ b/src/video/windows/SDL_windowsevents.c	Thu May 29 13:39:02 2014 -0400
@@ -865,6 +865,21 @@
             return 0;
         }
         break;
+
+    case WM_NCHITTEST:
+        {
+            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;
+                }
+                // if we didn't return, this will call DefWindowProc below.
+            }
+        }
+        break;
+
     }
 
     /* If there's a window proc, assume it's going to handle messages */
--- a/src/video/windows/SDL_windowsvideo.c	Thu May 29 13:38:39 2014 -0400
+++ b/src/video/windows/SDL_windowsvideo.c	Thu May 29 13:39:02 2014 -0400
@@ -121,6 +121,7 @@
     device->UpdateWindowFramebuffer = WIN_UpdateWindowFramebuffer;
     device->DestroyWindowFramebuffer = WIN_DestroyWindowFramebuffer;
     device->OnWindowEnter = WIN_OnWindowEnter;
+    device->SetWindowHitTest = WIN_SetWindowHitTest;
 
     device->shape_driver.CreateShaper = Win32_CreateShaper;
     device->shape_driver.SetWindowShape = Win32_SetWindowShape;
--- a/src/video/windows/SDL_windowswindow.c	Thu May 29 13:38:39 2014 -0400
+++ b/src/video/windows/SDL_windowswindow.c	Thu May 29 13:39:02 2014 -0400
@@ -782,6 +782,12 @@
     }
 }
 
+int
+WIN_SetWindowHitTest(SDL_Window *window, SDL_bool enabled)
+{
+    return 0;  /* just succeed, the real work is done elsewhere. */
+}
+
 #endif /* SDL_VIDEO_DRIVER_WINDOWS */
 
 /* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/windows/SDL_windowswindow.h	Thu May 29 13:38:39 2014 -0400
+++ b/src/video/windows/SDL_windowswindow.h	Thu May 29 13:39:02 2014 -0400
@@ -68,6 +68,7 @@
                                     struct SDL_SysWMinfo *info);
 extern void WIN_OnWindowEnter(_THIS, SDL_Window * window);
 extern void WIN_UpdateClipCursor(SDL_Window *window);
+extern int WIN_SetWindowHitTest(SDL_Window *window, SDL_bool enabled);
 
 #endif /* _SDL_windowswindow_h */