diff --git a/examples/child_window.rs b/examples/child_window.rs index 61f6539a68..284a6c8504 100644 --- a/examples/child_window.rs +++ b/examples/child_window.rs @@ -53,12 +53,12 @@ fn main() -> Result<(), impl std::error::Error> { println!("parent window: {parent_window:?})"); - event_loop.run(move |event: Event<()>, elwt| { + event_loop.run(move |event, event_loop| { if let Event::WindowEvent { event, window_id } = event { match event { WindowEvent::CloseRequested => { windows.clear(); - elwt.exit(); + event_loop.exit(); } WindowEvent::CursorEntered { device_id: _ } => { // On x11, println when the cursor entered in a window even if the child window is created @@ -75,7 +75,7 @@ fn main() -> Result<(), impl std::error::Error> { }, .. } => { - spawn_child_window(&parent_window, elwt, &mut windows); + spawn_child_window(&parent_window, event_loop, &mut windows); } WindowEvent::RedrawRequested => { if let Some(window) = windows.get(&window_id) { diff --git a/examples/control_flow.rs b/examples/control_flow.rs index 5032d0bffc..94ba2f943b 100644 --- a/examples/control_flow.rs +++ b/examples/control_flow.rs @@ -47,7 +47,7 @@ fn main() -> Result<(), impl std::error::Error> { let mut wait_cancelled = false; let mut close_requested = false; - event_loop.run(move |event, elwt| { + event_loop.run(move |event, event_loop| { use winit::event::StartCause; println!("{event:?}"); match event { @@ -104,22 +104,22 @@ fn main() -> Result<(), impl std::error::Error> { } match mode { - Mode::Wait => elwt.set_control_flow(ControlFlow::Wait), + Mode::Wait => event_loop.set_control_flow(ControlFlow::Wait), Mode::WaitUntil => { if !wait_cancelled { - elwt.set_control_flow(ControlFlow::WaitUntil( + event_loop.set_control_flow(ControlFlow::WaitUntil( time::Instant::now() + WAIT_TIME, )); } } Mode::Poll => { thread::sleep(POLL_SLEEP_TIME); - elwt.set_control_flow(ControlFlow::Poll); + event_loop.set_control_flow(ControlFlow::Poll); } }; if close_requested { - elwt.exit(); + event_loop.exit(); } } _ => (), diff --git a/examples/cursor.rs b/examples/cursor.rs index b2c80b89ce..e537006dff 100644 --- a/examples/cursor.rs +++ b/examples/cursor.rs @@ -19,7 +19,7 @@ fn main() -> Result<(), impl std::error::Error> { let mut cursor_idx = 0; - event_loop.run(move |event, elwt| { + event_loop.run(move |event, event_loop| { if let Event::WindowEvent { event, .. } = event { match event { WindowEvent::KeyboardInput { @@ -42,7 +42,7 @@ fn main() -> Result<(), impl std::error::Error> { fill::fill_window(&window); } WindowEvent::CloseRequested => { - elwt.exit(); + event_loop.exit(); } _ => (), } diff --git a/examples/cursor_grab.rs b/examples/cursor_grab.rs index 27f8edfe8d..2388cbcefb 100644 --- a/examples/cursor_grab.rs +++ b/examples/cursor_grab.rs @@ -22,9 +22,9 @@ fn main() -> Result<(), impl std::error::Error> { let mut modifiers = ModifiersState::default(); - event_loop.run(move |event, elwt| match event { + event_loop.run(move |event, event_loop| match event { Event::WindowEvent { event, .. } => match event { - WindowEvent::CloseRequested => elwt.exit(), + WindowEvent::CloseRequested => event_loop.exit(), WindowEvent::KeyboardInput { event: KeyEvent { @@ -36,7 +36,7 @@ fn main() -> Result<(), impl std::error::Error> { } => { let result = match key { Key::Named(NamedKey::Escape) => { - elwt.exit(); + event_loop.exit(); Ok(()) } Key::Character(ch) => match ch.to_lowercase().as_str() { diff --git a/examples/custom_cursors.rs b/examples/custom_cursors.rs index 68984bce65..6042343fa5 100644 --- a/examples/custom_cursors.rs +++ b/examples/custom_cursors.rs @@ -57,7 +57,7 @@ fn main() -> Result<(), impl std::error::Error> { decode_cursor(include_bytes!("data/cross2.png"), &event_loop), ]; - event_loop.run(move |event, _elwt| match event { + event_loop.run(move |event, _event_loop| match event { Event::WindowEvent { event, .. } => match event { WindowEvent::KeyboardInput { event: @@ -94,7 +94,7 @@ fn main() -> Result<(), impl std::error::Error> { 64, 64, ) - .build(_elwt), + .build(_event_loop), ); } #[cfg(wasm_platform)] @@ -114,11 +114,11 @@ fn main() -> Result<(), impl std::error::Error> { 64, 64, ) - .build(_elwt), + .build(_event_loop), ], ) .unwrap() - .build(_elwt), + .build(_event_loop), ); } _ => {} @@ -129,7 +129,7 @@ fn main() -> Result<(), impl std::error::Error> { } WindowEvent::CloseRequested => { #[cfg(not(wasm_platform))] - _elwt.exit(); + _event_loop.exit(); } _ => (), }, diff --git a/examples/custom_events.rs b/examples/custom_events.rs index 50501e6758..55a1348885 100644 --- a/examples/custom_events.rs +++ b/examples/custom_events.rs @@ -40,12 +40,12 @@ fn main() -> Result<(), impl std::error::Error> { } }); - event_loop.run(move |event, elwt| match event { + event_loop.run(move |event, event_loop| match event { Event::UserEvent(event) => println!("user event: {event:?}"), Event::WindowEvent { event: WindowEvent::CloseRequested, .. - } => elwt.exit(), + } => event_loop.exit(), Event::WindowEvent { event: WindowEvent::RedrawRequested, .. diff --git a/examples/drag_window.rs b/examples/drag_window.rs index 2d13ce431c..fc93a9bf3e 100644 --- a/examples/drag_window.rs +++ b/examples/drag_window.rs @@ -22,12 +22,12 @@ fn main() -> Result<(), impl std::error::Error> { let mut entered_id = window_2.id(); let mut cursor_location = None; - event_loop.run(move |event, elwt| match event { + event_loop.run(move |event, event_loop| match event { Event::NewEvents(StartCause::Init) => { eprintln!("Switch which window is to be dragged by pressing \"x\".") } Event::WindowEvent { event, window_id } => match event { - WindowEvent::CloseRequested => elwt.exit(), + WindowEvent::CloseRequested => event_loop.exit(), WindowEvent::CursorMoved { position, .. } => cursor_location = Some(position), WindowEvent::MouseInput { state, button, .. } => { let window = if (window_id == window_1.id() && switched) diff --git a/examples/focus.rs b/examples/focus.rs index 29d3c621db..3603a18341 100644 --- a/examples/focus.rs +++ b/examples/focus.rs @@ -27,7 +27,7 @@ fn main() -> Result<(), impl std::error::Error> { .unwrap(); let mut deadline = time::Instant::now() + time::Duration::from_secs(3); - event_loop.run(move |event, elwt| { + event_loop.run(move |event, event_loop| { match event { Event::NewEvents(StartCause::ResumeTimeReached { .. }) => { // Timeout reached; focus the window. @@ -36,7 +36,7 @@ fn main() -> Result<(), impl std::error::Error> { window.focus_window(); } Event::WindowEvent { event, window_id } if window_id == window.id() => match event { - WindowEvent::CloseRequested => elwt.exit(), + WindowEvent::CloseRequested => event_loop.exit(), WindowEvent::RedrawRequested => { // Notify the windowing system that we'll be presenting to the window. window.pre_present_notify(); @@ -51,6 +51,6 @@ fn main() -> Result<(), impl std::error::Error> { _ => (), } - elwt.set_control_flow(winit::event_loop::ControlFlow::WaitUntil(deadline)); + event_loop.set_control_flow(winit::event_loop::ControlFlow::WaitUntil(deadline)); }) } diff --git a/examples/fullscreen.rs b/examples/fullscreen.rs index b82ca07f1d..bd5e38c638 100644 --- a/examples/fullscreen.rs +++ b/examples/fullscreen.rs @@ -52,10 +52,10 @@ fn main() -> Result<(), impl std::error::Error> { println!("- I\tToggle mIn size limit"); println!("- A\tToggle mAx size limit"); - event_loop.run(move |event, elwt| { + event_loop.run(move |event, event_loop| { if let Event::WindowEvent { event, .. } = event { match event { - WindowEvent::CloseRequested => elwt.exit(), + WindowEvent::CloseRequested => event_loop.exit(), WindowEvent::KeyboardInput { event: KeyEvent { @@ -65,7 +65,7 @@ fn main() -> Result<(), impl std::error::Error> { }, .. } => match key { - Key::Named(NamedKey::Escape) => elwt.exit(), + Key::Named(NamedKey::Escape) => event_loop.exit(), // WARNING: Consider using `key_without_modifers()` if available on your platform. // See the `key_binding` example Key::Character(ch) => match ch.to_lowercase().as_str() { @@ -88,12 +88,14 @@ fn main() -> Result<(), impl std::error::Error> { } "s" => { monitor_index += 1; - if let Some(mon) = elwt.available_monitors().nth(monitor_index) { + if let Some(mon) = event_loop.available_monitors().nth(monitor_index) { monitor = mon; } else { monitor_index = 0; - monitor = - elwt.available_monitors().next().expect("no monitor found!"); + monitor = event_loop + .available_monitors() + .next() + .expect("no monitor found!"); } println!("Monitor: {:?}", monitor.name()); diff --git a/examples/handling_close.rs b/examples/handling_close.rs index fdc671d25d..63c2a92876 100644 --- a/examples/handling_close.rs +++ b/examples/handling_close.rs @@ -22,7 +22,7 @@ fn main() -> Result<(), impl std::error::Error> { let mut close_requested = false; - event_loop.run(move |event, elwt| { + event_loop.run(move |event, event_loop| { if let Event::WindowEvent { event, .. } = event { match event { WindowEvent::CloseRequested => { @@ -64,7 +64,7 @@ fn main() -> Result<(), impl std::error::Error> { // event loop (i.e. if it's a multi-window application), you need to // drop the window. That closes it, and results in `Destroyed` being // sent. - elwt.exit(); + event_loop.exit(); } } Key::Character("n") => { diff --git a/examples/ime.rs b/examples/ime.rs index 79c2416411..97ddf70e3f 100644 --- a/examples/ime.rs +++ b/examples/ime.rs @@ -39,10 +39,10 @@ fn main() -> Result<(), impl std::error::Error> { let mut cursor_position = PhysicalPosition::new(0.0, 0.0); let mut ime_pos = PhysicalPosition::new(0.0, 0.0); - event_loop.run(move |event, elwt| { + event_loop.run(move |event, event_loop| { if let Event::WindowEvent { event, .. } = event { match event { - WindowEvent::CloseRequested => elwt.exit(), + WindowEvent::CloseRequested => event_loop.exit(), WindowEvent::CursorMoved { position, .. } => { cursor_position = position; } diff --git a/examples/key_binding.rs b/examples/key_binding.rs index b640889708..c61d0a7f5f 100644 --- a/examples/key_binding.rs +++ b/examples/key_binding.rs @@ -31,10 +31,10 @@ fn main() -> Result<(), impl std::error::Error> { let mut modifiers = ModifiersState::default(); - event_loop.run(move |event, elwt| { + event_loop.run(move |event, event_loop| { if let Event::WindowEvent { event, .. } = event { match event { - WindowEvent::CloseRequested => elwt.exit(), + WindowEvent::CloseRequested => event_loop.exit(), WindowEvent::ModifiersChanged(new) => { modifiers = new.state(); } diff --git a/examples/mouse_wheel.rs b/examples/mouse_wheel.rs index cda0673a0e..9066c697e6 100644 --- a/examples/mouse_wheel.rs +++ b/examples/mouse_wheel.rs @@ -34,10 +34,10 @@ In both cases the example window should move like the content of a scroll area i In other words, the deltas indicate the direction in which to move the content (in this case the window)." ); - event_loop.run(move |event, elwt| { + event_loop.run(move |event, event_loop| { if let Event::WindowEvent { event, .. } = event { match event { - WindowEvent::CloseRequested => elwt.exit(), + WindowEvent::CloseRequested => event_loop.exit(), WindowEvent::MouseWheel { delta, .. } => match delta { winit::event::MouseScrollDelta::LineDelta(x, y) => { println!("mouse wheel Line Delta: ({x},{y})"); diff --git a/examples/multithreaded.rs b/examples/multithreaded.rs index 3bcf462ffe..73f11e4305 100644 --- a/examples/multithreaded.rs +++ b/examples/multithreaded.rs @@ -175,9 +175,9 @@ fn main() -> Result<(), impl std::error::Error> { } }); } - event_loop.run(move |event, elwt| { + event_loop.run(move |event, event_loop| { if window_senders.is_empty() { - elwt.exit() + event_loop.exit() } match event { Event::WindowEvent { event, window_id } => match event { diff --git a/examples/multiwindow.rs b/examples/multiwindow.rs index 07a9b84eef..4e3cfeb3fa 100644 --- a/examples/multiwindow.rs +++ b/examples/multiwindow.rs @@ -26,7 +26,7 @@ fn main() -> Result<(), impl std::error::Error> { println!("Press N to open a new window."); - event_loop.run(move |event, elwt| { + event_loop.run(move |event, event_loop| { if let Event::WindowEvent { event, window_id } = event { match event { WindowEvent::CloseRequested => { @@ -36,7 +36,7 @@ fn main() -> Result<(), impl std::error::Error> { windows.remove(&window_id); if windows.is_empty() { - elwt.exit(); + event_loop.exit(); } } WindowEvent::KeyboardInput { @@ -44,9 +44,9 @@ fn main() -> Result<(), impl std::error::Error> { is_synthetic: false, .. } if event.state == ElementState::Pressed => match event.logical_key { - Key::Named(NamedKey::Escape) => elwt.exit(), + Key::Named(NamedKey::Escape) => event_loop.exit(), Key::Character(c) if c == "n" || c == "N" => { - let window = Window::new(elwt).unwrap(); + let window = Window::new(event_loop).unwrap(); println!("Opened a new window: {:?}", window.id()); windows.insert(window.id(), window); } diff --git a/examples/request_redraw.rs b/examples/request_redraw.rs index a058bd6019..01b1e66f83 100644 --- a/examples/request_redraw.rs +++ b/examples/request_redraw.rs @@ -19,12 +19,12 @@ fn main() -> Result<(), impl std::error::Error> { .build(&event_loop) .unwrap(); - event_loop.run(move |event, elwt| { + event_loop.run(move |event, event_loop| { println!("{event:?}"); if let Event::WindowEvent { event, .. } = event { match event { - WindowEvent::CloseRequested => elwt.exit(), + WindowEvent::CloseRequested => event_loop.exit(), WindowEvent::MouseInput { state: ElementState::Released, .. diff --git a/examples/request_redraw_threaded.rs b/examples/request_redraw_threaded.rs index 6070c2ae0e..b704b901bc 100644 --- a/examples/request_redraw_threaded.rs +++ b/examples/request_redraw_threaded.rs @@ -33,14 +33,14 @@ fn main() -> Result<(), impl std::error::Error> { } }); - event_loop.run(move |event, elwt| { + event_loop.run(move |event, event_loop| { println!("{event:?}"); match event { Event::WindowEvent { event: WindowEvent::CloseRequested, .. - } => elwt.exit(), + } => event_loop.exit(), Event::WindowEvent { event: WindowEvent::RedrawRequested, .. diff --git a/examples/resizable.rs b/examples/resizable.rs index 134c34388d..fd288697d6 100644 --- a/examples/resizable.rs +++ b/examples/resizable.rs @@ -27,10 +27,10 @@ fn main() -> Result<(), impl std::error::Error> { .build(&event_loop) .unwrap(); - event_loop.run(move |event, elwt| { + event_loop.run(move |event, event_loop| { if let Event::WindowEvent { event, .. } = event { match event { - WindowEvent::CloseRequested => elwt.exit(), + WindowEvent::CloseRequested => event_loop.exit(), WindowEvent::KeyboardInput { event: KeyEvent { diff --git a/examples/startup_notification.rs b/examples/startup_notification.rs index 0cbf4d3652..1f3a1006ed 100644 --- a/examples/startup_notification.rs +++ b/examples/startup_notification.rs @@ -31,7 +31,7 @@ mod example { let mut counter = 0; let mut create_first_window = false; - event_loop.run(move |event, elwt| { + event_loop.run(move |event, event_loop| { match event { Event::Resumed => create_first_window = true, @@ -60,7 +60,7 @@ mod example { // Remove the window from the map. windows.remove(&window_id); if windows.is_empty() { - elwt.exit(); + event_loop.exit(); return; } } @@ -92,7 +92,7 @@ mod example { builder = builder.with_activation_token(token); } - Rc::new(builder.build(elwt).unwrap()) + Rc::new(builder.build(event_loop).unwrap()) }; // Add the window to the map. diff --git a/examples/theme.rs b/examples/theme.rs index 6b7f8a4f11..3775161801 100644 --- a/examples/theme.rs +++ b/examples/theme.rs @@ -27,10 +27,10 @@ fn main() -> Result<(), impl std::error::Error> { println!(" (L) Light theme"); println!(" (D) Dark theme"); - event_loop.run(move |event, elwt| { + event_loop.run(move |event, event_loop| { if let Event::WindowEvent { window_id, event } = event { match event { - WindowEvent::CloseRequested => elwt.exit(), + WindowEvent::CloseRequested => event_loop.exit(), WindowEvent::ThemeChanged(theme) if window_id == window.id() => { println!("Theme is changed: {theme:?}") } diff --git a/examples/timer.rs b/examples/timer.rs index 62c0eee4bb..bcc6c38063 100644 --- a/examples/timer.rs +++ b/examples/timer.rs @@ -27,21 +27,21 @@ fn main() -> Result<(), impl std::error::Error> { let timer_length = Duration::new(1, 0); - event_loop.run(move |event, elwt| { + event_loop.run(move |event, event_loop| { println!("{event:?}"); match event { Event::NewEvents(StartCause::Init) => { - elwt.set_control_flow(ControlFlow::WaitUntil(Instant::now() + timer_length)); + event_loop.set_control_flow(ControlFlow::WaitUntil(Instant::now() + timer_length)); } Event::NewEvents(StartCause::ResumeTimeReached { .. }) => { - elwt.set_control_flow(ControlFlow::WaitUntil(Instant::now() + timer_length)); + event_loop.set_control_flow(ControlFlow::WaitUntil(Instant::now() + timer_length)); println!("\nTimer\n"); } Event::WindowEvent { event: WindowEvent::CloseRequested, .. - } => elwt.exit(), + } => event_loop.exit(), Event::WindowEvent { event: WindowEvent::RedrawRequested, .. diff --git a/examples/touchpad_gestures.rs b/examples/touchpad_gestures.rs index 6d9015bf02..ca3732b025 100644 --- a/examples/touchpad_gestures.rs +++ b/examples/touchpad_gestures.rs @@ -19,10 +19,10 @@ fn main() -> Result<(), impl std::error::Error> { println!("Only supported on macOS at the moment."); - event_loop.run(move |event, elwt| { + event_loop.run(move |event, event_loop| { if let Event::WindowEvent { event, .. } = event { match event { - WindowEvent::CloseRequested => elwt.exit(), + WindowEvent::CloseRequested => event_loop.exit(), WindowEvent::TouchpadMagnify { delta, .. } => { if delta > 0.0 { println!("Zoomed in {delta}"); diff --git a/examples/transparent.rs b/examples/transparent.rs index ee149a87d0..15158c901b 100644 --- a/examples/transparent.rs +++ b/examples/transparent.rs @@ -22,12 +22,12 @@ fn main() -> Result<(), impl std::error::Error> { window.set_title("A fantastic window!"); - event_loop.run(move |event, elwt| { + event_loop.run(move |event, event_loop| { println!("{event:?}"); if let Event::WindowEvent { event, .. } = event { match event { - WindowEvent::CloseRequested => elwt.exit(), + WindowEvent::CloseRequested => event_loop.exit(), WindowEvent::RedrawRequested => { fill::fill_window(&window); } diff --git a/examples/web.rs b/examples/web.rs index febc903a38..5d44e358be 100644 --- a/examples/web.rs +++ b/examples/web.rs @@ -21,7 +21,7 @@ pub fn main() -> Result<(), impl std::error::Error> { #[cfg(wasm_platform)] let log_list = wasm::insert_canvas_and_create_log_list(&window); - event_loop.run(move |event, elwt| { + event_loop.run(move |event, event_loop| { #[cfg(wasm_platform)] wasm::log_event(&log_list, &event); @@ -29,7 +29,7 @@ pub fn main() -> Result<(), impl std::error::Error> { Event::WindowEvent { event: WindowEvent::CloseRequested, window_id, - } if window_id == window.id() => elwt.exit(), + } if window_id == window.id() => event_loop.exit(), Event::AboutToWait => { window.request_redraw(); } diff --git a/examples/window.rs b/examples/window.rs index 488aa38af0..8ff79fc1df 100644 --- a/examples/window.rs +++ b/examples/window.rs @@ -20,12 +20,12 @@ fn main() -> Result<(), impl std::error::Error> { .build(&event_loop) .unwrap(); - event_loop.run(move |event, elwt| { + event_loop.run(move |event, event_loop| { println!("{event:?}"); match event { Event::WindowEvent { event, window_id } if window_id == window.id() => match event { - WindowEvent::CloseRequested => elwt.exit(), + WindowEvent::CloseRequested => event_loop.exit(), WindowEvent::RedrawRequested => { // Notify the windowing system that we'll be presenting to the window. window.pre_present_notify(); diff --git a/examples/window_buttons.rs b/examples/window_buttons.rs index d5b8a5be98..38e56154a8 100644 --- a/examples/window_buttons.rs +++ b/examples/window_buttons.rs @@ -31,7 +31,7 @@ fn main() -> Result<(), impl std::error::Error> { event_loop.listen_device_events(DeviceEvents::Always); - event_loop.run(move |event, elwt| { + event_loop.run(move |event, event_loop| { if let Event::WindowEvent { window_id, event } = event { match event { WindowEvent::KeyboardInput { @@ -57,7 +57,7 @@ fn main() -> Result<(), impl std::error::Error> { } _ => (), }, - WindowEvent::CloseRequested if window_id == window.id() => elwt.exit(), + WindowEvent::CloseRequested if window_id == window.id() => event_loop.exit(), WindowEvent::RedrawRequested => { fill::fill_window(&window); } diff --git a/examples/window_debug.rs b/examples/window_debug.rs index c6bf5b9053..fc59a03bfc 100644 --- a/examples/window_debug.rs +++ b/examples/window_debug.rs @@ -38,7 +38,7 @@ fn main() -> Result<(), impl std::error::Error> { event_loop.listen_device_events(DeviceEvents::Always); - event_loop.run(move |event, elwt| { + event_loop.run(move |event, event_loop| { match event { // This used to use the virtual key, but the new API // only provides the `physical_key` (`Code`). @@ -113,7 +113,7 @@ fn main() -> Result<(), impl std::error::Error> { window.set_minimized(minimized); } "q" => { - elwt.exit(); + event_loop.exit(); } "v" => { visible = !visible; @@ -125,7 +125,7 @@ fn main() -> Result<(), impl std::error::Error> { } _ => (), }, - WindowEvent::CloseRequested if window_id == window.id() => elwt.exit(), + WindowEvent::CloseRequested if window_id == window.id() => event_loop.exit(), WindowEvent::RedrawRequested => { fill::fill_window(&window); } diff --git a/examples/window_drag_resize.rs b/examples/window_drag_resize.rs index 8db9fa543a..d70d7555c2 100644 --- a/examples/window_drag_resize.rs +++ b/examples/window_drag_resize.rs @@ -27,12 +27,12 @@ fn main() -> Result<(), impl std::error::Error> { let mut border = false; let mut cursor_location = None; - event_loop.run(move |event, elwt| match event { + event_loop.run(move |event, event_loop| match event { Event::NewEvents(StartCause::Init) => { eprintln!("Press 'B' to toggle borderless") } Event::WindowEvent { event, .. } => match event { - WindowEvent::CloseRequested => elwt.exit(), + WindowEvent::CloseRequested => event_loop.exit(), WindowEvent::CursorMoved { position, .. } => { if !window.is_decorated() { let new_location = diff --git a/examples/window_icon.rs b/examples/window_icon.rs index 0f19780106..08fa6e333b 100644 --- a/examples/window_icon.rs +++ b/examples/window_icon.rs @@ -33,10 +33,10 @@ fn main() -> Result<(), impl std::error::Error> { .build(&event_loop) .unwrap(); - event_loop.run(move |event, elwt| { + event_loop.run(move |event, event_loop| { if let Event::WindowEvent { event, .. } = event { match event { - WindowEvent::CloseRequested => elwt.exit(), + WindowEvent::CloseRequested => event_loop.exit(), WindowEvent::DroppedFile(path) => { window.set_window_icon(Some(load_icon(&path))); } diff --git a/examples/window_on_demand.rs b/examples/window_on_demand.rs index bb00416da5..f37752aeb2 100644 --- a/examples/window_on_demand.rs +++ b/examples/window_on_demand.rs @@ -30,7 +30,7 @@ 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_on_demand(move |event, elwt| { + event_loop.run_on_demand(move |event, event_loop| { 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; - elwt.exit(); + event_loop.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(elwt) + .build(event_loop) .unwrap(); app.window_id = Some(window.id()); app.window = Some(window); diff --git a/examples/window_option_as_alt.rs b/examples/window_option_as_alt.rs index 28fb93bd99..90c9bbf6e4 100644 --- a/examples/window_option_as_alt.rs +++ b/examples/window_option_as_alt.rs @@ -31,11 +31,11 @@ fn main() -> Result<(), impl std::error::Error> { let mut option_as_alt = window.option_as_alt(); - event_loop.run(move |event, elwt| match event { + event_loop.run(move |event, event_loop| match event { Event::WindowEvent { event: WindowEvent::CloseRequested, window_id, - } if window_id == window.id() => elwt.exit(), + } if window_id == window.id() => event_loop.exit(), Event::WindowEvent { event, .. } => match event { WindowEvent::MouseInput { state: ElementState::Pressed, diff --git a/examples/window_pump_events.rs b/examples/window_pump_events.rs index 040ad7f001..0a73e107b3 100644 --- a/examples/window_pump_events.rs +++ b/examples/window_pump_events.rs @@ -32,7 +32,7 @@ fn main() -> std::process::ExitCode { 'main: loop { let timeout = Some(Duration::ZERO); - let status = event_loop.pump_events(timeout, |event, elwt| { + let status = event_loop.pump_events(timeout, |event, event_loop| { if let Event::WindowEvent { event, .. } = &event { // Print only Window events to reduce noise println!("{event:?}"); @@ -42,7 +42,7 @@ fn main() -> std::process::ExitCode { Event::WindowEvent { event: WindowEvent::CloseRequested, window_id, - } if window_id == window.id() => elwt.exit(), + } if window_id == window.id() => event_loop.exit(), Event::AboutToWait => { window.request_redraw(); } diff --git a/examples/window_resize_increments.rs b/examples/window_resize_increments.rs index 834050585a..702fb057eb 100644 --- a/examples/window_resize_increments.rs +++ b/examples/window_resize_increments.rs @@ -24,9 +24,9 @@ fn main() -> Result<(), impl std::error::Error> { let mut has_increments = true; - event_loop.run(move |event, elwt| match event { + event_loop.run(move |event, event_loop| match event { Event::WindowEvent { event, window_id } if window_id == window.id() => match event { - WindowEvent::CloseRequested => elwt.exit(), + WindowEvent::CloseRequested => event_loop.exit(), WindowEvent::KeyboardInput { event, .. } if event.logical_key == NamedKey::Space && event.state == ElementState::Released => diff --git a/examples/window_tabbing.rs b/examples/window_tabbing.rs index 9413ae9a39..eaddc82f03 100644 --- a/examples/window_tabbing.rs +++ b/examples/window_tabbing.rs @@ -30,7 +30,7 @@ fn main() -> Result<(), impl std::error::Error> { println!("Press N to open a new window."); - event_loop.run(move |event, elwt| { + event_loop.run(move |event, event_loop| { if let Event::WindowEvent { event, window_id } = event { match event { WindowEvent::CloseRequested => { @@ -40,7 +40,7 @@ fn main() -> Result<(), impl std::error::Error> { windows.remove(&window_id); if windows.is_empty() { - elwt.exit(); + event_loop.exit(); } } WindowEvent::Resized(_) => { @@ -62,7 +62,7 @@ fn main() -> Result<(), impl std::error::Error> { let tabbing_id = windows.get(&window_id).unwrap().tabbing_identifier(); let window = WindowBuilder::new() .with_tabbing_identifier(&tabbing_id) - .build(elwt) + .build(event_loop) .unwrap(); println!("Added a new tab: {:?}", window.id()); windows.insert(window.id(), window); diff --git a/examples/x11_embed.rs b/examples/x11_embed.rs index e66482eba3..4b80b0f2f5 100644 --- a/examples/x11_embed.rs +++ b/examples/x11_embed.rs @@ -32,12 +32,12 @@ mod imple { .build(&event_loop) .unwrap(); - event_loop.run(move |event, elwt| { + event_loop.run(move |event, event_loop| { match event { Event::WindowEvent { event: WindowEvent::CloseRequested, window_id, - } if window_id == window.id() => elwt.exit(), + } if window_id == window.id() => event_loop.exit(), Event::AboutToWait => { window.request_redraw(); } diff --git a/src/event.rs b/src/event.rs index 66871835dc..8da4584876 100644 --- a/src/event.rs +++ b/src/event.rs @@ -9,22 +9,22 @@ //! ```rust,ignore //! let mut start_cause = StartCause::Init; //! -//! while !elwt.exiting() { -//! event_handler(NewEvents(start_cause), elwt); +//! while !event_loop.exiting() { +//! event_handler(NewEvents(start_cause), event_loop); //! //! for e in (window events, user events, device events) { -//! event_handler(e, elwt); +//! event_handler(e, event_loop); //! } //! //! for w in (redraw windows) { -//! event_handler(RedrawRequested(w), elwt); +//! event_handler(RedrawRequested(w), event_loop); //! } //! -//! event_handler(AboutToWait, elwt); +//! event_handler(AboutToWait, event_loop); //! start_cause = wait_if_necessary(); //! } //! -//! event_handler(LoopExiting, elwt); +//! event_handler(LoopExiting, event_loop); //! ``` //! //! This leaves out timing details like [`ControlFlow::WaitUntil`] but hopefully diff --git a/src/lib.rs b/src/lib.rs index ecd965f875..e14607a919 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -78,14 +78,14 @@ //! // input, and uses significantly less power/CPU time than ControlFlow::Poll. //! event_loop.set_control_flow(ControlFlow::Wait); //! -//! event_loop.run(move |event, elwt| { +//! event_loop.run(move |event, event_loop| { //! match event { //! Event::WindowEvent { //! event: WindowEvent::CloseRequested, //! .. //! } => { //! println!("The close button was pressed; stopping"); -//! elwt.exit(); +//! event_loop.exit(); //! }, //! Event::AboutToWait => { //! // Application update code. diff --git a/src/platform/pump_events.rs b/src/platform/pump_events.rs index 994c70750d..5b6ace11a2 100644 --- a/src/platform/pump_events.rs +++ b/src/platform/pump_events.rs @@ -63,7 +63,7 @@ pub trait EventLoopExtPumpEvents { /// /// 'main: loop { /// let timeout = Some(Duration::ZERO); - /// let status = event_loop.pump_events(timeout, |event, elwt| { + /// let status = event_loop.pump_events(timeout, |event, event_loop| { /// # if let Event::WindowEvent { event, .. } = &event { /// # // Print only Window events to reduce noise /// # println!("{event:?}"); @@ -73,7 +73,7 @@ pub trait EventLoopExtPumpEvents { /// Event::WindowEvent { /// event: WindowEvent::CloseRequested, /// window_id, - /// } if window_id == window.id() => elwt.exit(), + /// } if window_id == window.id() => event_loop.exit(), /// Event::AboutToWait => { /// window.request_redraw(); /// } diff --git a/src/window.rs b/src/window.rs index f4d3c1e1c3..57044bf69f 100644 --- a/src/window.rs +++ b/src/window.rs @@ -44,12 +44,12 @@ use serde::{Deserialize, Serialize}; /// event_loop.set_control_flow(ControlFlow::Wait); /// let window = Window::new(&event_loop).unwrap(); /// -/// event_loop.run(move |event, elwt| { +/// event_loop.run(move |event, event_loop| { /// match event { /// Event::WindowEvent { /// event: WindowEvent::CloseRequested, /// .. -/// } => elwt.exit(), +/// } => event_loop.exit(), /// _ => (), /// } /// });