Skip to content
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

Refactor winit_runner to make custom runners more usable #4537

Open
alice-i-cecile opened this issue Apr 19, 2022 · 3 comments
Open

Refactor winit_runner to make custom runners more usable #4537

alice-i-cecile opened this issue Apr 19, 2022 · 3 comments
Labels
A-App Bevy apps and plugins A-Windowing Platform-agnostic interface layer to run your app in C-Code-Quality A section of code that is hard to understand or change C-Usability A targeted quality-of-life change that makes Bevy easier to use

Comments

@alice-i-cecile
Copy link
Member

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.

@alice-i-cecile alice-i-cecile added A-Windowing Platform-agnostic interface layer to run your app in C-Code-Quality A section of code that is hard to understand or change C-Usability A targeted quality-of-life change that makes Bevy easier to use A-App Bevy apps and plugins labels Apr 19, 2022
@alice-i-cecile alice-i-cecile changed the title Refactor winit_runner to make custom runners more usable Refactor winit_runner to make custom runners more reusable Apr 19, 2022
@alice-i-cecile alice-i-cecile changed the title Refactor winit_runner to make custom runners more reusable Refactor winit_runner to make custom runners more usable Apr 19, 2022
@bjorn3
Copy link
Contributor

bjorn3 commented Apr 19, 2022

winit_runner_with is necessary to run on another thread than the main thread as you need to pass in EventLoop::new_any_thread() in that case. It is also necessary to force a specific window api like X11 or Wayland.

@alice-i-cecile
Copy link
Member Author

Useful context, thanks. We should really document that in the comments.

@fowenix
Copy link

fowenix commented Apr 20, 2022

After a day of trying to get bevy_winit to work with #4531, i keep getting stuck with borrow checker issues because of the usage of app.world everywhere in the Event::WindowEvent match statement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-App Bevy apps and plugins A-Windowing Platform-agnostic interface layer to run your app in C-Code-Quality A section of code that is hard to understand or change C-Usability A targeted quality-of-life change that makes Bevy easier to use
Projects
None yet
Development

No branches or pull requests

3 participants