summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/multi_window/src/main.rs11
-rw-r--r--runtime/src/window.rs11
-rw-r--r--winit/src/program.rs5
3 files changed, 17 insertions, 10 deletions
diff --git a/examples/multi_window/src/main.rs b/examples/multi_window/src/main.rs
index 3dcb58f5..ab09116e 100644
--- a/examples/multi_window/src/main.rs
+++ b/examples/multi_window/src/main.rs
@@ -40,12 +40,13 @@ enum Message {
impl Example {
fn new() -> (Self, Task<Message>) {
+ let (_id, open) = window::open(window::Settings::default());
+
(
Self {
windows: BTreeMap::new(),
},
- window::open(window::Settings::default())
- .map(Message::WindowOpened),
+ open.map(Message::WindowOpened),
)
}
@@ -74,10 +75,12 @@ impl Example {
},
);
- window::open(window::Settings {
+ let (_id, open) = window::open(window::Settings {
position,
..window::Settings::default()
- })
+ });
+
+ open
})
.map(Message::WindowOpened)
}
diff --git a/runtime/src/window.rs b/runtime/src/window.rs
index ee03f84f..cd27cdfe 100644
--- a/runtime/src/window.rs
+++ b/runtime/src/window.rs
@@ -218,12 +218,15 @@ pub fn close_requests() -> Subscription<Id> {
/// Opens a new window with the given [`Settings`]; producing the [`Id`]
/// of the new window on completion.
-pub fn open(settings: Settings) -> Task<Id> {
+pub fn open(settings: Settings) -> (Id, Task<Id>) {
let id = Id::unique();
- task::oneshot(|channel| {
- crate::Action::Window(Action::Open(id, settings, channel))
- })
+ (
+ id,
+ task::oneshot(|channel| {
+ crate::Action::Window(Action::Open(id, settings, channel))
+ }),
+ )
}
/// Closes the window with `id`.
diff --git a/winit/src/program.rs b/winit/src/program.rs
index 286fff77..7e7864b3 100644
--- a/winit/src/program.rs
+++ b/winit/src/program.rs
@@ -207,8 +207,9 @@ where
let task = if let Some(window_settings) = window_settings {
let mut task = Some(task);
- runtime::window::open(window_settings)
- .then(move |_| task.take().unwrap_or(Task::none()))
+ let (_id, open) = runtime::window::open(window_settings);
+
+ open.then(move |_| task.take().unwrap_or(Task::none()))
} else {
task
};