Add timeout argument to pump_events

This renames all internal implementations of pump_events_with_timeout
to pump_events and makes them public.

Since all platforms that support pump_events support timeouts there's
no need to have a separate API.
This commit is contained in:
Robert Bragg 2023-07-24 00:37:51 +01:00 committed by Kirill Chibisov
parent e6c7cc297d
commit ae9b02e097
9 changed files with 23 additions and 68 deletions

View file

@ -14,7 +14,7 @@ fn main() -> std::process::ExitCode {
use simple_logger::SimpleLogger;
use winit::{
event::{Event, WindowEvent},
event_loop::EventLoop,
event_loop::{ControlFlow, EventLoop},
platform::pump_events::{EventLoopExtPumpEvents, PumpStatus},
window::WindowBuilder,
};
@ -31,7 +31,10 @@ fn main() -> std::process::ExitCode {
.unwrap();
'main: loop {
let status = event_loop.pump_events(|event, _, control_flow| {
let timeout = Some(Duration::ZERO);
let status = event_loop.pump_events(timeout, |event, _, control_flow| {
*control_flow = ControlFlow::Wait;
if let Event::WindowEvent { event, .. } = &event {
// Print only Window events to reduce noise
println!("{event:?}");