From 41e1a2360f2b26d9167b85f2f2259757d4f5ea28 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 27 Jul 2021 16:50:06 -0700 Subject: [PATCH] Correct the maximized size and position for borderless resizable windows This fixes bug https://github.com/libsdl-org/SDL/issues/4043 --- src/video/windows/SDL_windowsevents.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c index 01fd369b3..1481b0314 100644 --- a/src/video/windows/SDL_windowsevents.c +++ b/src/video/windows/SDL_windowsevents.c @@ -963,6 +963,14 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) /* Fix our size to the current size */ info = (MINMAXINFO *) lParam; if (SDL_GetWindowFlags(data->window) & SDL_WINDOW_RESIZABLE) { + if (SDL_GetWindowFlags(data->window) & SDL_WINDOW_BORDERLESS) { + int screenW = GetSystemMetrics(SM_CXSCREEN); + int screenH = GetSystemMetrics(SM_CYSCREEN); + info->ptMaxSize.x = SDL_max(w, screenW); + info->ptMaxSize.y = SDL_max(h, screenH); + info->ptMaxPosition.x = SDL_min(0, ((screenW - w) / 2)); + info->ptMaxPosition.y = SDL_min(0, ((screenH - h) / 2)); + } info->ptMinTrackSize.x = w + min_w; info->ptMinTrackSize.y = h + min_h; if (constrain_max_size) {