Fix #19033
- Fix a bug when mouse is confined don't update the cursor shape. - Don't let the mouse leave the window when resizing to a smaller resolution when MOUSE_MODE_CONFINED. - Fix set_borderless_window to preserve the actual video_mode.widht/height.
This commit is contained in:
parent
228b09bafb
commit
28d24c4f66
4 changed files with 33 additions and 5 deletions
|
@ -1480,7 +1480,7 @@ void OS_OSX::set_cursor_shape(CursorShape p_shape) {
|
||||||
if (cursor_shape == p_shape)
|
if (cursor_shape == p_shape)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (mouse_mode != MOUSE_MODE_VISIBLE) {
|
if (mouse_mode != MOUSE_MODE_VISIBLE && mouse_mode != MOUSE_MODE_CONFINED) {
|
||||||
cursor_shape = p_shape;
|
cursor_shape = p_shape;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -623,9 +623,26 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
case WM_SIZE: {
|
case WM_SIZE: {
|
||||||
int window_w = LOWORD(lParam);
|
int window_w = LOWORD(lParam);
|
||||||
int window_h = HIWORD(lParam);
|
int window_h = HIWORD(lParam);
|
||||||
if (window_w > 0 && window_h > 0) {
|
if (window_w > 0 && window_h > 0 && !preserve_window_size) {
|
||||||
video_mode.width = window_w;
|
video_mode.width = window_w;
|
||||||
video_mode.height = window_h;
|
video_mode.height = window_h;
|
||||||
|
} else {
|
||||||
|
preserve_window_size = false;
|
||||||
|
int w = video_mode.width;
|
||||||
|
int h = video_mode.height;
|
||||||
|
|
||||||
|
RECT rect;
|
||||||
|
GetWindowRect(hWnd, &rect);
|
||||||
|
|
||||||
|
if (video_mode.borderless_window == false) {
|
||||||
|
RECT crect;
|
||||||
|
GetClientRect(hWnd, &crect);
|
||||||
|
|
||||||
|
w += (rect.right - rect.left) - (crect.right - crect.left);
|
||||||
|
h += (rect.bottom - rect.top) - (crect.bottom - crect.top);
|
||||||
|
}
|
||||||
|
|
||||||
|
MoveWindow(hWnd, rect.left, rect.top, w, h, TRUE);
|
||||||
}
|
}
|
||||||
if (wParam == SIZE_MAXIMIZED) {
|
if (wParam == SIZE_MAXIMIZED) {
|
||||||
maximized = true;
|
maximized = true;
|
||||||
|
@ -1561,6 +1578,15 @@ void OS_Windows::set_window_size(const Size2 p_size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
MoveWindow(hWnd, rect.left, rect.top, w, h, TRUE);
|
MoveWindow(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) {
|
||||||
|
RECT rect;
|
||||||
|
GetClientRect(hWnd, &rect);
|
||||||
|
ClientToScreen(hWnd, (POINT *)&rect.left);
|
||||||
|
ClientToScreen(hWnd, (POINT *)&rect.right);
|
||||||
|
ClipCursor(&rect);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void OS_Windows::set_window_fullscreen(bool p_enabled) {
|
void OS_Windows::set_window_fullscreen(bool p_enabled) {
|
||||||
|
|
||||||
|
@ -1767,6 +1793,7 @@ void OS_Windows::set_borderless_window(bool p_borderless) {
|
||||||
|
|
||||||
video_mode.borderless_window = p_borderless;
|
video_mode.borderless_window = p_borderless;
|
||||||
|
|
||||||
|
preserve_window_size = true;
|
||||||
_update_window_style();
|
_update_window_style();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1785,7 +1812,7 @@ void OS_Windows::_update_window_style(bool repaint) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SetWindowPos(hWnd, video_mode.always_on_top ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
|
SetWindowPos(hWnd, video_mode.always_on_top ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE);
|
||||||
|
|
||||||
if (repaint) {
|
if (repaint) {
|
||||||
RECT rect;
|
RECT rect;
|
||||||
|
@ -1996,7 +2023,7 @@ void OS_Windows::set_cursor_shape(CursorShape p_shape) {
|
||||||
if (cursor_shape == p_shape)
|
if (cursor_shape == p_shape)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (mouse_mode != MOUSE_MODE_VISIBLE) {
|
if (mouse_mode != MOUSE_MODE_VISIBLE && mouse_mode != MOUSE_MODE_CONFINED) {
|
||||||
cursor_shape = p_shape;
|
cursor_shape = p_shape;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,6 +105,7 @@ class OS_Windows : public OS {
|
||||||
|
|
||||||
Size2 window_rect;
|
Size2 window_rect;
|
||||||
VideoMode video_mode;
|
VideoMode video_mode;
|
||||||
|
bool preserve_window_size = false;
|
||||||
|
|
||||||
MainLoop *main_loop;
|
MainLoop *main_loop;
|
||||||
|
|
||||||
|
|
|
@ -2407,7 +2407,7 @@ void OS_X11::set_cursor_shape(CursorShape p_shape) {
|
||||||
|
|
||||||
if (p_shape == current_cursor)
|
if (p_shape == current_cursor)
|
||||||
return;
|
return;
|
||||||
if (mouse_mode == MOUSE_MODE_VISIBLE) {
|
if (mouse_mode == MOUSE_MODE_VISIBLE && mouse_mode != MOUSE_MODE_CONFINED) {
|
||||||
if (cursors[p_shape] != None)
|
if (cursors[p_shape] != None)
|
||||||
XDefineCursor(x11_display, x11_window, cursors[p_shape]);
|
XDefineCursor(x11_display, x11_window, cursors[p_shape]);
|
||||||
else if (cursors[CURSOR_ARROW] != None)
|
else if (cursors[CURSOR_ARROW] != None)
|
||||||
|
|
Loading…
Reference in a new issue