Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose a pointer of EventLoopProxy to process custom messages #674

Merged
merged 1 commit into from
Oct 15, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -81,6 +84,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