Fix window_set_current_screen for maximized windows.
This commit is contained in:
parent
2e14492879
commit
d2f3725120
3 changed files with 18 additions and 1 deletions
|
@ -2055,7 +2055,7 @@ void DisplayServerX11::window_set_current_screen(int p_screen, WindowID p_window
|
|||
return;
|
||||
}
|
||||
|
||||
if (window_get_mode(p_window) == WINDOW_MODE_FULLSCREEN) {
|
||||
if (window_get_mode(p_window) == WINDOW_MODE_FULLSCREEN || window_get_mode(p_window) == WINDOW_MODE_MAXIMIZED) {
|
||||
Point2i position = screen_get_position(p_screen);
|
||||
Size2i size = screen_get_size(p_screen);
|
||||
|
||||
|
|
|
@ -1893,6 +1893,12 @@ void DisplayServerMacOS::window_set_current_screen(int p_screen, WindowID p_wind
|
|||
was_fullscreen = true;
|
||||
}
|
||||
|
||||
bool was_maximized = false;
|
||||
if (!was_fullscreen && NSEqualRects([wd.window_object frame], [[wd.window_object screen] visibleFrame])) {
|
||||
[wd.window_object zoom:nil];
|
||||
was_maximized = true;
|
||||
}
|
||||
|
||||
Rect2i srect = screen_get_usable_rect(p_screen);
|
||||
Point2i wpos = window_get_position(p_window) - screen_get_position(window_get_current_screen(p_window));
|
||||
Size2i wsize = window_get_size(p_window);
|
||||
|
@ -1901,6 +1907,10 @@ void DisplayServerMacOS::window_set_current_screen(int p_screen, WindowID p_wind
|
|||
wpos = wpos.clamp(srect.position, srect.position + srect.size - wsize / 3);
|
||||
window_set_position(wpos, p_window);
|
||||
|
||||
if (was_maximized) {
|
||||
[wd.window_object zoom:nil];
|
||||
}
|
||||
|
||||
if (was_fullscreen) {
|
||||
// Re-enter fullscreen mode.
|
||||
[wd.window_object toggleFullScreen:nil];
|
||||
|
|
|
@ -1813,6 +1813,13 @@ void DisplayServerWindows::window_set_current_screen(int p_screen, WindowID p_wi
|
|||
Size2 size = screen_get_size(p_screen);
|
||||
|
||||
MoveWindow(wd.hWnd, pos.x, pos.y, size.width, size.height, TRUE);
|
||||
} else if (wd.maximized) {
|
||||
Point2 pos = screen_get_position(p_screen) + _get_screens_origin();
|
||||
Size2 size = screen_get_size(p_screen);
|
||||
|
||||
ShowWindow(wd.hWnd, SW_RESTORE);
|
||||
MoveWindow(wd.hWnd, pos.x, pos.y, size.width, size.height, TRUE);
|
||||
ShowWindow(wd.hWnd, SW_MAXIMIZE);
|
||||
} else {
|
||||
Rect2i srect = screen_get_usable_rect(p_screen);
|
||||
Point2i wpos = window_get_position(p_window) - screen_get_position(window_get_current_screen(p_window));
|
||||
|
|
Loading…
Reference in a new issue