diff --git a/src/core/client_state.rs b/src/core/client_state.rs index 5a3ea07..e1cedad 100644 --- a/src/core/client_state.rs +++ b/src/core/client_state.rs @@ -33,7 +33,8 @@ impl LaunchInfo { #[derive(Debug, Serialize, Deserialize)] pub struct ClientStateParsed { pub launch_info: Option, - pub data: Vec, + #[serde(skip)] + pub data: Option>, pub root: Mat4, pub spatial_anchors: FxHashMap, } @@ -41,7 +42,7 @@ impl ClientStateParsed { pub fn from_deserialized(client: &Client, state: ClientState) -> Self { ClientStateParsed { launch_info: LaunchInfo::from_client(client), - data: state.data.unwrap_or_default(), + data: state.data, root: Self::spatial_transform(client, state.root).unwrap_or_default(), spatial_anchors: state .spatial_anchors @@ -63,7 +64,9 @@ impl ClientStateParsed { } pub fn from_file(file: &Path) -> Option { let file_string = std::fs::read_to_string(file).ok()?; - toml::from_str(&file_string).ok() + let mut client_state: Self = toml::from_str(&file_string).ok()?; + client_state.data = std::fs::read(file.with_extension("bin")).ok(); + Some(client_state) } pub fn to_file(&self, directory: &Path) { let app_name = self @@ -71,11 +74,14 @@ impl ClientStateParsed { .as_ref() .map(|l| l.cmdline.first().unwrap().split('/').next_back().unwrap()) .unwrap_or("unknown"); - let state_file_path = directory - .join(format!("{app_name}-{}", nanoid::nanoid!())) - .with_extension("toml"); + let state_file_prefix = directory.join(format!("{app_name}-{}", nanoid::nanoid!())); + let state_metadata_path = state_file_prefix.with_extension("toml"); + let state_data_path = state_file_prefix.with_extension("bin"); - std::fs::write(state_file_path, toml::to_string(&self).unwrap()).unwrap(); + std::fs::write(state_metadata_path, toml::to_string(&self).unwrap()).unwrap(); + if let Some(data) = self.data.as_deref() { + std::fs::write(state_data_path, data).unwrap(); + } } pub fn apply_to(&self, client: &Arc) -> ClientState { @@ -83,7 +89,7 @@ impl ClientStateParsed { root.set_transform(self.root) } ClientState { - data: Some(self.data.clone()), + data: self.data.clone(), root: 0, spatial_anchors: self .spatial_anchors @@ -111,7 +117,7 @@ impl Default for ClientStateParsed { fn default() -> Self { Self { launch_info: None, - data: Default::default(), + data: None, root: Mat4::IDENTITY, spatial_anchors: Default::default(), } diff --git a/src/nodes/drawable/lines.rs b/src/nodes/drawable/lines.rs index 335d255..2bc9545 100644 --- a/src/nodes/drawable/lines.rs +++ b/src/nodes/drawable/lines.rs @@ -194,7 +194,7 @@ fn build_line_mesh( perceptual_roughness: 1.0, // TODO: this should be Blend alpha_mode: AlphaMode::Opaque, - unlit: true, + emissive: Color::srgba_u8(128, 128, 128, 255).into(), ..default() })), )); diff --git a/src/session.rs b/src/session.rs index df82893..d1d0433 100644 --- a/src/session.rs +++ b/src/session.rs @@ -5,6 +5,7 @@ use crate::wayland::WAYLAND_DISPLAY; use crate::{CliArgs, STARDUST_INSTANCE}; use directories::ProjectDirs; use rustc_hash::FxHashMap; +use std::ffi::OsStr; use std::os::unix::fs::PermissionsExt; use std::path::Path; use std::process::{Child, Command, Stdio}; @@ -58,6 +59,7 @@ pub fn restore_session(session_dir: &Path, debug_launched_clients: bool) -> Vec< }; clients .filter_map(Result::ok) + .filter(|c| c.path().extension() == Some(OsStr::new("toml"))) .filter_map(|c| ClientStateParsed::from_file(&c.path())) .filter_map(ClientStateParsed::launch_command) .filter_map(|c| run_client(c, debug_launched_clients))