Skip to content

Refactor winit_runner to make custom runners more usable #4537

@alice-i-cecile

Description

@alice-i-cecile

What problem does this solve or what need does it fill?

App runners 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.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-AppBevy apps and pluginsA-WindowingPlatform-agnostic interface layer to run your app inC-Code-QualityA section of code that is hard to understand or changeC-UsabilityA targeted quality-of-life change that makes Bevy easier to use

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions