From cd9c25e80065dce4dd5a20b26c858d03e2b37eed Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 31 May 2024 09:30:37 -0700 Subject: [PATCH] Don't set the borderless flag if we're about to go fullscreen. This prevents the GNOME window manager from moving the window to a different display before the window goes fullscreen. Fixes https://github.com/libsdl-org/SDL/issues/9915 --- src/video/SDL_video.c | 1 + src/video/x11/SDL_x11window.c | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 1d4911941e..2f22a2f521 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -2254,6 +2254,7 @@ SDL_Window *SDL_CreateWindowWithProperties(SDL_PropertiesID props) window->y = bounds.y; window->w = bounds.w; window->h = bounds.h; + window->pending_flags |= SDL_WINDOW_FULLSCREEN; flags |= SDL_WINDOW_FULLSCREEN; } diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index efd36354af..fda1f07812 100644 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -655,8 +655,13 @@ int X11_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesI return SDL_SetError("Couldn't create window"); } - SetWindowBordered(display, screen, w, - !(window->flags & SDL_WINDOW_BORDERLESS)); + /* Don't set the borderless flag if we're about to go fullscreen. + * This prevents the window manager from moving a full-screen borderless + * window to a different display before we actually go fullscreen. + */ + if (!(window->pending_flags & SDL_WINDOW_FULLSCREEN)) { + SetWindowBordered(display, screen, w, !(window->flags & SDL_WINDOW_BORDERLESS)); + } sizehints = X11_XAllocSizeHints(); /* Setup the normal size hints */ @@ -1729,6 +1734,10 @@ static int X11_SetWindowFullscreenViaWM(SDL_VideoDevice *_this, SDL_Window *wind X11_SetNetWMState(_this, data->xwindow, flags); } + if ((window->flags & SDL_WINDOW_BORDERLESS) && !fullscreen) { + SetWindowBordered(display, displaydata->screen, data->xwindow, SDL_FALSE); + } + if (data->visual->class == DirectColor) { if (fullscreen) { X11_XInstallColormap(display, data->colormap);