mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-10 11:13:48 +02:00
Update window state logic
This commit is contained in:
@@ -1951,22 +1951,17 @@ pub fn run() {
|
|||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Save window state on exit
|
||||||
match event {
|
match event {
|
||||||
RunEvent::WindowEvent {
|
RunEvent::ExitRequested{..} => {
|
||||||
label,
|
let handle = app_handle.clone();
|
||||||
event: WindowEvent::CloseRequested { .. },
|
if let Err(e) = handle.save_window_state(StateFlags::all()) {
|
||||||
..
|
warn!("Failed to save window state {e:?}");
|
||||||
} => {
|
} else {
|
||||||
// Save window state on close because, for some reason, it doesn't
|
debug!("Saved window state");
|
||||||
if !label.starts_with(OTHER_WINDOW_PREFIX) {
|
};
|
||||||
let handle = app_handle.clone();
|
},
|
||||||
if let Err(e) = handle.save_window_state(StateFlags::all()) {
|
|
||||||
warn!("Failed to save window state {e:?}");
|
|
||||||
} else {
|
|
||||||
debug!("Saved window state");
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => {}
|
_ => {}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@@ -2005,7 +2000,19 @@ fn create_main_window(handle: &AppHandle, url: &str) -> WebviewWindow {
|
|||||||
100.0 + random::<f64>() * 20.0,
|
100.0 + random::<f64>() * 20.0,
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
create_window(handle, config)
|
|
||||||
|
let window = create_window(handle, config);
|
||||||
|
|
||||||
|
// Restore window state if it's a main window
|
||||||
|
if !label.starts_with(OTHER_WINDOW_PREFIX) {
|
||||||
|
if let Err(e) = window.restore_state(StateFlags::all()) {
|
||||||
|
warn!("Failed to restore window state {e:?}");
|
||||||
|
} else {
|
||||||
|
debug!("Restored window state");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
window
|
||||||
}
|
}
|
||||||
|
|
||||||
struct CreateWindowConfig<'s> {
|
struct CreateWindowConfig<'s> {
|
||||||
@@ -2099,12 +2106,6 @@ fn create_window(handle: &AppHandle, config: CreateWindowConfig) -> WebviewWindo
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if let Err(e) = win.restore_state(StateFlags::all()) {
|
|
||||||
warn!("Failed to restore window state {e:?}");
|
|
||||||
} else {
|
|
||||||
debug!("Restored window state");
|
|
||||||
}
|
|
||||||
|
|
||||||
win
|
win
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user