-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Description
Bevy version and features
- Still applies as of
maine2b2f4a
Relevant system information
This is on wayland.
AdapterInfo { name: "Apple M2 (G14G B0)", vendor: 65541, device: 0, device_type: IntegratedGpu, driver: "Honeykrisp", driver_info: "Mesa 26.0.0-devel (git-ad2f112ac2)", backend: Vulkan }
What you did
I am trying to create windows dynamically, and there is no meaning in having an initial window in my app, so I tried to disable it.
To have a simple reproducer, let's take the code from examples/window/multiple_windows.rs, and apply the following change:
diff --git ./examples/window/multiple_windows.rs ./examples/window/multiple_windows.rs
index 46d4a708a5a04eb35de8..dcb7a42a33f8d20b6a48 100644
--- ./examples/window/multiple_windows.rs
+++ ./examples/window/multiple_windows.rs
@@ -5,7 +5,10 @@
fn main() {
App::new()
// By default, a primary window gets spawned by `WindowPlugin`, contained in `DefaultPlugins`
- .add_plugins(DefaultPlugins)
+ .add_plugins(DefaultPlugins.set(WindowPlugin {
+ primary_window: None,
+ ..default()
+ }))
.add_systems(Startup, setup_scene)
.run();
}The intent being that this would stop the primary window from being created, while the second window continues to be created a few lines below, and the end result is that exactly one window appears, and it's the second one.
What went wrong
Instead, no window appears, but the app keeps running, presumably because the condition of "is there any window left open applies, meaning that the window was created enough for that, but not enough to be visible.
Additional information
A workaround that works is to let the default window get created (by not overriding primary_window), and then immediately close it at startup:
app.add_systems(Startup, close_primary_window);fn close_primary_window(
mut commands: Commands,
primary_window: Single<Entity, With<PrimaryWindow>>,
) {
commands.entity(*primary_window).despawn();
}