Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Windows] Set the cursor icon when the cursor first enters a window #1807

Merged
merged 1 commit into from
Jan 5, 2021

Conversation

maroider
Copy link
Member

@maroider maroider commented Dec 23, 2020

  • Tested on all platforms changed
  • Compilation warnings were addressed
  • cargo fmt has been run on this branch
  • cargo doc builds successfully
  • Added an entry to CHANGELOG.md if knowledge of this change could be valuable to users
  • Updated documentation to reflect any user-facing changes, including notes of platform-specific behavior
  • Created or updated an example program if it would help users understand this functionality
  • Updated feature matrix, if new features were added or implemented

I'm not sure if this is the best way to address #1682 since I'm not familiar with how Windows handles cursors WRT windows, and I plan on looking further into this before converting from a draft PR to a normal PR.

Fixes #1682

@maroider
Copy link
Member Author

It turns out that the first attempt at a fix made it so the "resize" cursor icons never appeared when hovering the cursor over the window borders.

@maroider
Copy link
Member Author

maroider commented Jan 3, 2021

It turns out that WM_SETCURSOR arrives with hit-test results in the low-order "word" of lParam, so we can use that instead of relying on other messages.

I'm mildly concerned about ordering guarantees here (if any such thing exists for this case), since users may want to set a cursor and have it applied immediately when the cursor enters the window. It may actually be fine in practice, but I don't know for sure.

@maroider maroider marked this pull request as ready for review January 3, 2021 10:02
@msiglreith msiglreith added DS - windows C - waiting on maintainer A maintainer must review this code labels Jan 4, 2021
@msiglreith msiglreith self-requested a review January 4, 2021 16:07
Copy link
Member

@msiglreith msiglreith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

.cursor_flags()
.contains(CursorFlags::IN_WINDOW)
{
if (lparam & 0xFFFF) == winuser::HTCLIENT {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(lparam & 0xFFFF) -> LOWORD(lparam)
Also, wrapping the condition into a separate let statement and/or short command regarding hit-testing here would be great

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

command

I assume you meant to write "comment" here.

@maroider
Copy link
Member Author

maroider commented Jan 5, 2021

Never mind that push. I trusted rust-analyzer a bit too much while I simultaneously did something rust-analyzer didn't support.

@maroider maroider force-pushed the windows-initial-cursor branch 2 times, most recently from e496138 to f88ab68 Compare January 5, 2021 12:14
@msiglreith msiglreith merged commit 9d63fc7 into rust-windowing:master Jan 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C - waiting on maintainer A maintainer must review this code DS - windows
Development

Successfully merging this pull request may close these issues.

Windows spinning cursor on startup
2 participants