Skip to content

Commit

Permalink
Use the monitor as the client rect for maximized borderless windows
Browse files Browse the repository at this point in the history
Fixes #9588
  • Loading branch information
slouken committed Dec 21, 2024
1 parent 7e298f5 commit 3344270
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/video/windows/SDL_windowsevents.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 3344270

Please sign in to comment.