bevy/crates/bevy_winit/src
Arend van Beelen jr ee82eec2b3
Expose WindowDestroyed events (#9016)
# 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](https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1623111-applicationwillterminate),
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:
https://github.com/bevyengine/bevy/pull/5589#discussion_r942811021

## 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.
2023-07-04 21:50:53 +00:00
..
accessibility.rs Require #[derive(Event)] on all Events (#7086) 2023-06-06 14:44:32 +00:00
converters.rs Add window entity to mouse and keyboard events (#8852) 2023-06-16 13:54:06 +00:00
lib.rs Expose WindowDestroyed events (#9016) 2023-07-04 21:50:53 +00:00
system.rs Support to set window theme and expose system window theme changed event (#8593) 2023-06-05 21:04:22 +00:00
web_resize.rs Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
winit_config.rs Fixed several missing links in docs. (#8117) 2023-04-23 17:28:36 +00:00
winit_windows.rs Fix windows not being centered properly when system interface is scaled (#8903) 2023-06-21 14:00:35 +00:00