-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Window.cursor_position can return Some when it shouldn't #8840
Copy link
Copy link
Closed
Labels
A-WindowingPlatform-agnostic interface layer to run your app inPlatform-agnostic interface layer to run your app inC-BugAn unexpected or incorrect behaviorAn unexpected or incorrect behavior
Description
Bevy version
0.10.1
What you did
Called the Window.cursor_position method after moving mouse from one window to another.
What went wrong
It intermittently returns Some(...) when it should be None.
Additional information
Using the small app below, this video shows the issue clearly. You can see that sometimes, but not always, when moving the cursor from one window directly to another window, the first window still thinks it has the cursor. This results in multiple windows claiming they have the cursor, while only one can at any one time.
I can see here Bevy sets the cursor position to None when it sees a WindowEvent::CursorLeft event from winit, but I verified that it is fired every time, even when the issue occurs, so I don't believe this is a bug in winit.
Screen.Recording.2023-06-14.at.7.26.15.pm.mov
Minimal app:
use bevy::prelude::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins.set(WindowPlugin {
primary_window: Some(Window {
position: WindowPosition::At(IVec2::new(400, 200)),
..default()
}),
..default()
}))
.add_startup_system(setup)
.add_system(print_cursor_position)
.run();
}
fn setup(mut commands: Commands) {
commands.spawn(Window {
title: "Second window".to_owned(),
position: WindowPosition::At(IVec2::new(0, 0)),
..default()
});
}
fn print_cursor_position(windows_q: Query<&Window>) {
for window in windows_q.iter() {
println!(
"Window '{}' cursor position: {:?}",
window.title,
window.cursor_position()
);
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-WindowingPlatform-agnostic interface layer to run your app inPlatform-agnostic interface layer to run your app inC-BugAn unexpected or incorrect behaviorAn unexpected or incorrect behavior