Merge pull request #71174 from RedMser/fix-confined-mouse-mode-update
Fix confined mouse mode not updating on resize
This commit is contained in:
commit
b8ef55a427
@ -991,15 +991,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);
|
wpos.y = CLAMP(wpos.y, srect.position.y, srect.position.y + srect.size.height - wsize.height / 3);
|
||||||
window_set_position(wpos, p_window);
|
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 {
|
Point2i DisplayServerWindows::window_get_position(WindowID p_window) const {
|
||||||
@ -1077,15 +1068,6 @@ void DisplayServerWindows::window_set_position(const Point2i &p_position, Window
|
|||||||
AdjustWindowRectEx(&rc, style, false, exStyle);
|
AdjustWindowRectEx(&rc, style, false, exStyle);
|
||||||
MoveWindow(wd.hWnd, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, TRUE);
|
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;
|
wd.last_pos = p_position;
|
||||||
_update_real_mouse_position(p_window);
|
_update_real_mouse_position(p_window);
|
||||||
}
|
}
|
||||||
@ -1227,15 +1209,6 @@ void DisplayServerWindows::window_set_size(const Size2i p_size, WindowID p_windo
|
|||||||
}
|
}
|
||||||
|
|
||||||
MoveWindow(wd.hWnd, rect.left, rect.top, w, h, TRUE);
|
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 {
|
Size2i DisplayServerWindows::window_get_size(WindowID p_window) const {
|
||||||
@ -1423,15 +1396,6 @@ void DisplayServerWindows::window_set_mode(WindowMode p_mode, WindowID p_window)
|
|||||||
SystemParametersInfoA(SPI_SETMOUSETRAILS, 0, 0, 0);
|
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 {
|
DisplayServer::WindowMode DisplayServerWindows::window_get_mode(WindowID p_window) const {
|
||||||
@ -3381,6 +3345,15 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
|||||||
Callable::CallError ce;
|
Callable::CallError ce;
|
||||||
window.rect_changed_callback.callp(args, 1, ret, 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
|
// Return here to prevent WM_MOVE and WM_SIZE from being sent
|
||||||
|
Loading…
Reference in New Issue
Block a user