diff options
author | Juan Linietsky <reduzio@gmail.com> | 2020-03-14 16:56:37 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2020-03-26 15:49:44 +0100 |
commit | 09ba290364aaa5b54528e82144ec0a40e10b497b (patch) | |
tree | 9961a35f3e5e08d7e1004b129ec958c55c67ca6b | |
parent | c7b4dcae2f3b75ad7146e36f196893731f403144 (diff) |
Fixes to window style flags
-rw-r--r-- | platform/linuxbsd/display_server_x11.cpp | 6 | ||||
-rw-r--r-- | platform/linuxbsd/display_server_x11.h | 2 | ||||
-rw-r--r-- | platform/windows/display_server_windows.cpp | 64 | ||||
-rw-r--r-- | platform/windows/display_server_windows.h | 3 |
4 files changed, 41 insertions, 34 deletions
diff --git a/platform/linuxbsd/display_server_x11.cpp b/platform/linuxbsd/display_server_x11.cpp index f93dbc5371..701ad0e263 100644 --- a/platform/linuxbsd/display_server_x11.cpp +++ b/platform/linuxbsd/display_server_x11.cpp @@ -653,7 +653,7 @@ DisplayServer::WindowID DisplayServerX11::create_sub_window(WindowMode p_mode, u _THREAD_SAFE_METHOD_ - WindowID id = _create_window(p_mode, p_rect); + WindowID id = _create_window(p_mode, p_flags, p_rect); for (int i = 0; i < WINDOW_FLAG_MAX; i++) { if (p_flags & (1 << i)) { window_set_flag(WindowFlags(i), true, id); @@ -2992,7 +2992,7 @@ DisplayServer *DisplayServerX11::create_func(const String &p_rendering_driver, W return memnew(DisplayServerX11(p_rendering_driver, p_mode, p_flags, p_resolution, r_error)); } -DisplayServerX11::WindowID DisplayServerX11::_create_window(WindowMode p_mode, const Rect2i &p_rect) { +DisplayServerX11::WindowID DisplayServerX11::_create_window(WindowMode p_mode, uint32_t p_flags, const Rect2i &p_rect) { //Create window @@ -3381,7 +3381,7 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode } #endif - WindowID main_window = _create_window(p_mode, Rect2i(Point2(), p_resolution)); + WindowID main_window = _create_window(p_mode, p_flags, Rect2i(Point2(), p_resolution)); for (int i = 0; i < WINDOW_FLAG_MAX; i++) { if (p_flags & (1 << i)) { window_set_flag(WindowFlags(i), true, main_window); diff --git a/platform/linuxbsd/display_server_x11.h b/platform/linuxbsd/display_server_x11.h index f06d838239..c7d9b8f0d9 100644 --- a/platform/linuxbsd/display_server_x11.h +++ b/platform/linuxbsd/display_server_x11.h @@ -142,7 +142,7 @@ class DisplayServerX11 : public DisplayServer { Map<WindowID, WindowData> windows; WindowID window_id_counter = MAIN_WINDOW_ID; - WindowID _create_window(WindowMode p_mode, const Rect2i &p_rect); + WindowID _create_window(WindowMode p_mode, uint32_t p_flags, const Rect2i &p_rect); String internal_clipboard; Window xdnd_source_window; diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index b895632848..9696e71630 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -413,7 +413,7 @@ DisplayServer::WindowID DisplayServerWindows::create_sub_window(WindowMode p_mod _THREAD_SAFE_METHOD_ - WindowID window_id = _create_window(p_mode, p_rect); + WindowID window_id = _create_window(p_mode, p_flags, p_rect); for (int i = 0; i < WINDOW_FLAG_MAX; i++) { if (p_flags & (1 << i)) { window_set_flag(WindowFlags(i), true, window_id); @@ -754,36 +754,47 @@ Size2i DisplayServerWindows::window_get_real_size(WindowID p_window) const { return Size2(); } -void DisplayServerWindows::_update_window_style(WindowID p_window, bool p_repaint, bool p_maximized) { - - _THREAD_SAFE_METHOD_ - - ERR_FAIL_COND(!windows.has(p_window)); - WindowData &wd = windows[p_window]; +void DisplayServerWindows::_get_window_style(bool p_main_window, bool p_fullscreen, bool p_borderless, bool p_resizable, bool p_maximized, DWORD &r_style, DWORD &r_style_ex) { - DWORD style = 0; - DWORD style_ex = WS_EX_WINDOWEDGE; - if (p_window == MAIN_WINDOW_ID) { - style_ex |= WS_EX_APPWINDOW; + r_style = 0; + r_style_ex = WS_EX_WINDOWEDGE; + if (p_main_window) { + r_style_ex |= WS_EX_APPWINDOW; } - if (wd.fullscreen || wd.borderless) { - style = WS_SYSMENU | WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE; - if (wd.borderless) { - style_ex |= WS_EX_TOOLWINDOW; - } + if (p_fullscreen || p_borderless) { + r_style |= WS_POPUP; + //if (p_borderless) { + // r_style_ex |= WS_EX_TOOLWINDOW; + //} } else { - if (wd.resizable) { + + if (p_resizable) { if (p_maximized) { - style = WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_MAXIMIZE; + r_style = WS_OVERLAPPEDWINDOW | WS_MAXIMIZE; } else { - style = GWL_STYLE, WS_OVERLAPPEDWINDOW | WS_VISIBLE; + r_style = WS_OVERLAPPEDWINDOW; } } else { - style = WS_CAPTION | WS_MINIMIZEBOX | WS_POPUPWINDOW | WS_VISIBLE; + r_style = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU; } } + r_style |= WS_CLIPCHILDREN | WS_CLIPSIBLINGS; +} + +void DisplayServerWindows::_update_window_style(WindowID p_window, bool p_repaint, bool p_maximized) { + + _THREAD_SAFE_METHOD_ + + ERR_FAIL_COND(!windows.has(p_window)); + WindowData &wd = windows[p_window]; + + DWORD style = 0; + DWORD style_ex = 0; + + _get_window_style(p_window == MAIN_WINDOW_ID, wd.fullscreen, wd.borderless, wd.resizable, wd.maximized, style, style_ex); + SetWindowLongPtr(wd.hWnd, GWL_STYLE, style); SetWindowLongPtr(wd.hWnd, GWL_EXSTYLE, style_ex); @@ -2561,17 +2572,12 @@ void DisplayServerWindows::_process_key_events() { key_event_pos = 0; } -DisplayServer::WindowID DisplayServerWindows::_create_window(WindowMode p_mode, const Rect2i &p_rect) { +DisplayServer::WindowID DisplayServerWindows::_create_window(WindowMode p_mode, uint32_t p_flags, const Rect2i &p_rect) { DWORD dwExStyle; DWORD dwStyle; - dwExStyle = WS_EX_WINDOWEDGE; - dwStyle = WS_OVERLAPPEDWINDOW; - - if (window_id_counter == MAIN_WINDOW_ID) { - dwExStyle |= WS_EX_APPWINDOW; - } + _get_window_style(window_id_counter == MAIN_WINDOW_ID, p_mode == WINDOW_MODE_FULLSCREEN, p_flags & WINDOW_FLAG_BORDERLESS_BIT, !(p_flags & WINDOW_FLAG_RESIZE_DISABLED_BIT), p_mode == WINDOW_MODE_MAXIMIZED, dwStyle, dwExStyle); RECT WindowRect; @@ -2589,7 +2595,7 @@ DisplayServer::WindowID DisplayServerWindows::_create_window(WindowMode p_mode, wd.hWnd = CreateWindowExW( dwExStyle, L"Engine", L"", - dwStyle | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, + dwStyle, // (GetSystemMetrics(SM_CXSCREEN) - WindowRect.right) / 2, // (GetSystemMetrics(SM_CYSCREEN) - WindowRect.bottom) / 2, WindowRect.left, @@ -2761,7 +2767,7 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win } } #endif - WindowID main_window = _create_window(p_mode, Rect2i(Point2i(), p_resolution)); + WindowID main_window = _create_window(p_mode, 0, Rect2i(Point2i(), p_resolution)); for (int i = 0; i < WINDOW_FLAG_MAX; i++) { if (p_flags & (1 << i)) { window_set_flag(WindowFlags(i), true, main_window); diff --git a/platform/windows/display_server_windows.h b/platform/windows/display_server_windows.h index ba9eef886b..70878ae0dc 100644 --- a/platform/windows/display_server_windows.h +++ b/platform/windows/display_server_windows.h @@ -212,7 +212,7 @@ class DisplayServerWindows : public DisplayServer { JoypadWindows *joypad; - WindowID _create_window(WindowMode p_mode, const Rect2i &p_rect); + WindowID _create_window(WindowMode p_mode, uint32_t p_flags, const Rect2i &p_rect); WindowID window_id_counter = MAIN_WINDOW_ID; Map<WindowID, WindowData> windows; @@ -225,6 +225,7 @@ class DisplayServerWindows : public DisplayServer { WNDPROC user_proc = nullptr; void _send_window_event(const WindowData &wd, WindowEvent p_event); + void _get_window_style(bool p_main_window, bool p_fullscreen, bool p_borderless, bool p_resizable, bool p_maximized, DWORD &r_style, DWORD &r_style_ex); MouseMode mouse_mode; bool alt_mem = false; |