Skip to content

Commit e00b7dc

Browse files
committed
[Windows] Fix borderless maximized window mode.
1 parent 594d64e commit e00b7dc

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

platform/windows/display_server_windows.cpp

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2395,7 +2395,12 @@ void DisplayServerWindows::window_set_mode(WindowMode p_mode, WindowID p_window)
23952395
wd.was_fullscreen_pre_min = false;
23962396

23972397
if (p_mode == WINDOW_MODE_MAXIMIZED && wd.borderless) {
2398-
p_mode = WINDOW_MODE_FULLSCREEN;
2398+
int cs = window_get_current_screen(p_window);
2399+
Rect2i full = Rect2i(screen_get_position(cs), screen_get_size(cs));
2400+
Rect2i usable = screen_get_usable_rect(cs);
2401+
if (full == usable) {
2402+
p_mode = WINDOW_MODE_FULLSCREEN;
2403+
}
23992404
}
24002405

24012406
if (wd.fullscreen && p_mode != WINDOW_MODE_FULLSCREEN && p_mode != WINDOW_MODE_EXCLUSIVE_FULLSCREEN) {
@@ -2434,12 +2439,24 @@ void DisplayServerWindows::window_set_mode(WindowMode p_mode, WindowID p_window)
24342439
wd.minimized = false;
24352440
}
24362441

2437-
if (p_mode == WINDOW_MODE_MAXIMIZED) {
2442+
if (p_mode == WINDOW_MODE_MAXIMIZED && !wd.borderless) {
24382443
ShowWindow(wd.hWnd, SW_MAXIMIZE);
24392444
wd.maximized = true;
24402445
wd.minimized = false;
24412446
}
24422447

2448+
if (p_mode == WINDOW_MODE_MAXIMIZED && wd.borderless) {
2449+
ShowWindow(wd.hWnd, SW_NORMAL);
2450+
wd.maximized = true;
2451+
wd.minimized = false;
2452+
2453+
int cs = window_get_current_screen(p_window);
2454+
Rect2i usable = screen_get_usable_rect(cs);
2455+
Point2 pos = usable.position + _get_screens_origin();
2456+
Size2 size = usable.size;
2457+
MoveWindow(wd.hWnd, pos.x, pos.y, size.width, size.height, TRUE);
2458+
}
2459+
24432460
if (p_mode == WINDOW_MODE_MINIMIZED) {
24442461
ShowWindow(wd.hWnd, SW_MINIMIZE);
24452462
wd.maximized = false;
@@ -5599,6 +5616,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
55995616
int screen_id = window_get_current_screen(window_id);
56005617
Size2i screen_size = screen_get_size(screen_id);
56015618
Point2i screen_position = screen_get_position(screen_id);
5619+
Rect2i usable = screen_get_usable_rect(screen_id);
56025620

56035621
window.maximized = false;
56045622
window.minimized = false;
@@ -5615,8 +5633,15 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
56155633
window.maximized_fs = true;
56165634
_update_window_style(window_id, false);
56175635
}
5636+
if (window.borderless && (screen_size != usable.size || screen_position != usable.position)) {
5637+
Point2 pos = usable.position + _get_screens_origin();
5638+
Size2 size = usable.size;
5639+
MoveWindow(window.hWnd, pos.x, pos.y, size.width, size.height, TRUE);
5640+
}
56185641
} else if (window_rect.position == screen_position && window_rect.size == screen_size) {
56195642
window.fullscreen = true;
5643+
} else if (window.borderless && usable.position == window_rect.position && usable.size == window_rect.size) {
5644+
window.maximized = true;
56205645
}
56215646

56225647
if (window.maximized_fs && !window.maximized) {

0 commit comments

Comments
 (0)