-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Closing multi windows #3241
Closing multi windows #3241
Conversation
pub struct WindowPlugin { | ||
pub add_primary_window: bool, | ||
pub exit_on_close: bool, | ||
pub exit_method: WindowExitMethod, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is bevy_window
meant to work apart from bevy_winit
? If so, I think this should be reverted. Since closing by WindowExitMethod
is controlled by bevy_winit
, it might make sense to leave this option in for the pure bevy_window
(and instead maybe just default the value to false
).
The best way to fix the rendering issue is probably to wait until the old renderer is removed; the new renderer only requires small changes to make it not panic. That being said, I think the solution in #2898 is much cleaner; it's a bit more code, but it composes much more nicely. Is there a reason you disregarded that approach? Fwiw, I was intending to re-open #2898 (or re-create it into a new PR) once the old renderer was removed, although obviously I don't mind someone else driving it forwards. |
This was a huge misstep on my part. For some reason, I thought that #2898 was merged and that all the window-related code was from that PR as well. I do agree that it's much cleaner, especially using standard systems to handle whether the app should be exited or not. I originally tried to do that, but the version of Although, I think the configuration should be made into a resource as described in #3180 so it's easier to access/modify. And an enum like But we can close this for now and wait for the old renderer to be removed, then open up #2898 again. Sorry for the mess! 😅 |
Objective
Currently, if any window is closed, the app quits entirely. This goal of this PR is to create a configurable resource to control how the app reacts to a window being closed.
Fixes #3180.
Solution
Removed the
exit_on_window_close_system
frombevy_window
and replaced its functionality with a function inbevy_winit
. The reason for this was to allow the reading and writing to world resources without having to add thebevy_ecs
dependency tobevy_window
, and to drop the Window from theWinitWindows
resource.Using the
WindowsConfig
resource, we can specify anexit_method
. I added the following methods to start:The
WindowsConfig
resource defaults with theWindowExitMethod::PrimaryClosed
method.I'm not sure if this is the best way to solve this or not, but it at least provides some functionality.
Issues
Removing the Window
One thing I was trying to do was also remove the window from the
Windows
resource, but I wasn't sure how to solve the following error though:I imagine this is a system ordering or caching issue of some kind. Is there anyone who has an idea of what might be causing the problem?
Resetting the Primary Window
Currently, the primary window is defined as
But one question, I wanted to ask is, "Should we update the primary window if it's closed?" Personally, I think it's best to keep this as is, but I wanted to hear other thoughts as well.