Commit e13b43ac212a578836943d59a9dd17ac86313835

Cameron Gutman 2021-06-05T12:44:08

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).

diff --git a/src/events/SDL_events.c b/src/events/SDL_events.c
index cefe885..458d8a8 100644
--- a/src/events/SDL_events.c
+++ b/src/events/SDL_events.c
@@ -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);
diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h
index 4491a4e..086166d 100644
--- a/src/video/SDL_sysvideo.h
+++ b/src/video/SDL_sysvideo.h
@@ -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;