Fix window restoring after fullscreen again

This commit is contained in:
Yuri Roubinsky 2020-12-31 14:49:03 +03:00
parent 41e9028868
commit 8a2bc6bf58
2 changed files with 15 additions and 11 deletions

View File

@ -903,6 +903,9 @@ void DisplayServerWindows::_get_window_style(bool p_main_window, bool p_fullscre
r_style = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU; r_style = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU;
} }
} }
if (!p_borderless) {
r_style |= WS_VISIBLE;
}
if (p_no_activate_focus) { if (p_no_activate_focus) {
r_style_ex |= WS_EX_TOPMOST | WS_EX_NOACTIVATE; r_style_ex |= WS_EX_TOPMOST | WS_EX_NOACTIVATE;
@ -910,7 +913,7 @@ void DisplayServerWindows::_get_window_style(bool p_main_window, bool p_fullscre
r_style |= WS_CLIPCHILDREN | WS_CLIPSIBLINGS; r_style |= WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
} }
void DisplayServerWindows::_update_window_style(WindowID p_window, bool p_repaint, bool p_maximized) { void DisplayServerWindows::_update_window_style(WindowID p_window, bool p_repaint) {
_THREAD_SAFE_METHOD_ _THREAD_SAFE_METHOD_
ERR_FAIL_COND(!windows.has(p_window)); ERR_FAIL_COND(!windows.has(p_window));
@ -943,6 +946,7 @@ void DisplayServerWindows::window_set_mode(WindowMode p_mode, WindowID p_window)
RECT rect; RECT rect;
wd.fullscreen = false; wd.fullscreen = false;
wd.maximized = wd.was_maximized;
if (wd.pre_fs_valid) { if (wd.pre_fs_valid) {
rect = wd.pre_fs_rect; rect = wd.pre_fs_rect;
@ -951,13 +955,16 @@ void DisplayServerWindows::window_set_mode(WindowMode p_mode, WindowID p_window)
rect.right = wd.width; rect.right = wd.width;
rect.top = 0; rect.top = 0;
rect.bottom = wd.height; rect.bottom = wd.height;
wd.pre_fs_valid = true;
} }
_update_window_style(p_window, false, wd.was_maximized); _update_window_style(p_window, false);
MoveWindow(wd.hWnd, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, TRUE); MoveWindow(wd.hWnd, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, TRUE);
} else if (p_mode == WINDOW_MODE_WINDOWED) {
wd.pre_fs_valid = true; ShowWindow(wd.hWnd, SW_RESTORE);
wd.maximized = false;
wd.minimized = false;
} }
if (p_mode == WINDOW_MODE_MAXIMIZED) { if (p_mode == WINDOW_MODE_MAXIMIZED) {
@ -966,12 +973,6 @@ void DisplayServerWindows::window_set_mode(WindowMode p_mode, WindowID p_window)
wd.minimized = false; wd.minimized = false;
} }
if (p_mode == WINDOW_MODE_WINDOWED) {
ShowWindow(wd.hWnd, SW_RESTORE);
wd.maximized = false;
wd.minimized = false;
}
if (p_mode == WINDOW_MODE_MINIMIZED) { if (p_mode == WINDOW_MODE_MINIMIZED) {
ShowWindow(wd.hWnd, SW_MINIMIZE); ShowWindow(wd.hWnd, SW_MINIMIZE);
wd.maximized = false; wd.maximized = false;
@ -2992,6 +2993,9 @@ DisplayServer::WindowID DisplayServerWindows::_create_window(WindowMode p_mode,
windows.erase(id); windows.erase(id);
return INVALID_WINDOW_ID; return INVALID_WINDOW_ID;
} }
if (p_mode != WINDOW_MODE_FULLSCREEN) {
wd.pre_fs_valid = true;
}
#ifdef VULKAN_ENABLED #ifdef VULKAN_ENABLED
if (rendering_driver == "vulkan") { if (rendering_driver == "vulkan") {

View File

@ -417,7 +417,7 @@ private:
void _drag_event(WindowID p_window, float p_x, float p_y, int idx); void _drag_event(WindowID p_window, float p_x, float p_y, int idx);
void _touch_event(WindowID p_window, bool p_pressed, float p_x, float p_y, int idx); void _touch_event(WindowID p_window, bool p_pressed, float p_x, float p_y, int idx);
void _update_window_style(WindowID p_window, bool p_repaint = true, bool p_maximized = false); void _update_window_style(WindowID p_window, bool p_repaint = true);
void _update_window_mouse_passthrough(WindowID p_window); void _update_window_mouse_passthrough(WindowID p_window);
void _update_real_mouse_position(WindowID p_window); void _update_real_mouse_position(WindowID p_window);