diff --git a/CHANGELOG.md b/CHANGELOG.md index 8807474a..92852662 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ And please only add new entries to the top of this list, right below the `# Unre # Unreleased +- Renamed `EventLoopExtRunOnDemand` / `run_ondemand` to `EventLoopExtRunOnDemand` / `run_on_demand`. - Make iOS `MonitorHandle` and `VideoMode` usable from other threads. - On Web, `ControlFlow::WaitUntil` now uses the Prioritized Task Scheduling API. `setTimeout()`, with a trick to circumvent throttling to 4ms, is used as a fallback. - On Web, never return a `MonitorHandle`. diff --git a/examples/window_ondemand.rs b/examples/window_on_demand.rs similarity index 96% rename from examples/window_ondemand.rs rename to examples/window_on_demand.rs index 4aeb4f11..ca9a448a 100644 --- a/examples/window_ondemand.rs +++ b/examples/window_on_demand.rs @@ -11,7 +11,7 @@ fn main() -> Result<(), impl std::error::Error> { error::EventLoopError, event::{Event, WindowEvent}, event_loop::EventLoop, - platform::run_ondemand::EventLoopExtRunOnDemand, + platform::run_on_demand::EventLoopExtRunOnDemand, window::{Window, WindowBuilder, WindowId}, }; @@ -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_ondemand(move |event, elwt| { + event_loop.run_on_demand(move |event, elwt| { println!("Run {idx}: {:?}", event); if let Some(window) = &app.window { diff --git a/src/platform/mod.rs b/src/platform/mod.rs index 40c2bce1..dbf1cbba 100644 --- a/src/platform/mod.rs +++ b/src/platform/mod.rs @@ -11,7 +11,7 @@ //! //! And the following platform-specific modules: //! -//! - `run_ondemand` (available on `windows`, `unix`, `macos`, `android`) +//! - `run_on_demand` (available on `windows`, `unix`, `macos`, `android`) //! - `pump_events` (available on `windows`, `unix`, `macos`, `android`) //! //! However only the module corresponding to the platform you're compiling to will be available. @@ -42,7 +42,7 @@ pub mod x11; x11_platform, wayland_platform ))] -pub mod run_ondemand; +pub mod run_on_demand; #[cfg(any( windows_platform, diff --git a/src/platform/run_ondemand.rs b/src/platform/run_on_demand.rs similarity index 91% rename from src/platform/run_ondemand.rs rename to src/platform/run_on_demand.rs index 6e1c0d6b..7443c2bd 100644 --- a/src/platform/run_ondemand.rs +++ b/src/platform/run_on_demand.rs @@ -28,7 +28,7 @@ pub trait EventLoopExtRunOnDemand { /// to while maintaining the full state of your application. (If you need something like this /// you can look at the [`EventLoopExtPumpEvents::pump_events()`] API) /// - /// Each time `run_ondemand` is called the `event_handler` can expect to receive a + /// Each time `run_on_demand` is called the `event_handler` can expect to receive a /// `NewEvents(Init)` and `Resumed` event (even on platforms that have no suspend/resume /// lifecycle) - which can be used to consistently initialize application state. /// @@ -59,7 +59,7 @@ pub trait EventLoopExtRunOnDemand { /// /// [`exit()`]: EventLoopWindowTarget::exit /// [`set_control_flow()`]: EventLoopWindowTarget::set_control_flow - fn run_ondemand(&mut self, event_handler: F) -> Result<(), EventLoopError> + fn run_on_demand(&mut self, event_handler: F) -> Result<(), EventLoopError> where F: FnMut(Event, &EventLoopWindowTarget); } @@ -67,10 +67,10 @@ pub trait EventLoopExtRunOnDemand { impl EventLoopExtRunOnDemand for EventLoop { type UserEvent = T; - fn run_ondemand(&mut self, event_handler: F) -> Result<(), EventLoopError> + fn run_on_demand(&mut self, event_handler: F) -> Result<(), EventLoopError> where F: FnMut(Event, &EventLoopWindowTarget), { - self.event_loop.run_ondemand(event_handler) + self.event_loop.run_on_demand(event_handler) } } diff --git a/src/platform_impl/android/mod.rs b/src/platform_impl/android/mod.rs index 2855e7ed..71b1d417 100644 --- a/src/platform_impl/android/mod.rs +++ b/src/platform_impl/android/mod.rs @@ -488,10 +488,10 @@ impl EventLoop { where F: FnMut(event::Event, &event_loop::EventLoopWindowTarget), { - self.run_ondemand(event_handler) + self.run_on_demand(event_handler) } - pub fn run_ondemand(&mut self, mut event_handler: F) -> Result<(), EventLoopError> + pub fn run_on_demand(&mut self, mut event_handler: F) -> Result<(), EventLoopError> where F: FnMut(event::Event, &event_loop::EventLoopWindowTarget), { diff --git a/src/platform_impl/linux/mod.rs b/src/platform_impl/linux/mod.rs index 0ecd6a0d..8983c9cf 100644 --- a/src/platform_impl/linux/mod.rs +++ b/src/platform_impl/linux/mod.rs @@ -774,14 +774,14 @@ impl EventLoop { where F: FnMut(crate::event::Event, &RootELW), { - self.run_ondemand(callback) + self.run_on_demand(callback) } - pub fn run_ondemand(&mut self, callback: F) -> Result<(), EventLoopError> + pub fn run_on_demand(&mut self, callback: F) -> Result<(), EventLoopError> where F: FnMut(crate::event::Event, &RootELW), { - x11_or_wayland!(match self; EventLoop(evlp) => evlp.run_ondemand(callback)) + x11_or_wayland!(match self; EventLoop(evlp) => evlp.run_on_demand(callback)) } pub fn pump_events(&mut self, timeout: Option, callback: F) -> PumpStatus diff --git a/src/platform_impl/linux/wayland/event_loop/mod.rs b/src/platform_impl/linux/wayland/event_loop/mod.rs index ceb8588e..b22f2ce5 100644 --- a/src/platform_impl/linux/wayland/event_loop/mod.rs +++ b/src/platform_impl/linux/wayland/event_loop/mod.rs @@ -40,7 +40,7 @@ type WaylandDispatcher = calloop::Dispatcher<'static, WaylandSource, /// The Wayland event loop. pub struct EventLoop { - /// Has `run` or `run_ondemand` been called or a call to `pump_events` that starts the loop + /// Has `run` or `run_on_demand` been called or a call to `pump_events` that starts the loop loop_running: bool, buffer_sink: EventSink, @@ -189,7 +189,7 @@ impl EventLoop { Ok(event_loop) } - pub fn run_ondemand(&mut self, mut event_handler: F) -> Result<(), EventLoopError> + pub fn run_on_demand(&mut self, mut event_handler: F) -> Result<(), EventLoopError> where F: FnMut(Event, &RootEventLoopWindowTarget), { @@ -212,7 +212,7 @@ impl EventLoop { }; // Applications aren't allowed to carry windows between separate - // `run_ondemand` calls but if they have only just dropped their + // `run_on_demand` calls but if they have only just dropped their // windows we need to make sure those last requests are sent to the // compositor. let _ = self.roundtrip().map_err(EventLoopError::Os); diff --git a/src/platform_impl/linux/x11/mod.rs b/src/platform_impl/linux/x11/mod.rs index 266d4b45..1f1da606 100644 --- a/src/platform_impl/linux/x11/mod.rs +++ b/src/platform_impl/linux/x11/mod.rs @@ -398,7 +398,7 @@ impl EventLoop { &self.target } - pub fn run_ondemand(&mut self, mut event_handler: F) -> Result<(), EventLoopError> + pub fn run_on_demand(&mut self, mut event_handler: F) -> Result<(), EventLoopError> where F: FnMut(Event, &RootELW), { @@ -421,7 +421,7 @@ impl EventLoop { }; // Applications aren't allowed to carry windows between separate - // `run_ondemand` calls but if they have only just dropped their + // `run_on_demand` calls but if they have only just dropped their // windows we need to make sure those last requests are sent to the // X Server. let wt = get_xtarget(&self.target); diff --git a/src/platform_impl/macos/app_state.rs b/src/platform_impl/macos/app_state.rs index bc9b04c1..046043d0 100644 --- a/src/platform_impl/macos/app_state.rs +++ b/src/platform_impl/macos/app_state.rs @@ -359,7 +359,7 @@ impl AppState { /// and can lead to undefined behaviour if the callback is not cleared before the end of /// its real lifetime. /// - /// All public APIs that take an event callback (`run`, `run_ondemand`, + /// All public APIs that take an event callback (`run`, `run_on_demand`, /// `pump_events`) _must_ pair a call to `set_callback` with /// a call to `clear_callback` before returning to avoid undefined behaviour. pub unsafe fn set_callback( diff --git a/src/platform_impl/macos/event_loop.rs b/src/platform_impl/macos/event_loop.rs index 422d5ca4..0fca45ad 100644 --- a/src/platform_impl/macos/event_loop.rs +++ b/src/platform_impl/macos/event_loop.rs @@ -231,14 +231,14 @@ impl EventLoop { where F: FnMut(Event, &RootWindowTarget), { - self.run_ondemand(callback) + self.run_on_demand(callback) } // NB: we don't base this on `pump_events` because for `MacOs` we can't support // `pump_events` elegantly (we just ask to run the loop for a "short" amount of // time and so a layered implementation would end up using a lot of CPU due to // redundant wake ups. - pub fn run_ondemand(&mut self, callback: F) -> Result<(), EventLoopError> + pub fn run_on_demand(&mut self, callback: F) -> Result<(), EventLoopError> where F: FnMut(Event, &RootWindowTarget), { diff --git a/src/platform_impl/windows/event_loop.rs b/src/platform_impl/windows/event_loop.rs index b74e53e2..a8ed8f2a 100644 --- a/src/platform_impl/windows/event_loop.rs +++ b/src/platform_impl/windows/event_loop.rs @@ -252,10 +252,10 @@ impl EventLoop { where F: FnMut(Event, &RootELW), { - self.run_ondemand(event_handler) + self.run_on_demand(event_handler) } - pub fn run_ondemand(&mut self, mut event_handler: F) -> Result<(), EventLoopError> + pub fn run_on_demand(&mut self, mut event_handler: F) -> Result<(), EventLoopError> where F: FnMut(Event, &RootELW), { diff --git a/src/platform_impl/windows/event_loop/runner.rs b/src/platform_impl/windows/event_loop/runner.rs index d4b935cf..00e60910 100644 --- a/src/platform_impl/windows/event_loop/runner.rs +++ b/src/platform_impl/windows/event_loop/runner.rs @@ -88,7 +88,7 @@ impl EventLoopRunner { /// outlive the EventLoopRunner) and can lead to undefined behaviour if /// the handler is not cleared before the end of real lifetime. /// - /// All public APIs that take an event handler (`run`, `run_ondemand`, + /// All public APIs that take an event handler (`run`, `run_on_demand`, /// `pump_events`) _must_ pair a call to `set_event_handler` with /// a call to `clear_event_handler` before returning to avoid /// undefined behaviour.