From 4235e2c6e519c2c585a0bc62c0c86854fa67db74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tur=C3=A1nszki=20J=C3=A1nos?= Date: Sun, 30 Mar 2025 12:35:31 +0200 Subject: [PATCH] winapi cursor state improvements --- Editor/main_Windows.cpp | 19 +++++++++++++++++++ WickedEngine/wiInput.cpp | 5 +++++ WickedEngine/wiInput.h | 3 +++ 3 files changed, 27 insertions(+) diff --git a/Editor/main_Windows.cpp b/Editor/main_Windows.cpp index 1440a3c04..56262576d 100644 --- a/Editor/main_Windows.cpp +++ b/Editor/main_Windows.cpp @@ -303,6 +303,25 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) case WM_DESTROY: PostQuitMessage(0); break; + case WM_SETCURSOR: + switch (LOWORD(lParam)) + { + case HTBOTTOM: + case HTBOTTOMLEFT: + case HTBOTTOMRIGHT: + case HTLEFT: + case HTRIGHT: + case HTTOP: + case HTTOPLEFT: + case HTTOPRIGHT: + // allow the system to handle these window resize cursors: + return DefWindowProc(hWnd, message, wParam, lParam); + default: + // notify the engine at other cursor changes to set its own cursor instead + wi::input::NotifyCursorChanged(); + break; + } + break; default: return DefWindowProc(hWnd, message, wParam, lParam); } diff --git a/WickedEngine/wiInput.cpp b/WickedEngine/wiInput.cpp index cf9a7a15d..37738da7a 100644 --- a/WickedEngine/wiInput.cpp +++ b/WickedEngine/wiInput.cpp @@ -843,6 +843,11 @@ namespace wi::input cursor_current = CURSOR_COUNT; } + void NotifyCursorChanged() + { + cursor_current = CURSOR_COUNT; + } + BUTTON StringToButton(const char* str) { if (str == nullptr) diff --git a/WickedEngine/wiInput.h b/WickedEngine/wiInput.h index 01e94bd7d..e97d6d437 100644 --- a/WickedEngine/wiInput.h +++ b/WickedEngine/wiInput.h @@ -267,6 +267,9 @@ namespace wi::input // Resets specified cursor to the original: void ResetCursor(CURSOR cursor); + // Notify the engine's input system that the OS changed the cursor from outside + void NotifyCursorChanged(); + BUTTON StringToButton(const char* str); enum CONTROLLER_PREFERENCE