SDL: x11: Always send fullscreen dimensions except on XWayland (18017)

From 180171cad6597abcee618d6d2f992129e3d3fbe1 Mon Sep 17 00:00:00 2001
From: Frank Praznik <[EMAIL REDACTED]>
Date: Fri, 23 May 2025 11:40:01 -0400
Subject: [PATCH] x11: Always send fullscreen dimensions except on XWayland

More non-compositing window managers than just openbox seem to need this, so always force sending the window position and dimensions when entering/leaving fullscreen. If they are wrong, they will be immediately overwritten by the correct dimensions from a subsequent ConfigureNotify event.

This is disabled on XWayland, as it seems to cause hitching on some compositors.

(cherry picked from commit 0657ece55dadb316adabd5d36b81f40ba6715c21)
---
 src/video/x11/SDL_x11video.c | 27 ++-------------------------
 1 file changed, 2 insertions(+), 25 deletions(-)

diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c
index 37bef7bf8bb79..86f5b860eebd6 100644
--- a/src/video/x11/SDL_x11video.c
+++ b/src/video/x11/SDL_x11video.c
@@ -75,23 +75,6 @@ static bool X11_IsXWayland(Display *d)
     return X11_XQueryExtension(d, "XWAYLAND", &opcode, &event, &error) == True;
 }
 
-static bool X11_CheckCurrentDesktop(const char *name)
-{
-    SDL_Environment *env = SDL_GetEnvironment();
-
-    const char *desktopVar = SDL_GetEnvironmentVariable(env, "DESKTOP_SESSION");
-    if (desktopVar && SDL_strcasecmp(desktopVar, name) == 0) {
-        return true;
-    }
-
-    desktopVar = SDL_GetEnvironmentVariable(env, "XDG_CURRENT_DESKTOP");
-    if (desktopVar && SDL_strcasestr(desktopVar, name)) {
-        return true;
-    }
-
-    return false;
-}
-
 static SDL_VideoDevice *X11_CreateDevice(void)
 {
     SDL_VideoDevice *device;
@@ -270,17 +253,11 @@ static SDL_VideoDevice *X11_CreateDevice(void)
 
     device->device_caps = VIDEO_DEVICE_CAPS_HAS_POPUP_WINDOW_SUPPORT;
 
-    /* Openbox doesn't send the new window dimensions when entering fullscreen, so the events must be synthesized.
-     * This is otherwise not wanted, as it can break fullscreen window positioning on multi-monitor configurations.
-     */
-    if (!X11_CheckCurrentDesktop("openbox")) {
-        device->device_caps |= VIDEO_DEVICE_CAPS_SENDS_FULLSCREEN_DIMENSIONS;
-    }
-
     data->is_xwayland = X11_IsXWayland(x11_display);
     if (data->is_xwayland) {
         device->device_caps |= VIDEO_DEVICE_CAPS_MODE_SWITCHING_EMULATED |
-                               VIDEO_DEVICE_CAPS_DISABLE_MOUSE_WARP_ON_FULLSCREEN_TRANSITIONS;
+                               VIDEO_DEVICE_CAPS_DISABLE_MOUSE_WARP_ON_FULLSCREEN_TRANSITIONS |
+                               VIDEO_DEVICE_CAPS_SENDS_FULLSCREEN_DIMENSIONS;
     }
 
     return device;