SDL: x11: Cancel the mode switch timer immediately upon success

From 01195c5d3212da93be7e50d98c12aa7f5f7d003e Mon Sep 17 00:00:00 2001
From: Frank Praznik <[EMAIL REDACTED]>
Date: Wed, 10 Apr 2024 14:18:26 -0400
Subject: [PATCH] x11: Cancel the mode switch timer immediately upon success

Prevents erroneous timeout error messages if the window is moved to another display before the timeout period elapses.
---
 src/video/x11/SDL_x11events.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c
index 4372132d4c1f2..6a90d96e39bab 100644
--- a/src/video/x11/SDL_x11events.c
+++ b/src/video/x11/SDL_x11events.c
@@ -1992,11 +1992,10 @@ void X11_PumpEvents(SDL_VideoDevice *_this)
      * fullscreen. If there is no fullscreen window past the elapsed timeout, revert the mode switch.
      */
     for (i = 0; i < _this->num_displays; ++i) {
-        if (_this->displays[i]->driverdata->mode_switch_deadline_ns &&
-            SDL_GetTicksNS() >= _this->displays[i]->driverdata->mode_switch_deadline_ns) {
+        if (_this->displays[i]->driverdata->mode_switch_deadline_ns) {
             if (_this->displays[i]->fullscreen_window) {
                 _this->displays[i]->driverdata->mode_switch_deadline_ns = 0;
-            } else {
+            } else if (SDL_GetTicksNS() >= _this->displays[i]->driverdata->mode_switch_deadline_ns) {
                 SDL_LogError(SDL_LOG_CATEGORY_VIDEO,
                              "Time out elapsed after mode switch on display %" SDL_PRIu32 " with no window becoming fullscreen; reverting", _this->displays[i]->id);
                 SDL_SetDisplayModeForDisplay(_this->displays[i], NULL);