Remove window::Id::MAIN constant
This commit is contained in:
parent
92e08c8f07
commit
c5f4bebeda
6 changed files with 10 additions and 11 deletions
|
|
@ -11,9 +11,6 @@ pub struct Id(u64);
|
|||
static COUNT: AtomicU64 = AtomicU64::new(1);
|
||||
|
||||
impl Id {
|
||||
/// The reserved window [`Id`] for the first window in an Iced application.
|
||||
pub const MAIN: Self = Id(0);
|
||||
|
||||
/// Creates a new unique window [`Id`].
|
||||
pub fn unique() -> Id {
|
||||
Id(COUNT.fetch_add(1, atomic::Ordering::Relaxed))
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ impl Events {
|
|||
}
|
||||
Message::EventOccurred(event) => {
|
||||
if let Event::Window(window::Event::CloseRequested) = event {
|
||||
window::close(window::Id::MAIN)
|
||||
window::get_latest().and_then(window::close)
|
||||
} else {
|
||||
Task::none()
|
||||
}
|
||||
|
|
@ -48,7 +48,7 @@ impl Events {
|
|||
|
||||
Task::none()
|
||||
}
|
||||
Message::Exit => window::close(window::Id::MAIN),
|
||||
Message::Exit => window::get_latest().and_then(window::close),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ enum Message {
|
|||
impl Exit {
|
||||
fn update(&mut self, message: Message) -> Task<Message> {
|
||||
match message {
|
||||
Message::Confirm => window::close(window::Id::MAIN),
|
||||
Message::Confirm => window::get_latest().and_then(window::close),
|
||||
Message::Exit => {
|
||||
self.show_confirm = true;
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ impl Example {
|
|||
return Task::none();
|
||||
};
|
||||
|
||||
window::fetch_position(*last_window)
|
||||
window::get_position(*last_window)
|
||||
.then(|last_position| {
|
||||
let position = last_position.map_or(
|
||||
window::Position::Default,
|
||||
|
|
|
|||
|
|
@ -47,7 +47,8 @@ impl Example {
|
|||
fn update(&mut self, message: Message) -> Task<Message> {
|
||||
match message {
|
||||
Message::Screenshot => {
|
||||
return iced::window::screenshot(window::Id::MAIN)
|
||||
return window::get_latest()
|
||||
.and_then(window::screenshot)
|
||||
.map(Message::Screenshotted);
|
||||
}
|
||||
Message::Screenshotted(screenshot) => {
|
||||
|
|
|
|||
|
|
@ -149,9 +149,10 @@ impl Todos {
|
|||
widget::focus_next()
|
||||
}
|
||||
}
|
||||
Message::ToggleFullscreen(mode) => {
|
||||
window::change_mode(window::Id::MAIN, mode)
|
||||
}
|
||||
Message::ToggleFullscreen(mode) => window::get_latest()
|
||||
.and_then(move |window| {
|
||||
window::change_mode(window, mode)
|
||||
}),
|
||||
Message::Loaded(_) => Command::none(),
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue