set_cursor_position fails if CursorGrabMode is changed from Confined to None on the same frame
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
## Bevy version and features
Bevy 0.16.1, Windows 10, Rust 1.88.0
## What you did
When changing `CursorGrabMode::Confined` to `CursorGrabMode::None` on Windows, the cursor will appear in the center of the screen.
If you use `set_cursor_position()` on the same frame, it won't do anything - the cursor will remain in the center of the screen, instead of the location you specified.
The behavior I expected was that, if called on the same frame, `set_cursor_position` functionality would override the default cursor starting position (or that there might exist a way to specify the location of where the cursor should appear when changing `CursorGrabMode` like this).
## Additional information
A workaround is to change `CursorGrabMode::Confined` to `CursorGrabMode::None`, and then wait one frame before calling `set_cursor_position()`. This works but is a bit unergonomic and adds a bit of code complexity. It also requires you to make sure that the cursor is invisible until the second frame when the position is set, or it will flash onscreen for a frame in an unappealing way.
(I'm unsure if this issue belongs here or on the `winit` github; if the latter, sorry, and please let me know so I can post it there.)
Contributor guide
Assessment
This issue has not been assessed yet.