Added a userdata parameter to SDL_SetWindowsMessageHook()
authorSam Lantinga <slouken@libsdl.org>
Wed, 13 May 2015 22:39:32 -0700
changeset 9599223fbcc6a327
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
     1.1 --- a/include/SDL_system.h	Wed May 13 22:39:27 2015 -0700
     1.2 +++ b/include/SDL_system.h	Wed May 13 22:39:32 2015 -0700
     1.3 @@ -46,8 +46,8 @@
     1.4  /**
     1.5     \brief Set a function that is called for every windows message, before TranslateMessage()
     1.6  */
     1.7 -typedef void (*SDL_WindowsMessageHook)(void *hWnd, unsigned int message, Uint64 wParam, Sint64 lParam);
     1.8 -extern DECLSPEC void SDLCALL SDL_SetWindowsMessageHook(SDL_WindowsMessageHook callback);
     1.9 +typedef void (SDLCALL * SDL_WindowsMessageHook)(void *userdata, void *hWnd, unsigned int message, Uint64 wParam, Sint64 lParam);
    1.10 +extern DECLSPEC void SDLCALL SDL_SetWindowsMessageHook(SDL_WindowsMessageHook callback, void *userdata);
    1.11  
    1.12  /**
    1.13     \brief Returns the D3D9 adapter index that matches the specified display index.
     2.1 --- a/src/dynapi/SDL_dynapi_procs.h	Wed May 13 22:39:27 2015 -0700
     2.2 +++ b/src/dynapi/SDL_dynapi_procs.h	Wed May 13 22:39:32 2015 -0700
     2.3 @@ -625,5 +625,5 @@
     2.4  SDL_DYNAPI_PROC(void,SDL_ClearQueuedAudio,(SDL_AudioDeviceID a),(a),)
     2.5  SDL_DYNAPI_PROC(SDL_Window*,SDL_GetGrabbedWindow,(void),(),return)
     2.6  #ifdef __WIN32__
     2.7 -SDL_DYNAPI_PROC(void,SDL_SetWindowsMessageHook,(SDL_WindowsMessageHook a),(a),)
     2.8 +SDL_DYNAPI_PROC(void,SDL_SetWindowsMessageHook,(SDL_WindowsMessageHook a, void *b),(a,b),)
     2.9  #endif
     3.1 --- a/src/video/windows/SDL_windowsevents.c	Wed May 13 22:39:27 2015 -0700
     3.2 +++ b/src/video/windows/SDL_windowsevents.c	Wed May 13 22:39:32 2015 -0700
     3.3 @@ -928,10 +928,12 @@
     3.4  
     3.5  /* A message hook called before TranslateMessage() */
     3.6  static SDL_WindowsMessageHook g_WindowsMessageHook = NULL;
     3.7 +static void *g_WindowsMessageHookData = NULL;
     3.8  
     3.9 -void SDL_SetWindowsMessageHook(SDL_WindowsMessageHook callback)
    3.10 +void SDL_SetWindowsMessageHook(SDL_WindowsMessageHook callback, void *userdata)
    3.11  {
    3.12      g_WindowsMessageHook = callback;
    3.13 +    g_WindowsMessageHookData = userdata;
    3.14  }
    3.15  
    3.16  void
    3.17 @@ -944,7 +946,7 @@
    3.18      if (g_WindowsEnableMessageLoop) {
    3.19          while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
    3.20              if (g_WindowsMessageHook) {
    3.21 -                g_WindowsMessageHook(msg.hwnd, msg.message, msg.wParam, msg.lParam);
    3.22 +                g_WindowsMessageHook(g_WindowsMessageHookData, msg.hwnd, msg.message, msg.wParam, msg.lParam);
    3.23              }
    3.24  
    3.25              /* Always translate the message in case it's a non-SDL window (e.g. with Qt integration) */