Skip to content
Permalink
Browse files

Added a userdata parameter to SDL_SetWindowsMessageHook()

  • Loading branch information
slouken committed May 14, 2015
1 parent b2be925 commit 1c6ea0f226505001038c70687fbf39d72cafca02
Showing with 7 additions and 5 deletions.
  1. +2 −2 include/SDL_system.h
  2. +1 −1 src/dynapi/SDL_dynapi_procs.h
  3. +4 −2 src/video/windows/SDL_windowsevents.c
@@ -46,8 +46,8 @@ extern "C" {
/**
\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.
@@ -625,5 +625,5 @@ SDL_DYNAPI_PROC(Uint32,SDL_GetQueuedAudioSize,(SDL_AudioDeviceID a),(a),return)
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
@@ -928,10 +928,12 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)

/* 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 @@ WIN_PumpEvents(_THIS)
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) */

0 comments on commit 1c6ea0f

Please sign in to comment.