From 8aa57a745a121ac3c7dc32007aa425d6a381e557 Mon Sep 17 00:00:00 2001 From: Mads Buvik Sandvei Date: Tue, 14 Jul 2020 13:19:51 +0200 Subject: [PATCH] Fix --- components/sdlutil/sdlvideowrapper.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/components/sdlutil/sdlvideowrapper.cpp b/components/sdlutil/sdlvideowrapper.cpp index c2963be86..c64c651bc 100644 --- a/components/sdlutil/sdlvideowrapper.cpp +++ b/components/sdlutil/sdlvideowrapper.cpp @@ -88,6 +88,14 @@ namespace SDLUtil { SDL_SetWindowSize(mWindow, width, height); SDL_SetWindowBordered(mWindow, windowBorder ? SDL_TRUE : SDL_FALSE); + + // Some display managers will automatically maximize windows whose resolution matches its current display. + // This breaks the SDL window if we don't move the window to the corner of that display. + auto index = SDL_GetWindowDisplayIndex(mWindow); + SDL_Rect rect{}; + SDL_GetDisplayBounds(index, &rect); + if (width == rect.w && height == rect.h) + SDL_SetWindowPosition(mWindow, rect.x, rect.y); } }