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

Web: use raw data in DeviceEvent::MouseMotion when using CursorGrabMode::Confined #3803

Merged
merged 1 commit into from
Jul 23, 2024

Conversation

daxpedda
Copy link
Member

@daxpedda daxpedda commented Jul 20, 2024

This uses Element.requestPointerLock with the unadjustedMovement options, which is notable only supported by Chrome and even there not on Linux.

I also updated the documentation to properly reflect the current state.

Needs entry in #2875.
Fixes #3547.

@daxpedda daxpedda force-pushed the web-cursor-grab branch 2 times, most recently from b7fef07 to 07bcbe0 Compare July 20, 2024 16:01
Copy link
Member

@kchibisov kchibisov left a comment

Choose a reason for hiding this comment

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

I'd assume that you mean Locked pointer, which is the one that stays in place.

Also, could you change the cursor position when the cursor is locked, since it's other API that usually works with locked cursor?

And I'd assume there's no way to confine cursor at all on web?

src/changelog/unreleased.md Outdated Show resolved Hide resolved
src/changelog/unreleased.md Outdated Show resolved Hide resolved
src/event.rs Outdated Show resolved Hide resolved
src/window.rs Outdated Show resolved Hide resolved
@daxpedda
Copy link
Member Author

Also, could you change the cursor position when the cursor is locked, since it's other API that usually works with locked cursor?

You can't change the cursor position on Web. What other API?
I'm not sure what you mean with that question.

And I'd assume there's no way to confine cursor at all on web?

Not AFAIK.

@kchibisov
Copy link
Member

You can't change the cursor position on Web. What other API?
I'm not sure what you mean with that question.

Locked cursor is usually works in pair with set_cursor_position API, since otherwise it's sort of useless, unless you completely hide the cursor and draw everything yourself, which could also be an option.

On Wayland, for example, where manipulating with cursor is also prohibited, the locked pointer has its own method to set its position, but it only works when you have the cursor lock present.

It's not really mandatory, it's just changes how you write things basically.

@daxpedda
Copy link
Member Author

Locked cursor is usually works in pair with set_cursor_position API, since otherwise it's sort of useless, unless you completely hide the cursor and draw everything yourself, which could also be an option.

Ah I see!
Yes, on Web the cursor is hidden, so its not a problem.
The position of the cursor remains the same as the position it was when it was locked.

Is the cursor not hidden in other backends when locked?
If not I should document this for Web.

@daxpedda daxpedda requested a review from kchibisov July 20, 2024 19:11
@kchibisov
Copy link
Member

Is the cursor not hidden in other backends when locked?
If not I should document this for Web.

it's generally not hidden and users tend to hide it themselves.

@daxpedda
Copy link
Member Author

Is the cursor not hidden in other backends when locked?
If not I should document this for Web.

it's generally not hidden and users tend to hide it themselves.

Ah, CursorGrabMode::Locked already says:

There's no guarantee that the cursor will be hidden. You should hide it by yourself if you want to do so.

I removed some duplicate documentation now that I see CursorGrabMode includes it already.

@daxpedda daxpedda merged commit 2e97ab3 into rust-windowing:master Jul 23, 2024
52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

Web: use raw mouse input when locking pointer
2 participants