summaryrefslogtreecommitdiff
path: root/platform/windows/os_windows.cpp
diff options
context:
space:
mode:
authorGuilherme Felipe <guilhermefelipecgs@gmail.com>2018-09-05 18:45:23 -0300
committerGuilherme Felipe <guilhermefelipecgs@gmail.com>2018-09-05 18:52:05 -0300
commitbd3d73a9fd72ab5978b7b0e99237ac5b94978dda (patch)
tree90976c8e8b464456af82faccfa1678dd70d79173 /platform/windows/os_windows.cpp
parentfc207ba18a24f8383d8f985c161de229655a24d5 (diff)
Fix mouse confined leaving window with OS_Windows::set_window_position
Diffstat (limited to 'platform/windows/os_windows.cpp')
-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 {