Skip to content

Remove window descriptor resource once used #2886

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

Closed
wants to merge 3 commits into from
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
3 changes: 1 addition & 2 deletions crates/bevy_window/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ impl Plugin for WindowPlugin {
if self.add_primary_window {
let window_descriptor = app
.world
.get_resource::<WindowDescriptor>()
.map(|descriptor| (*descriptor).clone())
.remove_resource::<WindowDescriptor>()
.unwrap_or_else(WindowDescriptor::default);
let mut create_window_event = app
.world
Expand Down
4 changes: 4 additions & 0 deletions crates/bevy_window/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,10 @@ impl Window {
}
}

/// This resource will only be used as initialization to setup the window.
/// To change those settings during runtime, the [`Windows`](super::windows::Windows)
/// resource should be used. See example
/// [window_settings](https://github.com/bevyengine/bevy/blob/latest/examples/window/window_settings.rs)
#[derive(Debug, Clone)]
pub struct WindowDescriptor {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this PR makes this initialization only, what do you think about renaming this to WindowInitializationDescriptor? It's a bit long, but it makes it more obvious that it's only used for initialization.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually think this is a very good idea

pub width: f32,
Expand Down