From 6225df94977ddb1644f039d98b7fc945f510c955 Mon Sep 17 00:00:00 2001 From: doonv <58695417+doonv@users.noreply.github.com> Date: Fri, 3 Apr 2026 00:27:23 +0300 Subject: [PATCH 1/2] Replace unnecessary `&Window` reference in `exit_on_all_closed` with `With` --- crates/bevy_window/src/system.rs | 2 +- crates/bevy_winit/src/lib.rs | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/crates/bevy_window/src/system.rs b/crates/bevy_window/src/system.rs index 112770e6097f4..084a96fe25dee 100644 --- a/crates/bevy_window/src/system.rs +++ b/crates/bevy_window/src/system.rs @@ -10,7 +10,7 @@ use bevy_ecs::prelude::*; /// Ensure that you read the caveats documented on that field if doing so. /// /// [`WindowPlugin`]: crate::WindowPlugin -pub fn exit_on_all_closed(mut app_exit_writer: MessageWriter, windows: Query<&Window>) { +pub fn exit_on_all_closed(mut app_exit_writer: MessageWriter, windows: Query<(), With>) { if windows.is_empty() { log::info!("No windows are open, exiting"); app_exit_writer.write(AppExit::Success); diff --git a/crates/bevy_winit/src/lib.rs b/crates/bevy_winit/src/lib.rs index 2bd3456e96259..7ae6c47b8576c 100644 --- a/crates/bevy_winit/src/lib.rs +++ b/crates/bevy_winit/src/lib.rs @@ -23,7 +23,7 @@ use winit::{event_loop::EventLoop, window::WindowId}; use bevy_a11y::AccessibilityRequested; use bevy_app::{App, Last, Plugin}; use bevy_ecs::prelude::*; -use bevy_window::{exit_on_all_closed, CursorOptions, Window, WindowCreated}; +use bevy_window::{CursorOptions, Window, WindowCreated}; use system::{changed_cursor_options, changed_windows, check_keyboard_focus_lost, despawn_windows}; pub use system::{create_monitors, create_windows}; #[cfg(all(target_family = "wasm", target_os = "unknown"))] @@ -136,9 +136,7 @@ impl Plugin for WinitPlugin { .add_systems( Last, ( - // `exit_on_all_closed` only checks if windows exist but doesn't access data, - // so we don't need to care about its ordering relative to `changed_windows` - changed_windows.ambiguous_with(exit_on_all_closed), + changed_windows, changed_cursor_options, despawn_windows, check_keyboard_focus_lost, From 98159f3c972378f496683bdcfd0cfae265a0061c Mon Sep 17 00:00:00 2001 From: doonv <58695417+doonv@users.noreply.github.com> Date: Fri, 3 Apr 2026 00:37:27 +0300 Subject: [PATCH 2/2] Fix formatting --- crates/bevy_window/src/system.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/bevy_window/src/system.rs b/crates/bevy_window/src/system.rs index 084a96fe25dee..e53f0101f22b9 100644 --- a/crates/bevy_window/src/system.rs +++ b/crates/bevy_window/src/system.rs @@ -10,7 +10,10 @@ use bevy_ecs::prelude::*; /// Ensure that you read the caveats documented on that field if doing so. /// /// [`WindowPlugin`]: crate::WindowPlugin -pub fn exit_on_all_closed(mut app_exit_writer: MessageWriter, windows: Query<(), With>) { +pub fn exit_on_all_closed( + mut app_exit_writer: MessageWriter, + windows: Query<(), With>, +) { if windows.is_empty() { log::info!("No windows are open, exiting"); app_exit_writer.write(AppExit::Success);