summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2018-09-10 15:34:49 +0200
committerGitHub <noreply@github.com>2018-09-10 15:34:49 +0200
commita2d2fbe8a6a2b506e4d2e9609efd1e29b07d66b3 (patch)
tree10f541b38767d3f4879e3c311990d0c03b9ed85a
parentc0df3b147e59199fa3d7743f89c167a440daa070 (diff)
parentbd3d73a9fd72ab5978b7b0e99237ac5b94978dda (diff)
Merge pull request #21784 from guilhermefelipecgs/fix_resized_mouse_confined
Fix mouse confined leaving window with OS_Windows::set_window_position
-rw-r--r--platform/windows/os_windows.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index 88793386ab..e224a52b04 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -1711,6 +1711,15 @@ void OS_Windows::set_window_position(const Point2 &p_position) {
RECT r;
GetWindowRect(hWnd, &r);
MoveWindow(hWnd, p_position.x, p_position.y, r.right - r.left, r.bottom - r.top, TRUE);
+
+ // Don't let the mouse leave the window when moved
+ if (mouse_mode == MOUSE_MODE_CONFINED) {
+ RECT rect;
+ GetClientRect(hWnd, &rect);
+ ClientToScreen(hWnd, (POINT *)&rect.left);
+ ClientToScreen(hWnd, (POINT *)&rect.right);
+ ClipCursor(&rect);
+ }
}
Size2 OS_Windows::get_window_size() const {