Skip to content

Commit daba7a3

Browse files
HugoPeters1024HugoPeters1024
and
HugoPeters1024
authored
0.16 Regression fix: re-expose the display handle via a wrapper resource (#18644)
# Objective - In the latest released version (15.3) I am able to obtain this information by getting the actual `EventLoop` via `non_send_resource`. Now that this object has (probably rightfully so) been replaced by the `EventLoopProxy`, I can no longer maintain my custom render backend: https://github.com/HugoPeters1024/bevy_vulkan. I also need the display handle for a custom winit integration, for which I've made patches to bevy before: XREF: #15884 ## Solution - Luckily, all that is required is exposing the `OwnedDisplayHandle` in its own wrapper resource. ## Testing - Aforementioned custom rendering backend works on this commit. --------- Co-authored-by: HugoPeters1024 <[email protected]>
1 parent ec70a0f commit daba7a3

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

crates/bevy_winit/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ impl<T: Event> Plugin for WinitPlugin<T> {
127127
app.init_non_send_resource::<WinitWindows>()
128128
.init_resource::<WinitMonitors>()
129129
.init_resource::<WinitSettings>()
130+
.insert_resource(DisplayHandleWrapper(event_loop.owned_display_handle()))
130131
.add_event::<RawWinitWindowEvent>()
131132
.set_runner(|app| winit_runner(app, event_loop))
132133
.add_systems(
@@ -176,6 +177,15 @@ pub struct RawWinitWindowEvent {
176177
#[derive(Resource, Deref)]
177178
pub struct EventLoopProxyWrapper<T: 'static>(EventLoopProxy<T>);
178179

180+
/// A wrapper around [`winit::event_loop::OwnedDisplayHandle`]
181+
///
182+
/// The `DisplayHandleWrapper` can be used to build integrations that rely on direct
183+
/// access to the display handle
184+
///
185+
/// Use `Res<DisplayHandleWrapper>` to receive this resource.
186+
#[derive(Resource, Deref)]
187+
pub struct DisplayHandleWrapper(pub winit::event_loop::OwnedDisplayHandle);
188+
179189
trait AppSendEvent {
180190
fn send(&mut self, event: impl Into<WindowEvent>);
181191
}

0 commit comments

Comments
 (0)