Don't skip sending wakeups for the current thread

We can be in a situation where we receive a win32 hook callback on the same
thread that is currently waiting. In that case, we do still need to trigger
a wakeup when an event is pushed because the hook itself won't necessarily
do that (depending on what we return from the hook).
main
Cameron Gutman 2021-06-05 12:44:08 -05:00 committed by Sam Lantinga
parent b992b915e5
commit e13b43ac21
2 changed files with 1 additions and 4 deletions

View File

@ -594,7 +594,7 @@ SDL_SendWakeupEvent()
return 0;
}
if (!_this->wakeup_lock || SDL_LockMutex(_this->wakeup_lock) == 0) {
if (_this->wakeup_window && _this->blocking_thread_id != 0 && _this->blocking_thread_id != SDL_ThreadID()) {
if (_this->wakeup_window) {
_this->SendWakeupEvent(_this, _this->wakeup_window);
}
if (_this->wakeup_lock) {
@ -794,10 +794,8 @@ SDL_WaitEventTimeout_Device(_THIS, SDL_Window *wakeup_window, SDL_Event * event,
/* If status == 0 we are going to block so wakeup will be needed. */
if (status == 0) {
_this->wakeup_window = wakeup_window;
_this->blocking_thread_id = SDL_ThreadID();
} else {
_this->wakeup_window = NULL;
_this->blocking_thread_id = 0;
}
if (_this->wakeup_lock) {
SDL_UnlockMutex(_this->wakeup_lock);

View File

@ -328,7 +328,6 @@ struct SDL_VideoDevice
SDL_bool is_dummy;
SDL_bool suspend_screensaver;
SDL_Window *wakeup_window;
SDL_threadID blocking_thread_id;
SDL_mutex *wakeup_lock; /* Initialized only if WaitEventTimeout/SendWakeupEvent are supported */
int num_displays;
SDL_VideoDisplay *displays;