mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-06 19:38:14 +00:00
GDK: Partially revert 2670eb44af
MsgWaitForMultipleObjects is desktop-only.
(cherry picked from commit e1e5d33420
)
This commit is contained in:
@@ -1803,6 +1803,7 @@ void SDL_SetWindowsMessageHook(SDL_WindowsMessageHook callback, void *userdata)
|
|||||||
int WIN_WaitEventTimeout(_THIS, int timeout)
|
int WIN_WaitEventTimeout(_THIS, int timeout)
|
||||||
{
|
{
|
||||||
if (g_WindowsEnableMessageLoop) {
|
if (g_WindowsEnableMessageLoop) {
|
||||||
|
#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__)
|
||||||
DWORD dwMilliseconds, ret;
|
DWORD dwMilliseconds, ret;
|
||||||
dwMilliseconds = timeout < 0 ? INFINITE : (DWORD)timeout;
|
dwMilliseconds = timeout < 0 ? INFINITE : (DWORD)timeout;
|
||||||
ret = MsgWaitForMultipleObjects(0, NULL, FALSE, dwMilliseconds, QS_ALLINPUT);
|
ret = MsgWaitForMultipleObjects(0, NULL, FALSE, dwMilliseconds, QS_ALLINPUT);
|
||||||
@@ -1811,6 +1812,35 @@ int WIN_WaitEventTimeout(_THIS, int timeout)
|
|||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
/* MsgWaitForMultipleObjects is desktop-only. */
|
||||||
|
MSG msg;
|
||||||
|
BOOL message_result;
|
||||||
|
UINT_PTR timer_id = 0;
|
||||||
|
if (timeout > 0) {
|
||||||
|
timer_id = SetTimer(NULL, 0, timeout, NULL);
|
||||||
|
message_result = GetMessage(&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);
|
||||||
|
}
|
||||||
|
if (message_result) {
|
||||||
|
if (msg.message == WM_TIMER && !msg.hwnd && msg.wParam == timer_id) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (g_WindowsMessageHook) {
|
||||||
|
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) */
|
||||||
|
TranslateMessage(&msg);
|
||||||
|
DispatchMessage(&msg);
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/
|
||||||
} else {
|
} else {
|
||||||
/* Fail the wait so the caller falls back to polling */
|
/* Fail the wait so the caller falls back to polling */
|
||||||
return -1;
|
return -1;
|
||||||
|
Reference in New Issue
Block a user