feat(startup settings): use /proc/{pid}/environ
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
use super::spatial::Spatial;
|
||||
use super::startup::DESKTOP_STARTUP_IDS;
|
||||
use super::Node;
|
||||
use crate::core::client::Client;
|
||||
use crate::core::registry::Registry;
|
||||
use color_eyre::eyre::{eyre, Result};
|
||||
use color_eyre::eyre::Result;
|
||||
use glam::Mat4;
|
||||
use stardust_xr::schemas::flex::{deserialize, serialize};
|
||||
|
||||
@@ -19,7 +18,6 @@ pub struct Root {
|
||||
impl Root {
|
||||
pub fn create(client: &Arc<Client>) -> Arc<Self> {
|
||||
let node = Node::create(client, "", "", false);
|
||||
node.add_local_signal("apply_desktop_startup_id", Root::apply_desktop_startup_id);
|
||||
node.add_local_signal("subscribe_logic_step", Root::subscribe_logic_step);
|
||||
node.add_local_signal("set_base_prefixes", Root::set_base_prefixes);
|
||||
let node = node.add_to_scenegraph();
|
||||
@@ -31,21 +29,8 @@ impl Root {
|
||||
})
|
||||
}
|
||||
|
||||
fn apply_desktop_startup_id(
|
||||
node: &Node,
|
||||
_calling_client: Arc<Client>,
|
||||
data: &[u8],
|
||||
) -> Result<()> {
|
||||
let startup_settings = DESKTOP_STARTUP_IDS
|
||||
.lock()
|
||||
.remove(flexbuffers::Reader::get_root(data)?.get_str()?)
|
||||
.ok_or_else(|| eyre!("Desktop startup ID not found in the list!"))?;
|
||||
node.spatial
|
||||
.get()
|
||||
.unwrap()
|
||||
.set_local_transform(startup_settings.transform);
|
||||
|
||||
Ok(())
|
||||
pub fn spatial(&self) -> &Arc<Spatial> {
|
||||
self.node.spatial.get().unwrap()
|
||||
}
|
||||
|
||||
fn subscribe_logic_step(_node: &Node, calling_client: Arc<Client>, _data: &[u8]) -> Result<()> {
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
use crate::core::client::Client;
|
||||
|
||||
use super::Node;
|
||||
use color_eyre::eyre::{eyre, Result};
|
||||
use super::{
|
||||
spatial::find_spatial,
|
||||
Node,
|
||||
};
|
||||
use color_eyre::eyre::Result;
|
||||
use glam::Mat4;
|
||||
use parking_lot::Mutex;
|
||||
use rustc_hash::FxHashMap;
|
||||
@@ -23,15 +26,7 @@ impl StartupSettings {
|
||||
}
|
||||
|
||||
fn set_root_flex(node: &Node, calling_client: Arc<Client>, data: &[u8]) -> Result<()> {
|
||||
let startup_id = flexbuffers::Reader::get_root(data)?.get_str()?;
|
||||
let spatial_node = calling_client
|
||||
.scenegraph
|
||||
.get_node(startup_id)
|
||||
.ok_or_else(|| eyre!("Root spatial node does not exist"))?;
|
||||
let spatial = spatial_node
|
||||
.spatial
|
||||
.get()
|
||||
.ok_or_else(|| eyre!("Root spatial node is not a spatial"))?;
|
||||
let spatial = find_spatial(&calling_client, "Root spatial", deserialize(data)?)?;
|
||||
node.startup_settings.get().unwrap().lock().transform = spatial.global_transform();
|
||||
|
||||
Ok(())
|
||||
@@ -43,7 +38,7 @@ impl StartupSettings {
|
||||
_data: &[u8],
|
||||
) -> Result<Vec<u8>> {
|
||||
let id = nanoid::nanoid!();
|
||||
let data = flexbuffers::singleton(id.as_str());
|
||||
let data = serialize(&id)?;
|
||||
DESKTOP_STARTUP_IDS
|
||||
.lock()
|
||||
.insert(id, node.startup_settings.get().unwrap().lock().clone());
|
||||
|
||||
Reference in New Issue
Block a user