summaryrefslogtreecommitdiffstats
path: root/winit/src/window.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--runtime/src/window.rs (renamed from winit/src/window.rs)28
1 files changed, 24 insertions, 4 deletions
diff --git a/winit/src/window.rs b/runtime/src/window.rs
index 6ac58e20..236064f7 100644
--- a/winit/src/window.rs
+++ b/runtime/src/window.rs
@@ -1,7 +1,27 @@
-//! Interact with the window of your application.
-use crate::core::window::{Mode, UserAttention};
-use crate::native::command::{self, Command};
-use crate::native::window::Action;
+//! Build window-based GUI applications.
+mod action;
+
+pub use action::Action;
+
+use crate::command::{self, Command};
+use crate::core::time::Instant;
+use crate::core::window::{Event, Mode, UserAttention};
+use crate::futures::subscription::{self, Subscription};
+
+/// Subscribes to the frames of the window of the running application.
+///
+/// The resulting [`Subscription`] will produce items at a rate equal to the
+/// refresh rate of the window. Note that this rate may be variable, as it is
+/// normally managed by the graphics driver and/or the OS.
+///
+/// In any case, this [`Subscription`] is useful to smoothly draw application-driven
+/// animations without missing any frames.
+pub fn frames() -> Subscription<Instant> {
+ subscription::raw_events(|event, _status| match event {
+ iced_core::Event::Window(Event::RedrawRequested(at)) => Some(at),
+ _ => None,
+ })
+}
/// Closes the current window and exits the application.
pub fn close<Message>() -> Command<Message> {