From 5219b1ea57c32f16d4d9dac4ceb8a6246376e23a Mon Sep 17 00:00:00 2001 From: SupSuper Date: Thu, 29 Apr 2021 04:06:42 +0100 Subject: [PATCH] SDL: Get the window decoration size from the backend It's been 5 years since SDL 2.0.5, I think it's safe to use --- backends/platform/sdl/sdl-window.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/backends/platform/sdl/sdl-window.cpp b/backends/platform/sdl/sdl-window.cpp index 17999485137..2ec160ddb4d 100644 --- a/backends/platform/sdl/sdl-window.cpp +++ b/backends/platform/sdl/sdl-window.cpp @@ -296,19 +296,26 @@ bool SdlWindow::createOrUpdateWindow(int width, int height, uint32 flags) { // the documentation says it only works on X11 anyway, which means it is // basically worthless. So we'll just try to keep things closeish to the // maximum for now. - SDL_DisplayMode displayMode; - SDL_GetDesktopDisplayMode(0, &displayMode); + Common::Rect desktopRes = getDesktopResolution(); if (!fullscreenFlags) { - displayMode.w -= 20; - displayMode.h -= 30; + int top, left, bottom, right; +#if SDL_VERSION_ATLEAST(2, 0, 5) + if (!_window || SDL_GetWindowBordersSize(_window, &top, &left, &bottom, &right) < 0) +#endif + { + left = right = 10; + top = bottom = 15; + } + desktopRes.right -= (left + right); + desktopRes.bottom -= (top + bottom); } - if (width > displayMode.w) { - width = displayMode.w; + if (width > desktopRes.right) { + width = desktopRes.right; } - if (height > displayMode.h) { - height = displayMode.h; + if (height > desktopRes.bottom) { + height = desktopRes.bottom; } if (!_window || oldNonUpdateableFlags != newNonUpdateableFlags) {