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

[Merged by Bors] - break feedback loop when moving cursor #7298

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions crates/bevy_winit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,11 @@ pub fn winit_runner(mut app: App) {
window.resolution.physical_height() as f64 - position.y,
);

window.set_physical_cursor_position(Some(physical_position));
// bypassing change detection to not trigger feedback loop with system `changed_window`
// this system change the cursor position in winit
window
.bypass_change_detection()
.set_physical_cursor_position(Some(physical_position));

cursor_events.cursor_moved.send(CursorMoved {
window: window_entity,
Expand All @@ -412,7 +416,11 @@ pub fn winit_runner(mut app: App) {
WindowEvent::CursorLeft { .. } => {
// Component
if let Ok((mut window, _)) = window_query.get_mut(window_entity) {
window.set_physical_cursor_position(None);
// bypassing change detection to not trigger feedback loop with system `changed_window`
// this system change the cursor position in winit
window
.bypass_change_detection()
.set_physical_cursor_position(None);
}

cursor_events.cursor_left.send(CursorLeft {
Expand Down
3 changes: 2 additions & 1 deletion examples/tools/scene_viewer/camera_controller_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ fn camera_controller(
for mouse_event in mouse_events.iter() {
mouse_delta += mouse_event.delta;
}
} else {
}
if mouse_button_input.just_released(options.mouse_key_enable_mouse) {
for mut window in &mut windows {
window.cursor.grab_mode = CursorGrabMode::None;
window.cursor.visible = true;
Expand Down