SDL: video: Don't switch display modes when emulating mode changes

From 7d439b87b0d12e08579d4e6c424efdd55fbab0ca Mon Sep 17 00:00:00 2001
From: Frank Praznik <[EMAIL REDACTED]>
Date: Wed, 1 Feb 2023 18:37:34 -0500
Subject: [PATCH] video: Don't switch display modes when emulating mode changes

SDL uses window minimization to determine fullscreen window visibility and hide windows before changing the video mode back to the desktop. Wayland, however, does not have the concept of a minimized window and doesn't set the minimized flag (minimization can be requested, but what actually happens to the window is implementation dependent, and if a window is minimized via a desktop shortcut or decoration control, the application is not notified of any state changes). Make the video core mode setting a no-op so that the Wayland backend can handle reporting the display dimensions using its own internal logic.
 src/video/SDL_video.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index 45878148a6fa..ea81e12d16ce 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -1124,6 +1124,11 @@ const SDL_DisplayMode *SDL_GetCurrentDisplayMode(SDL_DisplayID displayID)
 static int SDL_SetDisplayModeForDisplay(SDL_VideoDisplay *display, SDL_DisplayMode *mode)
+    /* Mode switching is being emulated per-window; nothing to do and cannot fail. */
+    if (ModeSwitchingEmulated(_this)) {
+        return 0;
+    }
     if (!mode) {
         mode = &display->desktop_mode;