sdl: (linux) fix window position at startup/recreation

Window decorations dimensions aren't taken into account on linux when
creating a window. So reposition it after it's shown.
This commit is contained in:
Flyinghead 2024-01-29 17:08:10 +01:00
parent 617d82f5a2
commit 1153238e2c
1 changed files with 12 additions and 0 deletions

View File

@ -642,6 +642,18 @@ bool sdl_recreate_window(u32 flags)
settings.display.width = windowPos.w * hdpiScaling;
settings.display.height = windowPos.h * hdpiScaling;
#ifdef __linux__
if (flags & SDL_WINDOW_RESIZABLE)
{
// The position passed to SDL_CreateWindow doesn't take decorations into account on linux.
// SDL_ShowWindow retrieves the border dimensions and SDL_SetWindowPosition uses them
// to correctly (re)position the window if needed.
// TODO a similar issue happens when switching back from fullscreen
SDL_ShowWindow(window);
SDL_SetWindowPosition(window, windowPos.x, windowPos.y);
}
#endif
#if !defined(GLES) && !defined(_WIN32) && !defined(__SWITCH__) && !defined(__APPLE__)
// Set the window icon
u32 pixels[48 * 48];