Skip to content

Commit

Permalink
Expose a pointer of EventLoopProxy to process custom messages (#674)
Browse files Browse the repository at this point in the history
  • Loading branch information
J-F-Liu committed Oct 15, 2020
1 parent b03d8da commit f66a725
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions crates/bevy_winit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ use winit::{
#[derive(Default)]
pub struct WinitPlugin;

#[derive(Debug)]
pub struct EventLoopProxyPtr(pub usize);

impl Plugin for WinitPlugin {
fn build(&self, app: &mut AppBuilder) {
app
Expand Down Expand Up @@ -134,6 +137,11 @@ pub fn winit_runner(mut app: App) {
let mut create_window_event_reader = EventReader::<CreateWindow>::default();
let mut app_exit_event_reader = EventReader::<AppExit>::default();

app.resources
.insert_thread_local(EventLoopProxyPtr(
Box::into_raw(Box::new(event_loop.create_proxy())) as usize,
));

handle_create_window_events(
&mut app.resources,
&event_loop,
Expand Down

0 comments on commit f66a725

Please sign in to comment.