From 6b0940435dbed361d9c5d9aaeebeeace1de6c536 Mon Sep 17 00:00:00 2001 From: Frank Praznik Date: Tue, 4 Mar 2025 12:00:12 -0500 Subject: [PATCH 1/2] x11: Synthesize fullscreen size events on Openbox Openbox doesn't send size events when entering fullscreen, so they must be synthesized. This is not desirable on any other window manager, as it can break fullscreen positioning on multi-monitor configurations. --- src/video/x11/SDL_x11video.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c index 62b4330e6f613..75862db2215ff 100644 --- a/src/video/x11/SDL_x11video.c +++ b/src/video/x11/SDL_x11video.c @@ -78,6 +78,23 @@ 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; @@ -256,8 +273,14 @@ static SDL_VideoDevice *X11_CreateDevice(void) device->system_theme = SDL_SystemTheme_Get(); #endif - device->device_caps = VIDEO_DEVICE_CAPS_HAS_POPUP_WINDOW_SUPPORT | - VIDEO_DEVICE_CAPS_SENDS_FULLSCREEN_DIMENSIONS; + 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_DISPLAY_CHANGES; + } data->is_xwayland = X11_IsXWayland(x11_display); if (data->is_xwayland) { From 2ce11e9263859254d91396ccfb8b5a473b3ac9a0 Mon Sep 17 00:00:00 2001 From: Frank Praznik Date: Tue, 4 Mar 2025 12:17:12 -0500 Subject: [PATCH 2/2] video: Synthesize fullscreen related moves if the driver does not. --- src/video/SDL_video.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index d8f4535664d4b..3ed49941e46a9 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -1984,18 +1984,24 @@ bool SDL_UpdateFullscreenMode(SDL_Window *window, SDL_FullscreenOp fullscreen, b * This is also unnecessary on Cocoa, Wayland, Win32, and X11 (will send SDL_EVENT_WINDOW_RESIZED). */ if (!SDL_SendsFullscreenDimensions(_this)) { + SDL_Rect displayRect; + if (mode) { mode_w = mode->w; mode_h = mode->h; + SDL_GetDisplayBounds(mode->displayID, &displayRect); } else { mode_w = display->desktop_mode.w; mode_h = display->desktop_mode.h; + SDL_GetDisplayBounds(display->id, &displayRect); } if (window->w != mode_w || window->h != mode_h) { resized = true; } + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_MOVED, displayRect.x, displayRect.y); + if (resized) { SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESIZED, mode_w, mode_h); } else { @@ -2044,6 +2050,7 @@ bool SDL_UpdateFullscreenMode(SDL_Window *window, SDL_FullscreenOp fullscreen, b } if (!SDL_SendsFullscreenDimensions(_this)) { + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_MOVED, window->windowed.x, window->windowed.y); if (resized) { SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESIZED, window->windowed.w, window->windowed.h); } else {