diff options
author | Juan Linietsky <reduzio@gmail.com> | 2020-03-12 09:37:40 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2020-03-26 15:49:42 +0100 |
commit | 441f1a5fe9a3bf0e4e5dab578f793500b1ff6e3d (patch) | |
tree | 6421bcc3235e6fdcd726244ac7d455886e17734b /platform/windows | |
parent | 543fb1c4dadd75914d595b089820aef42e691075 (diff) |
Popups are now windows also (broken!)
Diffstat (limited to 'platform/windows')
-rw-r--r-- | platform/windows/display_server_windows.cpp | 32 | ||||
-rw-r--r-- | platform/windows/display_server_windows.h | 2 |
2 files changed, 31 insertions, 3 deletions
diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index d705ce631a..e2c78da5a9 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -527,9 +527,20 @@ Point2i DisplayServerWindows::window_get_position(WindowID p_window) const { return wd.last_pos; } + POINT point; + point.x = 0; + point.y = 0; + + ClientToScreen(wd.hWnd, &point); + + return Point2i(point.x, point.y); + +#if 0 + //do not use this method, as it includes windows decorations RECT r; GetWindowRect(wd.hWnd, &r); return Point2(r.left, r.top); +#endif } void DisplayServerWindows::_update_real_mouse_position(WindowID p_window) { @@ -551,10 +562,25 @@ void DisplayServerWindows::window_set_position(const Point2i &p_position, Window WindowData &wd = windows[p_window]; if (wd.fullscreen) return; +#if 0 + //wrong needs to account properly for decorations RECT r; GetWindowRect(wd.hWnd, &r); MoveWindow(wd.hWnd, p_position.x, p_position.y, r.right - r.left, r.bottom - r.top, TRUE); +#else + + RECT rc; + rc.left = p_position.x; + rc.right = p_position.x + wd.width; + rc.bottom = p_position.y + wd.height; + rc.top = p_position.y; + const DWORD style = GetWindowLongPtr(wd.hWnd, GWL_STYLE); + const DWORD exStyle = GetWindowLongPtr(wd.hWnd, GWL_EXSTYLE); + + AdjustWindowRectEx(&rc, style, false, exStyle); + MoveWindow(wd.hWnd, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, TRUE); +#endif // Don't let the mouse leave the window when moved if (mouse_mode == MOUSE_MODE_CONFINED) { RECT rect; @@ -2535,8 +2561,10 @@ DisplayServer::WindowID DisplayServerWindows::_create_window(WindowMode p_mode, dwExStyle, L"Engine", L"", dwStyle | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, - (GetSystemMetrics(SM_CXSCREEN) - WindowRect.right) / 2, - (GetSystemMetrics(SM_CYSCREEN) - WindowRect.bottom) / 2, + // (GetSystemMetrics(SM_CXSCREEN) - WindowRect.right) / 2, + // (GetSystemMetrics(SM_CYSCREEN) - WindowRect.bottom) / 2, + WindowRect.left, + WindowRect.top, WindowRect.right - WindowRect.left, WindowRect.bottom - WindowRect.top, NULL, NULL, hInstance, NULL); diff --git a/platform/windows/display_server_windows.h b/platform/windows/display_server_windows.h index 5fef08fbd5..0c07e6283c 100644 --- a/platform/windows/display_server_windows.h +++ b/platform/windows/display_server_windows.h @@ -222,7 +222,7 @@ class DisplayServerWindows : public DisplayServer { HCURSOR hCursor; - WNDPROC user_proc; + WNDPROC user_proc = nullptr; void _send_window_event(const WindowData &wd, WindowEvent p_event); |