From 9d63fc7ca0f445de3cea1018729a200e8e7dd6ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20R=C3=83=C2=B8yset?= Date: Tue, 5 Jan 2021 17:39:13 +0100 Subject: [PATCH] On Windows, set the cursor icon when the cursor first enters a window (#1807) --- CHANGELOG.md | 1 + src/platform_impl/windows/event_loop.rs | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ea826f7..ea0df5a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Unreleased +- On Windows, fix bug causing newly created windows to erroneously display the "wait" (spinning) cursor. - On Windows, change the default window size (1024x768) to match the default on other desktop platforms (800x600). - On Windows, fix bug causing mouse capture to not be released. - On Windows, fix fullscreen not preserving minimized/maximized state. diff --git a/src/platform_impl/windows/event_loop.rs b/src/platform_impl/windows/event_loop.rs index da3c48d3..2b518e9e 100644 --- a/src/platform_impl/windows/event_loop.rs +++ b/src/platform_impl/windows/event_loop.rs @@ -20,7 +20,7 @@ use winapi::shared::basetsd::{DWORD_PTR, UINT_PTR}; use winapi::{ shared::{ - minwindef::{BOOL, DWORD, HIWORD, INT, LOWORD, LPARAM, LRESULT, UINT, WPARAM}, + minwindef::{BOOL, DWORD, HIWORD, INT, LOWORD, LPARAM, LRESULT, UINT, WORD, WPARAM}, windef::{HWND, POINT, RECT}, windowsx, winerror, }, @@ -1664,11 +1664,11 @@ unsafe fn public_window_callback_inner( winuser::WM_SETCURSOR => { let set_cursor_to = { let window_state = subclass_input.window_state.lock(); - if window_state - .mouse - .cursor_flags() - .contains(CursorFlags::IN_WINDOW) - { + // The return value for the preceding `WM_NCHITTEST` message is conveniently + // provided through the low-order word of lParam. We use that here since + // `WM_MOUSEMOVE` seems to come after `WM_SETCURSOR` for a given cursor movement. + let in_client_area = LOWORD(lparam as DWORD) == winuser::HTCLIENT as WORD; + if in_client_area { Some(window_state.mouse.cursor) } else { None