From e8076b78ef6daf9e6d223fd463fb58819e72fed2 Mon Sep 17 00:00:00 2001 From: Frank Praznik Date: Tue, 21 Feb 2023 00:14:49 -0500 Subject: [PATCH] video: Move fullscreen windows via SDL_UpdateFullscreenMode() Update the target display ID and use SDL_UpdateFullscreenMode() when moving a fullscreen window to handle the case where the target display has an existing fullscreen window. --- src/video/SDL_video.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 2a4c0eab57..008e2ab4f0 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -1323,6 +1323,9 @@ static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen) mode = (SDL_DisplayMode *)SDL_GetWindowFullscreenMode(window); if (mode != NULL) { window->fullscreen_exclusive = SDL_TRUE; + } else { + /* Make sure the current mode is zeroed for fullscreen desktop. */ + SDL_zero(window->current_fullscreen_mode); } } @@ -2190,21 +2193,9 @@ int SDL_SetWindowPosition(SDL_Window *window, int x, int y) SDL_DisplayID displayID = GetDisplayForRect(x, y, 1, 1); if (displayID != original_displayID) { - SDL_Rect bounds; - SDL_zero(bounds); - SDL_GetDisplayBounds(displayID, &bounds); - - window->x = bounds.x; - window->y = bounds.y; - window->w = bounds.w; - window->h = bounds.h; - - if (_this->SetWindowPosition) { - _this->SetWindowPosition(_this, window); - } - if (_this->SetWindowSize) { - _this->SetWindowSize(_this, window); - } + /* Set the new target display and update the fullscreen mode */ + window->current_fullscreen_mode.displayID = displayID; + SDL_UpdateFullscreenMode(window, SDL_TRUE); } } } else {