mirror of
https://github.com/godotengine/godot.git
synced 2024-11-24 13:12:42 +00:00
Merge pull request #97757 from bruvzg/max_move_screen
Fix `window_set_current_screen` for maximized windows.
This commit is contained in:
commit
c28dd316a9
@ -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 New Issue
Block a user