Fall back to polling normally if not operating the win32 message loop In this condition, we cannot safely wait/wake on events.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
diff --git a/src/events/SDL_events.c b/src/events/SDL_events.c
index 4f8f91c..69990cf 100644
--- a/src/events/SDL_events.c
+++ b/src/events/SDL_events.c
@@ -817,7 +817,7 @@ SDL_WaitEventTimeout_Device(_THIS, SDL_Window *wakeup_window, SDL_Event * event,
_this->wakeup_window = NULL;
if (status <= 0) {
/* There is either an error or the timeout is elapsed: return */
- return 0;
+ return status;
}
/* An event was found and pumped into the SDL events queue. Continue the loop
to let SDL_PeepEvents pick it up .*/
@@ -880,7 +880,13 @@ SDL_WaitEventTimeout(SDL_Event * event, int timeout)
}
if (!need_polling && _this && _this->WaitEventTimeout && _this->SendWakeupEvent) {
- return SDL_WaitEventTimeout_Device(_this, wakeup_window, event, timeout);
+ int status = SDL_WaitEventTimeout_Device(_this, wakeup_window, event, timeout);
+
+ /* There may be implementation-defined conditions where the backend cannot
+ reliably wait for the next event. If that happens, fall back to polling */
+ if (status >= 0) {
+ return status;
+ }
}
for (;;) {
diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c
index a8108a8..2d47759 100644
--- a/src/video/windows/SDL_windowsevents.c
+++ b/src/video/windows/SDL_windowsevents.c
@@ -1303,9 +1303,13 @@ WIN_WaitEventTimeout(_THIS, int timeout)
TranslateMessage(&msg);
DispatchMessage(&msg);
return 1;
+ } else {
+ return 0;
}
+ } else {
+ /* Fail the wait so the caller falls back to polling */
+ return -1;
}
- return 0;
}
void