From f63218eaa830f9514dba6c25a8836eca63b75fb1 Mon Sep 17 00:00:00 2001 From: HugoPeters1024 Date: Sun, 30 Mar 2025 23:18:05 +0200 Subject: [PATCH 1/2] expose the display handle via a wrapper resource --- crates/bevy_winit/src/lib.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crates/bevy_winit/src/lib.rs b/crates/bevy_winit/src/lib.rs index db74825f0fff6..a54fe64b33a44 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); } From 77cedd1c18dd0f88f3df3590c6c41ba572ab953c Mon Sep 17 00:00:00 2001 From: Hugo Peters Date: Mon, 31 Mar 2025 10:29:27 +0200 Subject: [PATCH 2/2] fixup! expose the display handle via a wrapper resource --- crates/bevy_winit/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/bevy_winit/src/lib.rs b/crates/bevy_winit/src/lib.rs index a54fe64b33a44..97943cc14a98d 100644 --- a/crates/bevy_winit/src/lib.rs +++ b/crates/bevy_winit/src/lib.rs @@ -179,10 +179,10 @@ pub struct EventLoopProxyWrapper(EventLoopProxy); /// A wrapper around [`winit::event_loop::OwnedDisplayHandle`] /// -/// The DisplayHandleWrapper can be used to build integrations that rely on direct +/// The `DisplayHandleWrapper` can be used to build integrations that rely on direct /// access to the display handle /// -/// Use Res to receive this resource. +/// Use `Res` to receive this resource. #[derive(Resource, Deref)] pub struct DisplayHandleWrapper(pub winit::event_loop::OwnedDisplayHandle);