Move ControlFlow to EventLoopWindowTarget

Fixes #3042.
This commit is contained in:
daxpedda 2023-09-07 08:25:04 +02:00 committed by GitHub
parent 8fdd81ecef
commit e648169861
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
60 changed files with 800 additions and 860 deletions

View file

@ -10,7 +10,7 @@ fn main() -> Result<(), impl std::error::Error> {
use winit::{
error::EventLoopError,
event::{Event, WindowEvent},
event_loop::EventLoop,
event_loop::{ControlFlow, EventLoop},
platform::run_ondemand::EventLoopExtRunOnDemand,
window::{Window, WindowBuilder, WindowId},
};
@ -30,8 +30,8 @@ fn main() -> Result<(), impl std::error::Error> {
fn run_app(event_loop: &mut EventLoop<()>, idx: usize) -> Result<(), EventLoopError> {
let mut app = App::default();
event_loop.run_ondemand(move |event, event_loop, control_flow| {
control_flow.set_wait();
event_loop.run_ondemand(move |event, elwt| {
elwt.set_control_flow(ControlFlow::Wait);
println!("Run {idx}: {:?}", event);
if let Some(window) = &app.window {
@ -60,7 +60,7 @@ fn main() -> Result<(), impl std::error::Error> {
} if id == window_id => {
println!("--------------------------------------------------------- Window {idx} Destroyed");
app.window_id = None;
control_flow.set_exit();
elwt.exit();
}
_ => (),
}
@ -68,7 +68,7 @@ fn main() -> Result<(), impl std::error::Error> {
let window = WindowBuilder::new()
.with_title("Fantastic window number one!")
.with_inner_size(winit::dpi::LogicalSize::new(128.0, 128.0))
.build(event_loop)
.build(elwt)
.unwrap();
app.window_id = Some(window.id());
app.window = Some(window);