diff options
-rw-r--r-- | examples/events/src/main.rs | 6 | ||||
-rw-r--r-- | examples/exit/src/main.rs | 4 | ||||
-rw-r--r-- | runtime/src/window.rs | 6 | ||||
-rw-r--r-- | winit/src/program.rs | 3 |
4 files changed, 7 insertions, 12 deletions
diff --git a/examples/events/src/main.rs b/examples/events/src/main.rs index e432eb14..5bada9b5 100644 --- a/examples/events/src/main.rs +++ b/examples/events/src/main.rs @@ -37,7 +37,7 @@ impl Events { } Message::EventOccurred(event) => { if let Event::Window(window::Event::CloseRequested) = event { - window::get_latest().and_then(window::close).discard() + window::get_latest().and_then(window::close) } else { Task::none() } @@ -47,9 +47,7 @@ impl Events { Task::none() } - Message::Exit => { - window::get_latest().and_then(window::close).discard() - } + Message::Exit => window::get_latest().and_then(window::close), } } diff --git a/examples/exit/src/main.rs b/examples/exit/src/main.rs index d8334bcc..48b0864c 100644 --- a/examples/exit/src/main.rs +++ b/examples/exit/src/main.rs @@ -20,9 +20,7 @@ enum Message { impl Exit { fn update(&mut self, message: Message) -> Task<Message> { match message { - Message::Confirm => { - window::get_latest().and_then(window::close).discard() - } + Message::Confirm => window::get_latest().and_then(window::close), Message::Exit => { self.show_confirm = true; diff --git a/runtime/src/window.rs b/runtime/src/window.rs index 0d280f1f..cd27cdfe 100644 --- a/runtime/src/window.rs +++ b/runtime/src/window.rs @@ -24,7 +24,7 @@ pub enum Action { Open(Id, Settings, oneshot::Sender<Id>), /// Close the window and exits the application. - Close(Id, oneshot::Sender<Id>), + Close(Id), /// Gets the [`Id`] of the oldest window. GetOldest(oneshot::Sender<Option<Id>>), @@ -230,8 +230,8 @@ pub fn open(settings: Settings) -> (Id, Task<Id>) { } /// Closes the window with `id`. -pub fn close(id: Id) -> Task<Id> { - task::oneshot(|channel| crate::Action::Window(Action::Close(id, channel))) +pub fn close<T>(id: Id) -> Task<T> { + task::effect(crate::Action::Window(Action::Close(id))) } /// Gets the window [`Id`] of the oldest window. diff --git a/winit/src/program.rs b/winit/src/program.rs index 66f359f4..efe8a978 100644 --- a/winit/src/program.rs +++ b/winit/src/program.rs @@ -1211,10 +1211,9 @@ fn run_action<P, C>( *is_window_opening = true; } - window::Action::Close(id, channel) => { + window::Action::Close(id) => { let _ = window_manager.remove(id); let _ = ui_caches.remove(&id); - let _ = channel.send(id); events.push(( id, |