Skip to content

Commit 0a170a9

Browse files
committed
Merge pull request #110010 from bruvzg/win_max_b
[Windows] Save and restore window rect when switching to/from maximized+borderless mode.
2 parents d7c4773 + 01d7abb commit 0a170a9

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

platform/windows/display_server_windows.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2469,6 +2469,21 @@ void DisplayServerWindows::window_set_mode(WindowMode p_mode, WindowID p_window)
24692469
}
24702470
}
24712471

2472+
if ((wd.maximized || wd.was_maximized_pre_fs) && wd.borderless && p_mode != WINDOW_MODE_MINIMIZED && p_mode != WINDOW_MODE_FULLSCREEN && p_mode != WINDOW_MODE_EXCLUSIVE_FULLSCREEN) {
2473+
RECT rect;
2474+
if (wd.pre_fs_valid) {
2475+
rect = wd.pre_fs_rect;
2476+
} else {
2477+
rect.left = 0;
2478+
rect.right = wd.width;
2479+
rect.top = 0;
2480+
rect.bottom = wd.height;
2481+
}
2482+
2483+
ShowWindow(wd.hWnd, SW_RESTORE);
2484+
MoveWindow(wd.hWnd, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, TRUE);
2485+
}
2486+
24722487
if (p_mode == WINDOW_MODE_WINDOWED) {
24732488
ShowWindow(wd.hWnd, SW_NORMAL);
24742489
wd.maximized = false;
@@ -2482,6 +2497,11 @@ void DisplayServerWindows::window_set_mode(WindowMode p_mode, WindowID p_window)
24822497
}
24832498

24842499
if (p_mode == WINDOW_MODE_MAXIMIZED && wd.borderless) {
2500+
if (!was_fullscreen && !(wd.maximized && wd.borderless)) {
2501+
// Save non-fullscreen rect before entering fullscreen.
2502+
GetWindowRect(wd.hWnd, &wd.pre_fs_rect);
2503+
wd.pre_fs_valid = true;
2504+
}
24852505
ShowWindow(wd.hWnd, SW_NORMAL);
24862506
wd.maximized = true;
24872507
wd.minimized = false;
@@ -2515,7 +2535,7 @@ void DisplayServerWindows::window_set_mode(WindowMode p_mode, WindowID p_window)
25152535
// Save previous maximized stare.
25162536
wd.was_maximized_pre_fs = wd.maximized;
25172537

2518-
if (!was_fullscreen) {
2538+
if (!was_fullscreen && !(wd.maximized && wd.borderless)) {
25192539
// Save non-fullscreen rect before entering fullscreen.
25202540
GetWindowRect(wd.hWnd, &wd.pre_fs_rect);
25212541
wd.pre_fs_valid = true;

0 commit comments

Comments
 (0)