Make window::open pure again
This commit is contained in:
parent
98d8f466bb
commit
1deb87694d
3 changed files with 12 additions and 19 deletions
|
|
@ -42,13 +42,12 @@ enum Message {
|
|||
|
||||
impl Example {
|
||||
fn new() -> (Self, Task<Message>) {
|
||||
let (_id, open) = window::open(window::Settings::default());
|
||||
|
||||
(
|
||||
Self {
|
||||
windows: BTreeMap::new(),
|
||||
},
|
||||
open.map(Message::WindowOpened),
|
||||
window::open(window::Settings::default())
|
||||
.map(Message::WindowOpened),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -77,12 +76,10 @@ impl Example {
|
|||
},
|
||||
);
|
||||
|
||||
let (_id, open) = window::open(window::Settings {
|
||||
window::open(window::Settings {
|
||||
position,
|
||||
..window::Settings::default()
|
||||
});
|
||||
|
||||
open
|
||||
})
|
||||
})
|
||||
.map(Message::WindowOpened)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ use raw_window_handle::WindowHandle;
|
|||
#[allow(missing_debug_implementations)]
|
||||
pub enum Action {
|
||||
/// Opens a new window with some [`Settings`].
|
||||
Open(Id, Settings, oneshot::Sender<Id>),
|
||||
Open(Settings, oneshot::Sender<Id>),
|
||||
|
||||
/// Close the window and exits the application.
|
||||
Close(Id),
|
||||
|
|
@ -249,15 +249,10 @@ 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) -> (Id, Task<Id>) {
|
||||
let id = Id::unique();
|
||||
|
||||
(
|
||||
id,
|
||||
task::oneshot(|channel| {
|
||||
crate::Action::Window(Action::Open(id, settings, channel))
|
||||
}),
|
||||
)
|
||||
pub fn open(settings: Settings) -> Task<Id> {
|
||||
task::oneshot(|channel| {
|
||||
crate::Action::Window(Action::Open(settings, channel))
|
||||
})
|
||||
}
|
||||
|
||||
/// Closes the window with `id`.
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ where
|
|||
let task = if let Some(window_settings) = window_settings {
|
||||
let mut task = Some(task);
|
||||
|
||||
let (_id, open) = runtime::window::open(window_settings);
|
||||
let open = runtime::window::open(window_settings);
|
||||
|
||||
open.then(move |_| task.take().unwrap_or(Task::none()))
|
||||
} else {
|
||||
|
|
@ -1121,7 +1121,8 @@ fn run_action<'a, P, C>(
|
|||
}
|
||||
},
|
||||
Action::Window(action) => match action {
|
||||
window::Action::Open(id, settings, channel) => {
|
||||
window::Action::Open(settings, channel) => {
|
||||
let id = core::window::Id::unique();
|
||||
let monitor = window_manager.last_monitor();
|
||||
|
||||
control_sender
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue