Setting cursor position on same frame as locking cursor fails.

Open
#26,397 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
1-2 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
linux, rust
Domain
desktop

Research direction

The failing call is the window cursor-position update in bevy_winit, which runs in the changed_window and changed_cursor_options systems; the issue suggests their order matters. Read those systems in the bevy_winit crate and reproduce the picking-observer scenario on Linux/Wayland. Done means setting the cursor position and the Locked grab mode in the same frame no longer logs the 'cursor position can be set only for locked cursor' error and the cursor actually moves.

Written by the indexing model from the issue text.

Description

A-Windowing C-Bug D-Straightforward S-Needs-Investigation

Bevy version and features

  • Bevy 0.19.1

Relevant system information

  • Linux

What you did

// window is Query<(&mut Window, &mut CursorOptions)>

let Ok((mut window, mut cursor)) = window.get_mut(event.entity) else {
    return;
};
let mid_position = window.size() * 0.5;
window.set_cursor_position(Some(mid_position));
cursor.grab_mode = CursorGrabMode::Locked;

This is happening in a picking observer (so not at startup).

What went wrong

2026-11-01T19:42:06.399277Z ERROR bevy_winit::system: could not set cursor position: os error at /.../winit-0.30.13/src/platform_impl/linux/wayland/window/state.rs:951: cursor position can be set only for locked cursor.

Setting the grab mode on the same frame as setting the cursor position fails to move the cursor!

Additional information

It might be sufficient to just change the order of the changed_window and changed_cursor_options systems.

Dominant language
Rust
Stars
49.8k
Forks
5.1k
Avg merge
3d 4h
Merged PRs (30d)
136

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from bevyengine/bevy

All issues in bevyengine/bevy

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.