Added a userdata parameter to SDL_SetWindowsMessageHook()
authorSam Lantinga <slouken@libsdl.org>
Wed, 13 May 2015 22:39:32 -0700
changeset 9599 223fbcc6a327
parent 9598 5f50522bf2e1
child 9600 d52c2129c9ac
Added a userdata parameter to SDL_SetWindowsMessageHook()
include/SDL_system.h
src/dynapi/SDL_dynapi_procs.h
src/video/windows/SDL_windowsevents.c
--- a/include/SDL_system.h	Wed May 13 22:39:27 2015 -0700
+++ b/include/SDL_system.h	Wed May 13 22:39:32 2015 -0700
@@ -46,8 +46,8 @@
 /**
    \brief Set a function that is called for every windows message, before TranslateMessage()
 */
-typedef void (*SDL_WindowsMessageHook)(void *hWnd, unsigned int message, Uint64 wParam, Sint64 lParam);
-extern DECLSPEC void SDLCALL SDL_SetWindowsMessageHook(SDL_WindowsMessageHook callback);
+typedef void (SDLCALL * SDL_WindowsMessageHook)(void *userdata, void *hWnd, unsigned int message, Uint64 wParam, Sint64 lParam);
+extern DECLSPEC void SDLCALL SDL_SetWindowsMessageHook(SDL_WindowsMessageHook callback, void *userdata);
 
 /**
    \brief Returns the D3D9 adapter index that matches the specified display index.
--- a/src/dynapi/SDL_dynapi_procs.h	Wed May 13 22:39:27 2015 -0700
+++ b/src/dynapi/SDL_dynapi_procs.h	Wed May 13 22:39:32 2015 -0700
@@ -625,5 +625,5 @@
 SDL_DYNAPI_PROC(void,SDL_ClearQueuedAudio,(SDL_AudioDeviceID a),(a),)
 SDL_DYNAPI_PROC(SDL_Window*,SDL_GetGrabbedWindow,(void),(),return)
 #ifdef __WIN32__
-SDL_DYNAPI_PROC(void,SDL_SetWindowsMessageHook,(SDL_WindowsMessageHook a),(a),)
+SDL_DYNAPI_PROC(void,SDL_SetWindowsMessageHook,(SDL_WindowsMessageHook a, void *b),(a,b),)
 #endif
--- a/src/video/windows/SDL_windowsevents.c	Wed May 13 22:39:27 2015 -0700
+++ b/src/video/windows/SDL_windowsevents.c	Wed May 13 22:39:32 2015 -0700
@@ -928,10 +928,12 @@
 
 /* A message hook called before TranslateMessage() */
 static SDL_WindowsMessageHook g_WindowsMessageHook = NULL;
+static void *g_WindowsMessageHookData = NULL;
 
-void SDL_SetWindowsMessageHook(SDL_WindowsMessageHook callback)
+void SDL_SetWindowsMessageHook(SDL_WindowsMessageHook callback, void *userdata)
 {
     g_WindowsMessageHook = callback;
+    g_WindowsMessageHookData = userdata;
 }
 
 void
@@ -944,7 +946,7 @@
     if (g_WindowsEnableMessageLoop) {
         while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
             if (g_WindowsMessageHook) {
-                g_WindowsMessageHook(msg.hwnd, msg.message, msg.wParam, msg.lParam);
+                g_WindowsMessageHook(g_WindowsMessageHookData, msg.hwnd, msg.message, msg.wParam, msg.lParam);
             }
 
             /* Always translate the message in case it's a non-SDL window (e.g. with Qt integration) */