SDL: Only queue one wakeup event per wait

From 105de64c2dba71de2c4c051f2b6ae5541ed0ac5a Mon Sep 17 00:00:00 2001
From: Cameron Gutman <[EMAIL REDACTED]>
Date: Sat, 12 Jun 2021 16:19:03 -0500
Subject: [PATCH] Only queue one wakeup event per wait

Queuing more than one can lead to a spurious wakeup on the next wait.
---
 src/events/SDL_events.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/events/SDL_events.c b/src/events/SDL_events.c
index 458d8a8c1..961d19bf2 100644
--- a/src/events/SDL_events.c
+++ b/src/events/SDL_events.c
@@ -596,6 +596,9 @@ SDL_SendWakeupEvent()
     if (!_this->wakeup_lock || SDL_LockMutex(_this->wakeup_lock) == 0) {
         if (_this->wakeup_window) {
             _this->SendWakeupEvent(_this, _this->wakeup_window);
+
+            /* No more wakeup events needed until we enter a new wait */
+            _this->wakeup_window = NULL;
         }
         if (_this->wakeup_lock) {
             SDL_UnlockMutex(_this->wakeup_lock);