From 0b86c4a299d384cafca31206eac8c94f1123518d Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 12 Jan 2023 04:35:41 +0100 Subject: Implement `window::frames` subscription ... and use it in the `solar_system` example :tada: --- native/src/window.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'native/src/window.rs') diff --git a/native/src/window.rs b/native/src/window.rs index 1b97e655..4bccc471 100644 --- a/native/src/window.rs +++ b/native/src/window.rs @@ -8,3 +8,18 @@ pub use action::Action; pub use event::Event; pub use mode::Mode; pub use user_attention::UserAttention; + +use crate::subscription::{self, Subscription}; + +use std::time::Instant; + +/// Subscribes to the frames of the window of the running application. +/// +/// The resulting [`Subscription`] will produce items at a rate equal to the +/// framerate of the monitor of said window. +pub fn frames() -> Subscription { + subscription::raw_events(|event, _status| match event { + crate::Event::Window(Event::RedrawRequested(at)) => Some(at), + _ => None, + }) +} -- cgit