Keep window::open impure (for now)
This commit is contained in:
parent
d7aab6c4ec
commit
bf3ac04498
4 changed files with 21 additions and 14 deletions
|
|
@ -42,12 +42,13 @@ enum Message {
|
||||||
|
|
||||||
impl Example {
|
impl Example {
|
||||||
fn new() -> (Self, Task<Message>) {
|
fn new() -> (Self, Task<Message>) {
|
||||||
|
let (_, open) = window::open(window::Settings::default());
|
||||||
|
|
||||||
(
|
(
|
||||||
Self {
|
Self {
|
||||||
windows: BTreeMap::new(),
|
windows: BTreeMap::new(),
|
||||||
},
|
},
|
||||||
window::open(window::Settings::default())
|
open.map(Message::WindowOpened),
|
||||||
.map(Message::WindowOpened),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -76,10 +77,12 @@ impl Example {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
window::open(window::Settings {
|
let (_, open) = window::open(window::Settings {
|
||||||
position,
|
position,
|
||||||
..window::Settings::default()
|
..window::Settings::default()
|
||||||
})
|
});
|
||||||
|
|
||||||
|
open
|
||||||
})
|
})
|
||||||
.map(Message::WindowOpened)
|
.map(Message::WindowOpened)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ use raw_window_handle::WindowHandle;
|
||||||
#[allow(missing_debug_implementations)]
|
#[allow(missing_debug_implementations)]
|
||||||
pub enum Action {
|
pub enum Action {
|
||||||
/// Opens a new window with some [`Settings`].
|
/// Opens a new window with some [`Settings`].
|
||||||
Open(Settings, oneshot::Sender<Id>),
|
Open(Id, Settings, oneshot::Sender<Id>),
|
||||||
|
|
||||||
/// Close the window and exits the application.
|
/// Close the window and exits the application.
|
||||||
Close(Id),
|
Close(Id),
|
||||||
|
|
@ -249,10 +249,15 @@ pub fn close_requests() -> Subscription<Id> {
|
||||||
|
|
||||||
/// Opens a new window with the given [`Settings`]; producing the [`Id`]
|
/// Opens a new window with the given [`Settings`]; producing the [`Id`]
|
||||||
/// of the new window on completion.
|
/// of the new window on completion.
|
||||||
pub fn open(settings: Settings) -> Task<Id> {
|
pub fn open(settings: Settings) -> (Id, Task<Id>) {
|
||||||
task::oneshot(|channel| {
|
let id = Id::unique();
|
||||||
crate::Action::Window(Action::Open(settings, channel))
|
|
||||||
})
|
(
|
||||||
|
id,
|
||||||
|
task::oneshot(|channel| {
|
||||||
|
crate::Action::Window(Action::Open(id, settings, channel))
|
||||||
|
}),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Closes the window with `id`.
|
/// Closes the window with `id`.
|
||||||
|
|
|
||||||
|
|
@ -145,8 +145,8 @@ impl<P: Program + 'static> Emulator<P> {
|
||||||
dbg!(action);
|
dbg!(action);
|
||||||
}
|
}
|
||||||
Action::Window(action) => match action {
|
Action::Window(action) => match action {
|
||||||
window::Action::Open(_settings, sender) => {
|
window::Action::Open(id, _settings, sender) => {
|
||||||
self.window = core::window::Id::unique();
|
self.window = id;
|
||||||
|
|
||||||
let _ = sender.send(self.window);
|
let _ = sender.send(self.window);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,7 @@ where
|
||||||
let task = if let Some(window_settings) = window_settings {
|
let task = if let Some(window_settings) = window_settings {
|
||||||
let mut task = Some(task);
|
let mut task = Some(task);
|
||||||
|
|
||||||
let open = runtime::window::open(window_settings);
|
let (_id, open) = runtime::window::open(window_settings);
|
||||||
|
|
||||||
open.then(move |_| task.take().unwrap_or(Task::none()))
|
open.then(move |_| task.take().unwrap_or(Task::none()))
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1122,8 +1122,7 @@ fn run_action<'a, P, C>(
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Action::Window(action) => match action {
|
Action::Window(action) => match action {
|
||||||
window::Action::Open(settings, channel) => {
|
window::Action::Open(id, settings, channel) => {
|
||||||
let id = core::window::Id::unique();
|
|
||||||
let monitor = window_manager.last_monitor();
|
let monitor = window_manager.last_monitor();
|
||||||
|
|
||||||
control_sender
|
control_sender
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue