Skip to content

Commit

Permalink
fix(window-state): manual default implentation, closes #421
Browse files Browse the repository at this point in the history
  • Loading branch information
amrbashir committed Jun 7, 2023
1 parent b3d7d11 commit a60b97a
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion plugins/window-state/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl Default for StateFlags {
}
}

#[derive(Debug, Default, Deserialize, Serialize, PartialEq)]
#[derive(Debug, Deserialize, Serialize, PartialEq)]
struct WindowState {
width: f64,
height: f64,
Expand All @@ -65,6 +65,21 @@ struct WindowState {
fullscreen: bool,
}

impl Default for WindowState {
fn default() -> Self {
Self {
width: Default::default(),
height: Default::default(),
x: Default::default(),
y: Default::default(),
maximized: Default::default(),
visible: true,
decorated: true,
fullscreen: Default::default(),
}
}
}

struct WindowStateCache(Arc<Mutex<HashMap<String, WindowState>>>);
pub trait AppHandleExt {
/// Saves all open windows state to disk
Expand Down Expand Up @@ -110,7 +125,9 @@ impl<R: Runtime> WindowExt for Window<R> {

if let Some(state) = c.get(self.label()) {
// avoid restoring the default zeroed state
dbg!(&*state);
if *state == WindowState::default() {
dbg!("asdasd");
return Ok(());
}

Expand Down

0 comments on commit a60b97a

Please sign in to comment.