[Windows] Hide cursor before moving.

This commit is contained in:
bruvzg 2024-08-27 08:44:05 +03:00
parent db76de5de8
commit 9a2977fef1

View file

@ -133,9 +133,17 @@ String DisplayServerWindows::get_name() const {
} }
void DisplayServerWindows::_set_mouse_mode_impl(MouseMode p_mode) { void DisplayServerWindows::_set_mouse_mode_impl(MouseMode p_mode) {
if (p_mode == MOUSE_MODE_HIDDEN || p_mode == MOUSE_MODE_CAPTURED || p_mode == MOUSE_MODE_CONFINED_HIDDEN) {
// Hide cursor before moving.
if (hCursor == nullptr) {
hCursor = SetCursor(nullptr);
} else {
SetCursor(nullptr);
}
}
if (windows.has(MAIN_WINDOW_ID) && (p_mode == MOUSE_MODE_CAPTURED || p_mode == MOUSE_MODE_CONFINED || p_mode == MOUSE_MODE_CONFINED_HIDDEN)) { if (windows.has(MAIN_WINDOW_ID) && (p_mode == MOUSE_MODE_CAPTURED || p_mode == MOUSE_MODE_CONFINED || p_mode == MOUSE_MODE_CONFINED_HIDDEN)) {
// Mouse is grabbed (captured or confined). // Mouse is grabbed (captured or confined).
WindowID window_id = _get_focused_window_or_popup(); WindowID window_id = _get_focused_window_or_popup();
if (!windows.has(window_id)) { if (!windows.has(window_id)) {
window_id = MAIN_WINDOW_ID; window_id = MAIN_WINDOW_ID;
@ -165,13 +173,8 @@ void DisplayServerWindows::_set_mouse_mode_impl(MouseMode p_mode) {
_register_raw_input_devices(INVALID_WINDOW_ID); _register_raw_input_devices(INVALID_WINDOW_ID);
} }
if (p_mode == MOUSE_MODE_HIDDEN || p_mode == MOUSE_MODE_CAPTURED || p_mode == MOUSE_MODE_CONFINED_HIDDEN) { if (p_mode == MOUSE_MODE_VISIBLE || p_mode == MOUSE_MODE_CONFINED) {
if (hCursor == nullptr) { // Show cursor.
hCursor = SetCursor(nullptr);
} else {
SetCursor(nullptr);
}
} else {
CursorShape c = cursor_shape; CursorShape c = cursor_shape;
cursor_shape = CURSOR_MAX; cursor_shape = CURSOR_MAX;
cursor_set_shape(c); cursor_set_shape(c);