-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Part of #3367, opening to discuss separately.
Winit is designed around a single crate with a specific set of backends, which is great for users that can use that, but there is a need for other backends that are not implemented in Winit today, like GTK. Additionally, the backend-specific extensions that we do have usually constrain some other part of the design.
So it would probably be useful to try to split Winit into multiple smaller crates (though still in the same repository), to ease doing this work. The top-level winit crate would still remain.
Along with this, we'd want a way to write out-of-tree backends, and allow the user to integrate them into their application. This could probably be solved by introducing internal / "backend" traits, and keep a dyn in structures inside the winit crate.
A rough implementation plan could be:
- Create a
winit-corecrate, which contains the common types that all backends use (likedpiand keyboard types) - Make traits in
winit-core, that implements the desired functionality, and move each backend to also implement those traits. - Move the main
winitcrate to an API that is notcfg-based, butdyn Trait-based. - Introduce a
winit-commoncrate to have shared functionality between the crates, which will be intended for winit internal usage and help writing new backends. - Move the backends out into separate crates, which all depend on
winit-core, but still have the mainwinitcrate "merge" these backends withcfgs, not with a trait.
@kchibisov: I've tried to fairly faithfully reproduce what I felt was the important points from #3367, but please edit this issue description with your own.
EDIT: Implementation history:
- Refactor to
dyntraits: - Refactorings:
- Remove
dummy()fromWindowIdandDeviceIdand useOption<DeviceId>#3864 - Merge all
WindowIdinto a single type in the core crate #3902 - api: add
DeviceId::{into,from}_raw#3941 - Add
as_innerhelper method on trait objects #4160 - chore: Import from winit-core instead of the top-level crate #4225
- Move
EventLoopExt*towinit-core#4228 - Use workspace dependencies everywhere #4240
- chore: Move event loop recreation check into backends themselves #4257
- Remove
- Core split: winit-core: new crate #4208
- Figure out naming: Backend naming #4246
- Moving backends:
- Common: Move shared code to new crate
winit-common#4241 - Android: Move Android backend to
winit-android#4250 - AppKit: Move AppKit backend to
winit-appkit#4248 - Orbital: Split Orbital backend out into
winit-orbital#4243 - UIKit: Split UIKit backend out into
winit-uikit#4242 - Web: Move Web backend to
winit-web#4249 - Windows: Move Windows backend to
winit-win32#4247 - Wayland: Move Wayland backend to
winit-wayland#4252 - X11: Move X11 backend to
winit-x11#4253
- Common: Move shared code to new crate
- Reserve crate names (DONE).
- Move top-level crate: Move winit itself to crate #4258
- Docs + changelog cleanup: TODO
- Clean up CI: TODO
- doc_auto_cfg: TODO
- Rename / refactor extension traits: TODO
- Figure out how we do releases / versioning: Use a shared version number for all winit-* crates #4274
- Make sure features like
serdeis properly enabled throughout: TODO