Skip to content

Commit

Permalink
Added SDL_SetWindowsMessageHook() to facilitate full IME support on W…
Browse files Browse the repository at this point in the history
…indows
  • Loading branch information
slouken committed May 14, 2015
1 parent 094c4a1 commit 7de242e
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions include/SDL_system.h
Expand Up @@ -42,6 +42,12 @@ extern "C" {

/* Platform specific functions for Windows */
#ifdef __WIN32__

/**
\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);

/**
\brief Returns the D3D9 adapter index that matches the specified display index.
Expand Down
1 change: 1 addition & 0 deletions src/dynapi/SDL_dynapi_overrides.h
Expand Up @@ -592,3 +592,4 @@
#define SDL_GetQueuedAudioSize SDL_GetQueuedAudioSize_REAL
#define SDL_ClearQueuedAudio SDL_ClearQueuedAudio_REAL
#define SDL_GetGrabbedWindow SDL_GetGrabbedWindow_REAL
#define SDL_SetWindowsMessageHook SDL_SetWindowsMessageHook_REAL
1 change: 1 addition & 0 deletions src/dynapi/SDL_dynapi_procs.h
Expand Up @@ -624,3 +624,4 @@ SDL_DYNAPI_PROC(int,SDL_QueueAudio,(SDL_AudioDeviceID a, const void *b, Uint32 c
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)
SDL_DYNAPI_PROC(void,SDL_SetWindowsMessageHook,(SDL_WindowsMessageHook a),(a),)
Empty file modified src/video/SDL_egl.c 100755 → 100644
Empty file.
13 changes: 13 additions & 0 deletions src/video/windows/SDL_windowsevents.c
Expand Up @@ -24,6 +24,7 @@

#include "SDL_windowsvideo.h"
#include "SDL_windowsshape.h"
#include "SDL_system.h"
#include "SDL_syswm.h"
#include "SDL_timer.h"
#include "SDL_vkeys.h"
Expand Down Expand Up @@ -925,6 +926,14 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
}
}

/* A message hook called before TranslateMessage() */
static SDL_WindowsMessageHook g_WindowsMessageHook = NULL;

void SDL_SetWindowsMessageHook(SDL_WindowsMessageHook callback)
{
g_WindowsMessageHook = callback;
}

void
WIN_PumpEvents(_THIS)
{
Expand All @@ -934,6 +943,10 @@ 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);
}

/* Always translate the message in case it's a non-SDL window (e.g. with Qt integration) */
TranslateMessage(&msg);
DispatchMessage(&msg);
Expand Down

0 comments on commit 7de242e

Please sign in to comment.