From 33442701ca1ea37074e42ca4ff9bc252e8b7d626 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sat, 21 Dec 2024 08:19:51 -0800
Subject: [PATCH] Use the monitor as the client rect for maximized borderless
windows
Fixes https://github.com/libsdl-org/SDL/issues/9588
---
src/video/windows/SDL_windowsevents.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c
index c47573e083ab0..81eb3babb673e 100644
--- a/src/video/windows/SDL_windowsevents.c
+++ b/src/video/windows/SDL_windowsevents.c
@@ -1875,9 +1875,21 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
SDL_WindowFlags window_flags = SDL_GetWindowFlags(data->window);
if (wParam == TRUE && (window_flags & SDL_WINDOW_BORDERLESS) && !(window_flags & SDL_WINDOW_FULLSCREEN)) {
// When borderless, need to tell windows that the size of the non-client area is 0
- if (!(window_flags & SDL_WINDOW_RESIZABLE)) {
+ NCCALCSIZE_PARAMS *params = (NCCALCSIZE_PARAMS *)lParam;
+ WINDOWPLACEMENT placement;
+ if (GetWindowPlacement(hwnd, &placement) && placement.showCmd == SW_MAXIMIZE) {
+ // Maximized borderless windows should use the full monitor size
+ HMONITOR hMonitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONULL);
+ if (hMonitor) {
+ MONITORINFO info;
+ SDL_zero(info);
+ info.cbSize = sizeof(info);
+ if (GetMonitorInfo(hMonitor, &info)) {
+ params->rgrc[0] = info.rcMonitor;
+ }
+ }
+ } else if (!(window_flags & SDL_WINDOW_RESIZABLE)) {
int w, h;
- NCCALCSIZE_PARAMS *params = (NCCALCSIZE_PARAMS *)lParam;
w = data->window->floating.w;
h = data->window->floating.h;
params->rgrc[0].right = params->rgrc[0].left + w;