Merge pull request #2214 from dtzxporter/workaround-winit-win32-issues
Workaround issue with winit on windows not resuming the event loop.
This commit is contained in:
commit
80a29a277e
2 changed files with 43 additions and 14 deletions
|
|
@ -96,6 +96,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- Slow touch scrolling for `TextEditor` widget. [#2140](https://github.com/iced-rs/iced/pull/2140)
|
- Slow touch scrolling for `TextEditor` widget. [#2140](https://github.com/iced-rs/iced/pull/2140)
|
||||||
- `Subscription::map` using unreliable function pointer hash to identify mappers. [#2237](https://github.com/iced-rs/iced/pull/2237)
|
- `Subscription::map` using unreliable function pointer hash to identify mappers. [#2237](https://github.com/iced-rs/iced/pull/2237)
|
||||||
- Missing feature flag docs for `time::every`. [#2188](https://github.com/iced-rs/iced/pull/2188)
|
- Missing feature flag docs for `time::every`. [#2188](https://github.com/iced-rs/iced/pull/2188)
|
||||||
|
- Event loop not being resumed on Windows while resizing. [#2214](https://github.com/iced-rs/iced/pull/2214)
|
||||||
|
|
||||||
Many thanks to...
|
Many thanks to...
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -213,26 +213,54 @@ where
|
||||||
|
|
||||||
let mut context = task::Context::from_waker(task::noop_waker_ref());
|
let mut context = task::Context::from_waker(task::noop_waker_ref());
|
||||||
|
|
||||||
let _ = event_loop.run(move |event, event_loop| {
|
let process_event =
|
||||||
if event_loop.exiting() {
|
move |event, event_loop: &winit::event_loop::EventLoopWindowTarget<_>| {
|
||||||
return;
|
if event_loop.exiting() {
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
event_sender.start_send(event).expect("Send event");
|
event_sender.start_send(event).expect("Send event");
|
||||||
|
|
||||||
let poll = instance.as_mut().poll(&mut context);
|
let poll = instance.as_mut().poll(&mut context);
|
||||||
|
|
||||||
match poll {
|
match poll {
|
||||||
task::Poll::Pending => {
|
task::Poll::Pending => {
|
||||||
if let Ok(Some(flow)) = control_receiver.try_next() {
|
if let Ok(Some(flow)) = control_receiver.try_next() {
|
||||||
event_loop.set_control_flow(flow);
|
event_loop.set_control_flow(flow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
task::Poll::Ready(_) => {
|
||||||
|
event_loop.exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
task::Poll::Ready(_) => {
|
|
||||||
event_loop.exit();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
});
|
|
||||||
|
#[cfg(not(target_os = "windows"))]
|
||||||
|
let _ = event_loop.run(process_event);
|
||||||
|
|
||||||
|
// TODO: Remove when unnecessary
|
||||||
|
// On Windows, we emulate an `AboutToWait` event after every `Resized` event
|
||||||
|
// since the event loop does not resume during resize interaction.
|
||||||
|
// More details: https://github.com/rust-windowing/winit/issues/3272
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
{
|
||||||
|
let mut process_event = process_event;
|
||||||
|
|
||||||
|
let _ = event_loop.run(move |event, event_loop| {
|
||||||
|
if matches!(
|
||||||
|
event,
|
||||||
|
winit::event::Event::WindowEvent {
|
||||||
|
event: winit::event::WindowEvent::Resized(_),
|
||||||
|
..
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
process_event(event, event_loop);
|
||||||
|
process_event(winit::event::Event::AboutToWait, event_loop);
|
||||||
|
} else {
|
||||||
|
process_event(event, event_loop);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue