Skip to content

Commit a133d64

Browse files
masonry_winit: Pass a EventLoopProxy (linebender#1045)
Instead of passing an `&EventLoop` to `MasonryState`, we pass an `EventLoopProxy` as that's all that it actually needs. We also rename `proxy` to `event_loop_proxy`.
1 parent 6be3661 commit a133d64

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

masonry_winit/src/event_loop_runner.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ pub struct MasonryState<'a> {
124124
renderer: Option<Renderer>,
125125
// TODO: Winit doesn't seem to let us create these proxies from within the loop
126126
// The reasons for this are unclear
127-
proxy: EventLoopProxy,
127+
event_loop_proxy: EventLoopProxy,
128128
#[cfg(feature = "tracy")]
129129
frame: Option<tracing_tracy::client::Frame>,
130130

@@ -186,7 +186,7 @@ pub fn run_with(
186186
let _ = crate::app::try_init_tracing();
187187

188188
let mut main_state = MainState {
189-
masonry_state: MasonryState::new(&event_loop, windows, default_properties),
189+
masonry_state: MasonryState::new(event_loop.create_proxy(), windows, default_properties),
190190
app_driver: Box::new(app_driver),
191191
};
192192
main_state
@@ -266,7 +266,7 @@ impl ApplicationHandler<MasonryUserEvent> for MainState<'_> {
266266

267267
impl MasonryState<'_> {
268268
pub fn new(
269-
event_loop: &EventLoop,
269+
event_loop_proxy: EventLoopProxy,
270270
initial_windows: Vec<(WindowId, WindowAttributes, Box<dyn Widget>)>,
271271
default_properties: DefaultProperties,
272272
) -> Self {
@@ -279,9 +279,9 @@ impl MasonryState<'_> {
279279
MasonryState {
280280
render_cx,
281281
renderer: None,
282+
event_loop_proxy,
282283
#[cfg(feature = "tracy")]
283284
frame: None,
284-
proxy: event_loop.create_proxy(),
285285
signal_receiver,
286286

287287
last_anim: None,
@@ -374,7 +374,8 @@ impl MasonryState<'_> {
374374
self.need_first_frame.push(handle.id());
375375
}
376376

377-
let adapter = Adapter::with_event_loop_proxy(event_loop, &handle, self.proxy.clone());
377+
let adapter =
378+
Adapter::with_event_loop_proxy(event_loop, &handle, self.event_loop_proxy.clone());
378379
let handle = Arc::new(handle);
379380
// https://github.com/rust-windowing/winit/issues/2308
380381
#[cfg(target_os = "ios")]

xilem/examples/external_event_loop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ fn main() -> Result<(), EventLoopError> {
137137
let (driver, window_id, root_widget) =
138138
xilem.into_driver_and_window(move |event| proxy.send_event(event).map_err(|err| err.0));
139139
let masonry_state = masonry_winit::app::MasonryState::new(
140-
&event_loop,
140+
event_loop.create_proxy(),
141141
vec![(window_id, window_attributes, root_widget)],
142142
default_property_set(),
143143
);

0 commit comments

Comments
 (0)