diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-06-22 13:00:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-22 13:00:58 +0200 |
commit | 2cd36209cc748d485f3ed16ef8bc059e51904b4a (patch) | |
tree | c7ab277dc37778b9509d0f5411dcd9507986e3da | |
parent | 6869d5d19030e29ca7e15812bb98d93ef1eafcc0 (diff) | |
parent | fc1d1c3557de3339d18df2639e12edca33a774a5 (diff) |
Merge pull request #39750 from bruvzg/win_fix_mouse_mode
[Windows] Fix mouse cursor not shown after multiple mode changes.
-rw-r--r-- | platform/windows/display_server_windows.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index 7cb6e90edb..f47afcc4e5 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -103,7 +103,11 @@ void DisplayServerWindows::_set_mouse_mode_impl(MouseMode p_mode) { } if (p_mode == MOUSE_MODE_CAPTURED || p_mode == MOUSE_MODE_HIDDEN) { - hCursor = SetCursor(nullptr); + if (hCursor == nullptr) { + hCursor = SetCursor(nullptr); + } else { + SetCursor(nullptr); + } } else { CursorShape c = cursor_shape; cursor_shape = CURSOR_MAX; @@ -117,9 +121,9 @@ void DisplayServerWindows::mouse_set_mode(MouseMode p_mode) { if (mouse_mode == p_mode) return; - _set_mouse_mode_impl(p_mode); - mouse_mode = p_mode; + + _set_mouse_mode_impl(p_mode); } DisplayServer::MouseMode DisplayServerWindows::mouse_get_mode() const { @@ -2654,10 +2658,11 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA if (LOWORD(lParam) == HTCLIENT) { if (windows[window_id].window_has_focus && (mouse_mode == MOUSE_MODE_HIDDEN || mouse_mode == MOUSE_MODE_CAPTURED)) { //Hide the cursor - if (hCursor == nullptr) + if (hCursor == nullptr) { hCursor = SetCursor(nullptr); - else + } else { SetCursor(nullptr); + } } else { if (hCursor != nullptr) { CursorShape c = cursor_shape; |