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);
|
static COUNT: AtomicU64 = AtomicU64::new(1);
|
||||||
|
|
||||||
impl Id {
|
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`].
|
/// Creates a new unique window [`Id`].
|
||||||
pub fn unique() -> Id {
|
pub fn unique() -> Id {
|
||||||
Id(COUNT.fetch_add(1, atomic::Ordering::Relaxed))
|
Id(COUNT.fetch_add(1, atomic::Ordering::Relaxed))
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ impl Events {
|
||||||
}
|
}
|
||||||
Message::EventOccurred(event) => {
|
Message::EventOccurred(event) => {
|
||||||
if let Event::Window(window::Event::CloseRequested) = event {
|
if let Event::Window(window::Event::CloseRequested) = event {
|
||||||
window::close(window::Id::MAIN)
|
window::get_latest().and_then(window::close)
|
||||||
} else {
|
} else {
|
||||||
Task::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
|
|
@ -48,7 +48,7 @@ impl Events {
|
||||||
|
|
||||||
Task::none()
|
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 {
|
impl Exit {
|
||||||
fn update(&mut self, message: Message) -> Task<Message> {
|
fn update(&mut self, message: Message) -> Task<Message> {
|
||||||
match message {
|
match message {
|
||||||
Message::Confirm => window::close(window::Id::MAIN),
|
Message::Confirm => window::get_latest().and_then(window::close),
|
||||||
Message::Exit => {
|
Message::Exit => {
|
||||||
self.show_confirm = true;
|
self.show_confirm = true;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ impl Example {
|
||||||
return Task::none();
|
return Task::none();
|
||||||
};
|
};
|
||||||
|
|
||||||
window::fetch_position(*last_window)
|
window::get_position(*last_window)
|
||||||
.then(|last_position| {
|
.then(|last_position| {
|
||||||
let position = last_position.map_or(
|
let position = last_position.map_or(
|
||||||
window::Position::Default,
|
window::Position::Default,
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,8 @@ impl Example {
|
||||||
fn update(&mut self, message: Message) -> Task<Message> {
|
fn update(&mut self, message: Message) -> Task<Message> {
|
||||||
match message {
|
match message {
|
||||||
Message::Screenshot => {
|
Message::Screenshot => {
|
||||||
return iced::window::screenshot(window::Id::MAIN)
|
return window::get_latest()
|
||||||
|
.and_then(window::screenshot)
|
||||||
.map(Message::Screenshotted);
|
.map(Message::Screenshotted);
|
||||||
}
|
}
|
||||||
Message::Screenshotted(screenshot) => {
|
Message::Screenshotted(screenshot) => {
|
||||||
|
|
|
||||||
|
|
@ -149,9 +149,10 @@ impl Todos {
|
||||||
widget::focus_next()
|
widget::focus_next()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Message::ToggleFullscreen(mode) => {
|
Message::ToggleFullscreen(mode) => window::get_latest()
|
||||||
window::change_mode(window::Id::MAIN, mode)
|
.and_then(move |window| {
|
||||||
}
|
window::change_mode(window, mode)
|
||||||
|
}),
|
||||||
Message::Loaded(_) => Command::none(),
|
Message::Loaded(_) => Command::none(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue