summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/src/window.rs32
1 files changed, 27 insertions, 5 deletions
diff --git a/runtime/src/window.rs b/runtime/src/window.rs
index 2ba3e796..956a20e1 100644
--- a/runtime/src/window.rs
+++ b/runtime/src/window.rs
@@ -155,10 +155,21 @@ pub fn frames() -> Subscription<Instant> {
})
}
-/// Subscribes to all window close requests of the running application.
-pub fn close_requests() -> Subscription<Id> {
+/// Subscribes to all window events of the running application.
+pub fn events() -> Subscription<(Id, Event)> {
event::listen_with(|event, _status, id| {
- if let crate::core::Event::Window(Event::CloseRequested) = event {
+ if let crate::core::Event::Window(event) = event {
+ Some((id, event))
+ } else {
+ None
+ }
+ })
+}
+
+/// Subscribes to all [`Event::Closed`] occurrences in the running application.
+pub fn open_events() -> Subscription<Id> {
+ event::listen_with(|event, _status, id| {
+ if let crate::core::Event::Window(Event::Closed) = event {
Some(id)
} else {
None
@@ -166,8 +177,8 @@ pub fn close_requests() -> Subscription<Id> {
})
}
-/// Subscribes to all window closings of the running application.
-pub fn closings() -> Subscription<Id> {
+/// Subscribes to all [`Event::Closed`] occurrences in the running application.
+pub fn close_events() -> Subscription<Id> {
event::listen_with(|event, _status, id| {
if let crate::core::Event::Window(Event::Closed) = event {
Some(id)
@@ -177,6 +188,17 @@ pub fn closings() -> Subscription<Id> {
})
}
+/// Subscribes to all [`Event::CloseRequested`] occurences in the running application.
+pub fn close_requests() -> Subscription<Id> {
+ event::listen_with(|event, _status, id| {
+ if let crate::core::Event::Window(Event::CloseRequested) = event {
+ Some(id)
+ } else {
+ None
+ }
+ })
+}
+
/// Opens a new window with the given [`Settings`]; producing the [`Id`]
/// of the new window on completion.
pub fn open(settings: Settings) -> Task<Id> {