diff options
Diffstat (limited to 'platform/windows')
-rw-r--r-- | platform/windows/display_server_windows.cpp | 87 | ||||
-rw-r--r-- | platform/windows/gl_manager_windows.h | 1 | ||||
-rw-r--r-- | platform/windows/os_windows.cpp | 6 |
3 files changed, 47 insertions, 47 deletions
diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index 89a7114583..fe7d91dc18 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -829,6 +829,10 @@ void DisplayServerWindows::delete_sub_window(WindowID p_window) { } DestroyWindow(windows[p_window].hWnd); windows.erase(p_window); + + if (last_focused_window == p_window) { + last_focused_window = INVALID_WINDOW_ID; + } } void DisplayServerWindows::gl_window_make_current(DisplayServer::WindowID p_window_id) { @@ -991,15 +995,6 @@ void DisplayServerWindows::window_set_current_screen(int p_screen, WindowID p_wi wpos.y = CLAMP(wpos.y, srect.position.y, srect.position.y + srect.size.height - wsize.height / 3); window_set_position(wpos, p_window); } - - // Don't let the mouse leave the window when resizing to a smaller resolution. - if (mouse_mode == MOUSE_MODE_CONFINED || mouse_mode == MOUSE_MODE_CONFINED_HIDDEN) { - RECT crect; - GetClientRect(wd.hWnd, &crect); - ClientToScreen(wd.hWnd, (POINT *)&crect.left); - ClientToScreen(wd.hWnd, (POINT *)&crect.right); - ClipCursor(&crect); - } } Point2i DisplayServerWindows::window_get_position(WindowID p_window) const { @@ -1077,15 +1072,6 @@ void DisplayServerWindows::window_set_position(const Point2i &p_position, Window AdjustWindowRectEx(&rc, style, false, exStyle); MoveWindow(wd.hWnd, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, TRUE); - // Don't let the mouse leave the window when moved. - if (mouse_mode == MOUSE_MODE_CONFINED || mouse_mode == MOUSE_MODE_CONFINED_HIDDEN) { - RECT rect; - GetClientRect(wd.hWnd, &rect); - ClientToScreen(wd.hWnd, (POINT *)&rect.left); - ClientToScreen(wd.hWnd, (POINT *)&rect.right); - ClipCursor(&rect); - } - wd.last_pos = p_position; _update_real_mouse_position(p_window); } @@ -1227,15 +1213,6 @@ void DisplayServerWindows::window_set_size(const Size2i p_size, WindowID p_windo } MoveWindow(wd.hWnd, rect.left, rect.top, w, h, TRUE); - - // Don't let the mouse leave the window when resizing to a smaller resolution. - if (mouse_mode == MOUSE_MODE_CONFINED || mouse_mode == MOUSE_MODE_CONFINED_HIDDEN) { - RECT crect; - GetClientRect(wd.hWnd, &crect); - ClientToScreen(wd.hWnd, (POINT *)&crect.left); - ClientToScreen(wd.hWnd, (POINT *)&crect.right); - ClipCursor(&crect); - } } Size2i DisplayServerWindows::window_get_size(WindowID p_window) const { @@ -1423,15 +1400,6 @@ void DisplayServerWindows::window_set_mode(WindowMode p_mode, WindowID p_window) SystemParametersInfoA(SPI_SETMOUSETRAILS, 0, 0, 0); } } - - // Don't let the mouse leave the window when resizing to a smaller resolution. - if (mouse_mode == MOUSE_MODE_CONFINED || mouse_mode == MOUSE_MODE_CONFINED_HIDDEN) { - RECT crect; - GetClientRect(wd.hWnd, &crect); - ClientToScreen(wd.hWnd, (POINT *)&crect.left); - ClientToScreen(wd.hWnd, (POINT *)&crect.right); - ClipCursor(&crect); - } } DisplayServer::WindowMode DisplayServerWindows::window_get_mode(WindowID p_window) const { @@ -1626,7 +1594,7 @@ Vector2i DisplayServerWindows::ime_get_selection() const { ImmGetCompositionStringW(wd.im_himc, GCS_COMPSTR, string, length); int32_t utf32_cursor = 0; - for (int32_t i = 0; i < length / sizeof(wchar_t); i++) { + for (int32_t i = 0; i < length / int32_t(sizeof(wchar_t)); i++) { if ((string[i] & 0xfffffc00) == 0xd800) { i++; } @@ -2396,8 +2364,23 @@ Rect2i DisplayServerWindows::window_get_popup_safe_rect(WindowID p_window) const void DisplayServerWindows::popup_open(WindowID p_window) { _THREAD_SAFE_METHOD_ - const WindowData &wd = windows[p_window]; - if (wd.is_popup) { + bool has_popup_ancestor = false; + WindowID transient_root = p_window; + while (true) { + WindowID parent = windows[transient_root].transient_parent; + if (parent == INVALID_WINDOW_ID) { + break; + } else { + transient_root = parent; + if (windows[parent].is_popup) { + has_popup_ancestor = true; + break; + } + } + } + + WindowData &wd = windows[p_window]; + if (wd.is_popup || has_popup_ancestor) { // Find current popup parent, or root popup if new window is not transient. List<WindowID>::Element *C = nullptr; List<WindowID>::Element *E = popup_list.back(); @@ -3381,6 +3364,15 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA Callable::CallError ce; window.rect_changed_callback.callp(args, 1, ret, ce); } + + // Update cursor clip region after window rect has changed. + if (mouse_mode == MOUSE_MODE_CAPTURED || mouse_mode == MOUSE_MODE_CONFINED || mouse_mode == MOUSE_MODE_CONFINED_HIDDEN) { + RECT crect; + GetClientRect(window.hWnd, &crect); + ClientToScreen(window.hWnd, (POINT *)&crect.left); + ClientToScreen(window.hWnd, (POINT *)&crect.right); + ClipCursor(&crect); + } } // Return here to prevent WM_MOVE and WM_SIZE from being sent @@ -3971,10 +3963,19 @@ DisplayServer::WindowID DisplayServerWindows::_create_window(WindowMode p_mode, wd.im_position = Vector2(); - // FIXME this is wrong in cases where the window coordinates were changed due to full screen mode; use WindowRect - wd.last_pos = p_rect.position; - wd.width = p_rect.size.width; - wd.height = p_rect.size.height; + if (p_mode == WINDOW_MODE_FULLSCREEN || p_mode == WINDOW_MODE_EXCLUSIVE_FULLSCREEN || p_mode == WINDOW_MODE_MAXIMIZED) { + RECT r; + GetClientRect(wd.hWnd, &r); + ClientToScreen(wd.hWnd, (POINT *)&r.left); + ClientToScreen(wd.hWnd, (POINT *)&r.right); + wd.last_pos = Point2i(r.left, r.top) - _get_screens_origin(); + wd.width = r.right - r.left; + wd.height = r.bottom - r.top; + } else { + wd.last_pos = p_rect.position; + wd.width = p_rect.size.width; + wd.height = p_rect.size.height; + } window_id_counter++; } diff --git a/platform/windows/gl_manager_windows.h b/platform/windows/gl_manager_windows.h index b97d0f667c..361c559a5a 100644 --- a/platform/windows/gl_manager_windows.h +++ b/platform/windows/gl_manager_windows.h @@ -74,7 +74,6 @@ private: GLWindow *_current_window = nullptr; PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT = nullptr; - PFNWGLGETSWAPINTERVALEXTPROC wglGetSwapIntervalEXT = nullptr; // funcs void _internal_set_current_window(GLWindow *p_win); diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 08299d9b98..d384049fb5 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -830,7 +830,7 @@ class FallbackTextAnalysisSource : public IDWriteTextAnalysisSource { IDWriteNumberSubstitution *n_sub = nullptr; public: - HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, VOID **ppvInterface) { + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, VOID **ppvInterface) override { if (IID_IUnknown == riid) { AddRef(); *ppvInterface = (IUnknown *)this; @@ -844,11 +844,11 @@ public: return S_OK; } - ULONG STDMETHODCALLTYPE AddRef() { + ULONG STDMETHODCALLTYPE AddRef() override { return InterlockedIncrement(&_cRef); } - ULONG STDMETHODCALLTYPE Release() { + ULONG STDMETHODCALLTYPE Release() override { ULONG ulRef = InterlockedDecrement(&_cRef); if (0 == ulRef) { delete this; |