refactor: allow resetting main window id to None

This commit is contained in:
Ashley Wulber 2024-10-21 18:25:25 -04:00 committed by Jeremy Soller
parent 953685a882
commit 07763aca8e
4 changed files with 17 additions and 27 deletions

View file

@ -372,12 +372,14 @@ impl Core {
}
/// The [`Id`] of the main window
#[must_use]
pub fn main_window_id(&self) -> Option<window::Id> {
self.main_window.filter(|id| iced::window::Id::NONE != *id)
}
/// Reset the tracked main window to a new value
pub fn set_main_window_id(&mut self, id: window::Id) -> Option<window::Id> {
self.main_window.replace(id)
pub fn set_main_window_id(&mut self, mut id: Option<window::Id>) -> Option<window::Id> {
std::mem::swap(&mut self.main_window, &mut id);
id
}
}