From e13b43ac212a578836943d59a9dd17ac86313835 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 5 Jun 2021 12:44:08 -0500 Subject: [PATCH] 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). --- src/events/SDL_events.c | 4 +--- src/video/SDL_sysvideo.h | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/events/SDL_events.c b/src/events/SDL_events.c index cefe885a7..458d8a8c1 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 4491a4e59..086166d24 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;