Refactor winit_runner to make custom runners more usable
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
## What problem does this solve or what need does it fill?
App [runners](https://docs.rs/bevy/latest/bevy/app/struct.App.html#structfield.runner) control the main loop of Bevy apps.
Unfortunately, `winit` also needs to control the main loop of the app, and thus integrating Bevy with winit requires the use of a specialized [`winit_runner`](https://github.com/bevyengine/bevy/blob/fb02b842244ae562a1e939a471ea6cc108e8c5f0/crates/bevy_winit/src/lib.rs#L219).
This code is entirely monolithic, which makes it very challenging to reuse windowing functionality while using a specialized runner.
## What solution would you like?
Refactor the contents of `winit_runner` and `winit_runner_with` (which frankly just looks like it shouldn't exist at this point).
The code feels like it can be split up into three parts:
1. A default framework for converting `winit` `WindowEvents` into Bevy data.
2. Small, useful public functions that handle the conversion of specific window event types.
3. Looping control.
## What alternative(s) have you considered?
I've seen users copy-paste the code into their own runner, and make their tweaks there. This is not great, because it means any improvements or fixes we make aren't incorporated upstream.
## Additional context
Discussed in the context of #4530, which will require a serious refactor anyways.
Contributor guide
Assessment
This issue has not been assessed yet.