Merge pull request #21784 from guilhermefelipecgs/fix_resized_mouse_confined

Fix mouse confined leaving window with OS_Windows::set_window_position
This commit is contained in:
Rémi Verschelde 2018-09-10 15:34:49 +02:00 committed by GitHub
commit a2d2fbe8a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 {