mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-20 08:17:17 +01:00
Improve OS.set_current_screen
Fix moving fullscreen windows on macOS and Windows Fix window position on Linux/X11
This commit is contained in:
parent
55c580bad5
commit
f8be7dd320
@ -2523,8 +2523,24 @@ void OS_OSX::set_current_screen(int p_screen) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (get_current_screen() == p_screen) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool was_fullscreen = false;
|
||||||
|
if (zoomed) {
|
||||||
|
// Temporary exit fullscreen mode to move window.
|
||||||
|
[window_object toggleFullScreen:nil];
|
||||||
|
was_fullscreen = true;
|
||||||
|
}
|
||||||
|
|
||||||
Vector2 wpos = get_window_position() - get_screen_position(get_current_screen());
|
Vector2 wpos = get_window_position() - get_screen_position(get_current_screen());
|
||||||
set_window_position(wpos + get_screen_position(p_screen));
|
set_window_position(wpos + get_screen_position(p_screen));
|
||||||
|
|
||||||
|
if (was_fullscreen) {
|
||||||
|
// Re-enter fullscreen mode.
|
||||||
|
[window_object toggleFullScreen:nil];
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Point2 OS_OSX::get_native_screen_position(int p_screen) const {
|
Point2 OS_OSX::get_native_screen_position(int p_screen) const {
|
||||||
|
@ -1917,9 +1917,20 @@ int OS_Windows::get_current_screen() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void OS_Windows::set_current_screen(int p_screen) {
|
void OS_Windows::set_current_screen(int p_screen) {
|
||||||
|
if (video_mode.fullscreen) {
|
||||||
|
int cs = get_current_screen();
|
||||||
|
if (cs == p_screen) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Point2 pos = get_screen_position(p_screen);
|
||||||
|
Size2 size = get_screen_size(p_screen);
|
||||||
|
|
||||||
|
MoveWindow(hWnd, pos.x, pos.y, size.width, size.height, TRUE);
|
||||||
|
} else {
|
||||||
Vector2 ofs = get_window_position() - get_screen_position(get_current_screen());
|
Vector2 ofs = get_window_position() - get_screen_position(get_current_screen());
|
||||||
set_window_position(ofs + get_screen_position(p_screen));
|
set_window_position(ofs + get_screen_position(p_screen));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static BOOL CALLBACK _MonitorEnumProcPos(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
|
static BOOL CALLBACK _MonitorEnumProcPos(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
|
||||||
EnumPosData *data = (EnumPosData *)dwData;
|
EnumPosData *data = (EnumPosData *)dwData;
|
||||||
|
@ -1204,8 +1204,8 @@ void OS_X11::set_current_screen(int p_screen) {
|
|||||||
XMoveResizeWindow(x11_display, x11_window, position.x, position.y, size.x, size.y);
|
XMoveResizeWindow(x11_display, x11_window, position.x, position.y, size.x, size.y);
|
||||||
} else {
|
} else {
|
||||||
if (p_screen != get_current_screen()) {
|
if (p_screen != get_current_screen()) {
|
||||||
Point2i position = get_screen_position(p_screen);
|
Vector2 ofs = get_window_position() - get_screen_position(get_current_screen());
|
||||||
XMoveWindow(x11_display, x11_window, position.x, position.y);
|
set_window_position(ofs + get_screen_position(p_screen));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user