@@ -2426,7 +2426,12 @@ void DisplayServerWindows::window_set_mode(WindowMode p_mode, WindowID p_window)
24262426 wd.was_fullscreen_pre_min = false ;
24272427
24282428 if (p_mode == WINDOW_MODE_MAXIMIZED && wd.borderless ) {
2429- p_mode = WINDOW_MODE_FULLSCREEN;
2429+ int cs = window_get_current_screen (p_window);
2430+ Rect2i full = Rect2i (screen_get_position (cs), screen_get_size (cs));
2431+ Rect2i usable = screen_get_usable_rect (cs);
2432+ if (full == usable) {
2433+ p_mode = WINDOW_MODE_FULLSCREEN;
2434+ }
24302435 }
24312436
24322437 if (wd.fullscreen && p_mode != WINDOW_MODE_FULLSCREEN && p_mode != WINDOW_MODE_EXCLUSIVE_FULLSCREEN) {
@@ -2465,12 +2470,24 @@ void DisplayServerWindows::window_set_mode(WindowMode p_mode, WindowID p_window)
24652470 wd.minimized = false ;
24662471 }
24672472
2468- if (p_mode == WINDOW_MODE_MAXIMIZED) {
2473+ if (p_mode == WINDOW_MODE_MAXIMIZED && !wd. borderless ) {
24692474 ShowWindow (wd.hWnd , SW_MAXIMIZE);
24702475 wd.maximized = true ;
24712476 wd.minimized = false ;
24722477 }
24732478
2479+ if (p_mode == WINDOW_MODE_MAXIMIZED && wd.borderless ) {
2480+ ShowWindow (wd.hWnd , SW_NORMAL);
2481+ wd.maximized = true ;
2482+ wd.minimized = false ;
2483+
2484+ int cs = window_get_current_screen (p_window);
2485+ Rect2i usable = screen_get_usable_rect (cs);
2486+ Point2 pos = usable.position + _get_screens_origin ();
2487+ Size2 size = usable.size ;
2488+ MoveWindow (wd.hWnd , pos.x , pos.y , size.width , size.height , TRUE );
2489+ }
2490+
24742491 if (p_mode == WINDOW_MODE_MINIMIZED) {
24752492 ShowWindow (wd.hWnd , SW_MINIMIZE);
24762493 wd.maximized = false ;
@@ -5689,6 +5706,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
56895706 int screen_id = window_get_current_screen (window_id);
56905707 Size2i screen_size = screen_get_size (screen_id);
56915708 Point2i screen_position = screen_get_position (screen_id);
5709+ Rect2i usable = screen_get_usable_rect (screen_id);
56925710
56935711 window.maximized = false ;
56945712 window.minimized = false ;
@@ -5705,8 +5723,15 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
57055723 window.maximized_fs = true ;
57065724 _update_window_style (window_id, false );
57075725 }
5726+ if (window.borderless && (screen_size != usable.size || screen_position != usable.position )) {
5727+ Point2 pos = usable.position + _get_screens_origin ();
5728+ Size2 size = usable.size ;
5729+ MoveWindow (window.hWnd , pos.x , pos.y , size.width , size.height , TRUE );
5730+ }
57085731 } else if (window_rect.position == screen_position && window_rect.size == screen_size) {
57095732 window.fullscreen = true ;
5733+ } else if (window.borderless && usable.position == window_rect.position && usable.size == window_rect.size ) {
5734+ window.maximized = true ;
57105735 }
57115736
57125737 if (window.maximized_fs && !window.maximized ) {
0 commit comments