Implement win32 workaround for multi_window application as well. Also trigger AboutToWait for Moved as well.

This commit is contained in:
dtzxporter 2024-02-09 08:40:50 -05:00 committed by Héctor Ramón Jiménez
parent dc2cba9264
commit 3a80fece32
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
2 changed files with 32 additions and 3 deletions

View file

@ -250,7 +250,8 @@ where
if matches!(
event,
winit::event::Event::WindowEvent {
event: winit::event::WindowEvent::Resized(_),
event: winit::event::WindowEvent::Resized(_)
| winit::event::WindowEvent::Moved(_),
..
}
) {

View file

@ -211,7 +211,7 @@ where
let mut context = task::Context::from_waker(task::noop_waker_ref());
let _ = event_loop.run(move |event, event_loop| {
let process_event = move |event, event_loop: &winit::event_loop::EventLoopWindowTarget<_>| {
if event_loop.exiting() {
return;
}
@ -280,7 +280,35 @@ where
}
};
}
});
};
#[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(_)
| winit::event::WindowEvent::Moved(_),
..
}
) {
process_event(event, event_loop);
process_event(winit::event::Event::AboutToWait, event_loop);
} else {
process_event(event, event_loop);
}
});
}
Ok(())
}