diff --git a/crates/bevy_winit/src/lib.rs b/crates/bevy_winit/src/lib.rs index db74825f0f..97943cc14a 100644 --- a/crates/bevy_winit/src/lib.rs +++ b/crates/bevy_winit/src/lib.rs @@ -127,6 +127,7 @@ impl Plugin for WinitPlugin { app.init_non_send_resource::() .init_resource::() .init_resource::() + .insert_resource(DisplayHandleWrapper(event_loop.owned_display_handle())) .add_event::() .set_runner(|app| winit_runner(app, event_loop)) .add_systems( @@ -176,6 +177,15 @@ pub struct RawWinitWindowEvent { #[derive(Resource, Deref)] pub struct EventLoopProxyWrapper(EventLoopProxy); +/// A wrapper around [`winit::event_loop::OwnedDisplayHandle`] +/// +/// The `DisplayHandleWrapper` can be used to build integrations that rely on direct +/// access to the display handle +/// +/// Use `Res` to receive this resource. +#[derive(Resource, Deref)] +pub struct DisplayHandleWrapper(pub winit::event_loop::OwnedDisplayHandle); + trait AppSendEvent { fn send(&mut self, event: impl Into); }