// SPDX-License-Identifier: AGPL-3.0-or-later use std::fs; use std::path::PathBuf; use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize)] pub struct WindowState { pub width: u32, pub height: u32, pub x: i32, pub y: i32, } impl WindowState { pub fn load(config_dir: &Option) -> Option { let path = config_dir.as_ref()?.join("window_state.json"); let content = fs::read_to_string(path).ok()?; serde_json::from_str(&content).ok() } pub fn save(&self, config_dir: &Option) { let Some(dir) = config_dir else { return }; let path = dir.join("window_state.json"); if let Ok(json) = serde_json::to_string(self) { let _ = fs::write(path, json); } } }