Batch events for processing in iced_winit event loop
This commit is contained in:
parent
50a7852cb8
commit
031784e274
1 changed files with 61 additions and 56 deletions
|
|
@ -469,9 +469,7 @@ async fn run_instance<A, E, C>(
|
|||
events.push(event);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
event::Event::AboutToWait => {
|
||||
if events.is_empty() && messages.is_empty() {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -488,12 +486,17 @@ async fn run_instance<A, E, C>(
|
|||
|
||||
debug.event_processing_finished();
|
||||
|
||||
for (event, status) in events.drain(..).zip(statuses.into_iter()) {
|
||||
for (event, status) in
|
||||
events.drain(..).zip(statuses.into_iter())
|
||||
{
|
||||
runtime.broadcast(event, status);
|
||||
}
|
||||
|
||||
if !messages.is_empty()
|
||||
|| matches!(interface_state, user_interface::State::Outdated)
|
||||
|| matches!(
|
||||
interface_state,
|
||||
user_interface::State::Outdated
|
||||
)
|
||||
{
|
||||
let mut cache =
|
||||
ManuallyDrop::into_inner(user_interface).into_cache();
|
||||
|
|
@ -504,7 +507,7 @@ async fn run_instance<A, E, C>(
|
|||
&mut compositor,
|
||||
&mut surface,
|
||||
&mut cache,
|
||||
&state,
|
||||
&mut state,
|
||||
&mut renderer,
|
||||
&mut runtime,
|
||||
&mut clipboard,
|
||||
|
|
@ -515,9 +518,6 @@ async fn run_instance<A, E, C>(
|
|||
&window,
|
||||
);
|
||||
|
||||
// Update window
|
||||
state.synchronize(&application, &window);
|
||||
|
||||
user_interface = ManuallyDrop::new(build_user_interface(
|
||||
&application,
|
||||
cache,
|
||||
|
|
@ -536,6 +536,9 @@ async fn run_instance<A, E, C>(
|
|||
redraw_pending = true;
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
// Manually drop the user interface
|
||||
drop(ManuallyDrop::into_inner(user_interface));
|
||||
|
|
@ -595,7 +598,7 @@ pub fn update<A: Application, C, E: Executor>(
|
|||
compositor: &mut C,
|
||||
surface: &mut C::Surface,
|
||||
cache: &mut user_interface::Cache,
|
||||
state: &State<A>,
|
||||
state: &mut State<A>,
|
||||
renderer: &mut A::Renderer,
|
||||
runtime: &mut Runtime<E, Proxy<A::Message>, A::Message>,
|
||||
clipboard: &mut Clipboard,
|
||||
|
|
@ -632,6 +635,8 @@ pub fn update<A: Application, C, E: Executor>(
|
|||
);
|
||||
}
|
||||
|
||||
state.synchronize(application, window);
|
||||
|
||||
let subscription = application.subscription();
|
||||
runtime.track(subscription.into_recipes());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue