Skip to content

Expose WindowDestroyed events#9016

Merged
james7132 merged 2 commits into
bevyengine:mainfrom
arendjr:expose-window-destroyed-event
Jul 4, 2023
Merged

Expose WindowDestroyed events#9016
james7132 merged 2 commits into
bevyengine:mainfrom
arendjr:expose-window-destroyed-event

Conversation

@arendjr

@arendjr arendjr commented Jul 1, 2023

Copy link
Copy Markdown
Contributor

Objective

I'm creating an iOS game and had to find a way to persist game state when the application is terminated. This required listening to the applicationWillTerminate() method, but I cannot do so myself anymore since winit already set up a delegate to listen for it, and there can be only one delegate.

So I had to move up the stack and try to respond to one of the events from winit instead. It appears winit fires two events that could serve my purpose: WindowEvent::Destroyed and Event::LoopDestroyed. It seemed to me the former might be slightly more generally useful, and I also found a past discussion that suggested it would be appropriate for Bevy to have a WindowDestroyed event: #5589 (comment)

Solution

  • I've added the WindowDestroyed event, which fires when winit fires WindowEvent::Destroyed.

Changelog

Added

  • Introduced a new WindowDestroyed event type. It is used to indicate a window has been destroyed by the windowing system.

@github-actions

github-actions Bot commented Jul 1, 2023

Copy link
Copy Markdown
Contributor

Welcome, new contributor!

Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨

@mockersf

mockersf commented Jul 1, 2023

Copy link
Copy Markdown
Member

thanks for the contribution! Could you run cargo fmt on your PR?

@arendjr

arendjr commented Jul 1, 2023

Copy link
Copy Markdown
Contributor Author

Hm, I did, but it didn't report any changes. But I've added the semicolon the CI was complaining about.

@Aceeri

Aceeri commented Jul 2, 2023

Copy link
Copy Markdown
Member

This is technically accomplishable with RemovedComponents I believe, but being consistent with the other events is helpful

@mockersf mockersf added A-Windowing Platform-agnostic interface layer to run your app in S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it labels Jul 2, 2023
@james7132 james7132 added this pull request to the merge queue Jul 4, 2023
Merged via the queue into bevyengine:main with commit ee82eec Jul 4, 2023
@arendjr arendjr deleted the expose-window-destroyed-event branch July 5, 2023 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Windowing Platform-agnostic interface layer to run your app in S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants