Merge pull request #2242 from dtzxporter/workaround-windows-issue-pt2

Implement win32 workaround for multi_window application as well. Also trigger AboutToWait for Moved as well.
This commit is contained in:
Héctor Ramón 2024-02-13 04:43:21 +01:00 committed by GitHub
commit 7a1e105036
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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(())
}