From d0819bcc5cfe852ad60deab4e1ff7d5598f0b983 Mon Sep 17 00:00:00 2001 From: Joshua Ashton Date: Mon, 15 Apr 2024 00:37:59 +0100 Subject: [PATCH] x11: Mark XWayland as MODE_SWITCHING_EMULATED That way we don't do the awful minimise on focus loss logic by default on XWayland where mode switching is emulated (like on the Wayland backend). This fixes CS2, Dota 2 minimising on alt-tab when playing in fullscreen (which is really annoying when managing eg. Discord on another screen) --- src/video/x11/SDL_x11video.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c index e63be44a0..3aba22386 100644 --- a/src/video/x11/SDL_x11video.c +++ b/src/video/x11/SDL_x11video.c @@ -101,6 +101,12 @@ static int X11_SafetyNetErrHandler(Display *d, XErrorEvent *e) return 0; } +static SDL_bool X11_IsXWayland(Display *d) +{ + int opcode, event, error; + return X11_XQueryExtension(d, "XWAYLAND", &opcode, &event, &error) == True; +} + static SDL_VideoDevice *X11_CreateDevice(void) { SDL_VideoDevice *device; @@ -283,6 +289,9 @@ static SDL_VideoDevice *X11_CreateDevice(void) device->device_caps = VIDEO_DEVICE_CAPS_HAS_POPUP_WINDOW_SUPPORT | VIDEO_DEVICE_CAPS_SENDS_FULLSCREEN_DIMENSIONS; + if (X11_IsXWayland(x11_display)) + device->device_caps |= VIDEO_DEVICE_CAPS_MODE_SWITCHING_EMULATED; + return device; }