mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-06-05 22:30:29 +00:00
Merge 257c0b8cd7 into 5f25ce9282
This commit is contained in:
commit
ce3ae93690
2 changed files with 29 additions and 2 deletions
|
|
@ -55,6 +55,14 @@ typedef void (SDLCALL * SDL_WindowsMessageHook)(void *userdata, void *hWnd, unsi
|
|||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_SetWindowsMessageHook(SDL_WindowsMessageHook callback, void *userdata);
|
||||
|
||||
// the return value is BOOL
|
||||
typedef int(SDLCALL *SDL_WindowsGetMessageImpl)(void *userdata, void *lpMsg, void *hWnd, unsigned int wMsgFilterMin, unsigned int wMsgFilterMax);
|
||||
|
||||
/**
|
||||
* Set a GetMessage implement, for blocking etc.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_SetWindowsGetMessageImpl(SDL_WindowsGetMessageImpl callback, void *userdata);
|
||||
|
||||
#endif /* defined(__WIN32__) || defined(__GDK__) */
|
||||
|
||||
#if defined(__WIN32__) || defined(__WINGDK__)
|
||||
|
|
|
|||
|
|
@ -1886,6 +1886,25 @@ void SDL_SetWindowsMessageHook(SDL_WindowsMessageHook callback, void *userdata)
|
|||
g_WindowsMessageHookData = userdata;
|
||||
}
|
||||
|
||||
// A user implement API: GetMessage
|
||||
static SDL_WindowsGetMessageImpl g_WindowsGetMessageImpl = NULL;
|
||||
static void *g_WindowsGetMessageImplData = NULL;
|
||||
|
||||
void SDLCALL SDL_SetWindowsGetMessageImpl(SDL_WindowsGetMessageImpl callback, void* userdata)
|
||||
{
|
||||
g_WindowsGetMessageImpl = callback;
|
||||
g_WindowsGetMessageImplData = userdata;
|
||||
}
|
||||
|
||||
static BOOL GetMessageImpl(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax)
|
||||
{
|
||||
if (g_WindowsGetMessageImpl)
|
||||
{
|
||||
return g_WindowsGetMessageImpl(g_WindowsGetMessageImplData, lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax);
|
||||
}
|
||||
return GetMessage(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax);
|
||||
}
|
||||
|
||||
int WIN_WaitEventTimeout(_THIS, int timeout)
|
||||
{
|
||||
if (g_WindowsEnableMessageLoop) {
|
||||
|
|
@ -1905,12 +1924,12 @@ int WIN_WaitEventTimeout(_THIS, int timeout)
|
|||
UINT_PTR timer_id = 0;
|
||||
if (timeout > 0) {
|
||||
timer_id = SetTimer(NULL, 0, timeout, NULL);
|
||||
message_result = GetMessage(&msg, 0, 0, 0);
|
||||
message_result = GetMessageImpl(&msg, 0, 0, 0);
|
||||
KillTimer(NULL, timer_id);
|
||||
} else if (timeout == 0) {
|
||||
message_result = PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);
|
||||
} else {
|
||||
message_result = GetMessage(&msg, 0, 0, 0);
|
||||
message_result = GetMessageImpl(&msg, 0, 0, 0);
|
||||
}
|
||||
if (message_result) {
|
||||
if (msg.message == WM_TIMER && !msg.hwnd && msg.wParam == timer_id) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue