diff --git a/Cargo.toml b/Cargo.toml index fc9e779..61d3d43 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] -edition = "2021" -rust-version = "1.75" +edition = "2024" +rust-version = "1.85" name = "stardust-xr-server" version = "0.45.0" authors = ["Nova King "] diff --git a/src/core/client.rs b/src/core/client.rs index f5956bb..0ac572f 100644 --- a/src/core/client.rs +++ b/src/core/client.rs @@ -1,17 +1,17 @@ use super::{ - client_state::{ClientStateParsed, CLIENT_STATES}, + client_state::{CLIENT_STATES, ClientStateParsed}, destroy_queue, scenegraph::Scenegraph, }; use crate::{ core::{registry::OwnedRegistry, task}, nodes::{ - audio, drawable, fields, input, items, + Node, audio, drawable, fields, input, items, root::{ClientState, Root}, - spatial, Node, + spatial, }, }; -use color_eyre::eyre::{eyre, Result}; +use color_eyre::eyre::{Result, eyre}; use global_counter::primitive::exact::CounterU32; use lazy_static::lazy_static; use once_cell::sync::OnceCell; diff --git a/src/core/client_state.rs b/src/core/client_state.rs index aa9c9bf..a2aa9c4 100644 --- a/src/core/client_state.rs +++ b/src/core/client_state.rs @@ -1,5 +1,5 @@ -use super::client::{get_env, Client}; -use crate::nodes::{root::ClientState, spatial::Spatial, Node}; +use super::client::{Client, get_env}; +use crate::nodes::{Node, root::ClientState, spatial::Spatial}; use glam::Mat4; use parking_lot::Mutex; use rustc_hash::FxHashMap; diff --git a/src/core/error.rs b/src/core/error.rs index 6dbe502..15b315f 100644 --- a/src/core/error.rs +++ b/src/core/error.rs @@ -4,8 +4,8 @@ use color_eyre::eyre::Report; use stardust_xr::{ messenger::MessengerError, schemas::flex::{ - flexbuffers::{DeserializationError, ReaderError}, FlexSerializeError, + flexbuffers::{DeserializationError, ReaderError}, }, }; use stereokit_rust::StereoKitError; diff --git a/src/core/registry.rs b/src/core/registry.rs index 711d6f2..5d9d85b 100644 --- a/src/core/registry.rs +++ b/src/core/registry.rs @@ -1,6 +1,6 @@ #![allow(dead_code)] -use parking_lot::{const_mutex, MappedMutexGuard, Mutex, MutexGuard}; +use parking_lot::{MappedMutexGuard, Mutex, MutexGuard, const_mutex}; use rustc_hash::FxHashMap; use std::ptr; use std::sync::{Arc, Weak}; diff --git a/src/core/scenegraph.rs b/src/core/scenegraph.rs index 745b3c3..bb62254 100644 --- a/src/core/scenegraph.rs +++ b/src/core/scenegraph.rs @@ -1,6 +1,6 @@ use crate::core::error::Result; -use crate::nodes::alias::get_original; use crate::nodes::Node; +use crate::nodes::alias::get_original; use crate::{core::client::Client, nodes::Message}; use once_cell::sync::OnceCell; use parking_lot::Mutex; diff --git a/src/main.rs b/src/main.rs index 747dceb..b6ebd2f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -25,7 +25,7 @@ use std::time::Duration; use stereokit_rust::material::Material; use stereokit_rust::shader::Shader; use stereokit_rust::sk::{ - sk_quit, AppMode, DepthMode, DisplayBlend, OriginMode, QuitReason, SkSettings, + AppMode, DepthMode, DisplayBlend, OriginMode, QuitReason, SkSettings, sk_quit, }; use stereokit_rust::system::{Handed, Input, LogLevel, Renderer}; use stereokit_rust::tex::{SHCubemap, Tex, TexFormat, TexType}; @@ -35,9 +35,9 @@ use tokio::net::UnixListener; use tokio::sync::Notify; use tracing::metadata::LevelFilter; use tracing::{debug_span, error, info}; -use tracing_subscriber::{fmt, prelude::*, EnvFilter}; -use zbus::fdo::ObjectManager; +use tracing_subscriber::{EnvFilter, fmt, prelude::*}; use zbus::Connection; +use zbus::fdo::ObjectManager; #[derive(Debug, Clone, Parser)] #[clap(author, version, about, long_about = None)] @@ -123,7 +123,9 @@ async fn main() { let project_dirs = ProjectDirs::from("", "", "stardust"); if project_dirs.is_none() { - error!("Unable to get Stardust project directories, default skybox and startup script will not work."); + error!( + "Unable to get Stardust project directories, default skybox and startup script will not work." + ); } let dbus_connection = Connection::session() @@ -132,7 +134,9 @@ async fn main() { dbus_connection .request_name("org.stardustxr.HMD") .await - .expect("Another instance of the server is running. This is not supported currently (but is planned)."); + .expect( + "Another instance of the server is running. This is not supported currently (but is planned).", + ); dbus_connection .object_server() diff --git a/src/nodes/audio.rs b/src/nodes/audio.rs index 0faf870..09015db 100644 --- a/src/nodes/audio.rs +++ b/src/nodes/audio.rs @@ -4,9 +4,9 @@ use crate::core::destroy_queue; use crate::core::error::Result; use crate::core::registry::Registry; use crate::core::resource::get_resource_file; -use crate::nodes::spatial::{Spatial, Transform, SPATIAL_ASPECT_ALIAS_INFO}; +use crate::nodes::spatial::{SPATIAL_ASPECT_ALIAS_INFO, Spatial, Transform}; use color_eyre::eyre::eyre; -use glam::{vec3, Vec4Swizzles}; +use glam::{Vec4Swizzles, vec3}; use once_cell::sync::OnceCell; use parking_lot::Mutex; use stardust_xr::values::ResourceID; diff --git a/src/nodes/drawable/lines.rs b/src/nodes/drawable/lines.rs index 7f372b7..efb6242 100644 --- a/src/nodes/drawable/lines.rs +++ b/src/nodes/drawable/lines.rs @@ -1,7 +1,7 @@ use super::{Line, LinesAspect}; use crate::{ core::{client::Client, error::Result, registry::Registry}, - nodes::{spatial::Spatial, Node}, + nodes::{Node, spatial::Spatial}, }; use glam::Vec3; use parking_lot::Mutex; diff --git a/src/nodes/drawable/mod.rs b/src/nodes/drawable/mod.rs index 3c2ba5c..4a7ae9d 100644 --- a/src/nodes/drawable/mod.rs +++ b/src/nodes/drawable/mod.rs @@ -1,14 +1,12 @@ pub mod lines; pub mod model; -#[cfg(feature = "wayland")] -pub mod shader_manipulation; pub mod shaders; pub mod text; use self::{lines::Lines, model::Model, text::Text}; use super::{ - spatial::{Spatial, Transform}, Aspect, AspectIdentifier, Node, + spatial::{Spatial, Transform}, }; use crate::core::{client::Client, error::Result, resource::get_resource_file}; use crate::nodes::spatial::SPATIAL_ASPECT_ALIAS_INFO; diff --git a/src/nodes/drawable/model.rs b/src/nodes/drawable/model.rs index 0c7469d..0f04785 100644 --- a/src/nodes/drawable/model.rs +++ b/src/nodes/drawable/model.rs @@ -1,12 +1,12 @@ -use super::{MaterialParameter, ModelAspect, ModelPartAspect, MODEL_PART_ASPECT_ALIAS_INFO}; +use super::{MODEL_PART_ASPECT_ALIAS_INFO, MaterialParameter, ModelAspect, ModelPartAspect}; use crate::bail; use crate::core::client::Client; use crate::core::error::Result; use crate::core::registry::Registry; use crate::core::resource::get_resource_file; +use crate::nodes::Node; use crate::nodes::alias::{Alias, AliasList}; use crate::nodes::spatial::Spatial; -use crate::nodes::Node; use color_eyre::eyre::eyre; use glam::{Mat4, Vec2, Vec3}; use once_cell::sync::{Lazy, OnceCell}; diff --git a/src/nodes/drawable/shader_manipulation.rs b/src/nodes/drawable/shader_manipulation.rs deleted file mode 100644 index bfcbad0..0000000 --- a/src/nodes/drawable/shader_manipulation.rs +++ /dev/null @@ -1,137 +0,0 @@ -#![allow(dead_code)] -use smithay::backend::renderer::gles::{ - ffi::{self, Gles2, FRAGMENT_SHADER, VERTEX_SHADER}, - GlesError, -}; -use stereokit_rust::shader::{Shader, _ShaderT}; -use tracing::error; - -struct FfiAssetHeader { - asset_type: i32, - asset_state: i32, - id: u64, - index: u64, - refs: i32, - debug: *mut u8, -} - -struct FfiSkgShader { - meta: *mut u8, - vertex: u32, - pixel: u32, - program: u32, - compute: u32, -} - -struct FfiShader { - header: FfiAssetHeader, - shader: FfiSkgShader, -} - -unsafe fn compile_shader( - gl: &ffi::Gles2, - variant: ffi::types::GLuint, - src: &str, -) -> Result { - let shader = gl.CreateShader(variant); - if shader == 0 { - return Err(GlesError::CreateShaderObject); - } - - gl.ShaderSource( - shader, - 1, - &src.as_ptr() as *const *const u8 as *const *const ffi::types::GLchar, - &(src.len() as i32) as *const _, - ); - gl.CompileShader(shader); - - let mut status = ffi::FALSE as i32; - gl.GetShaderiv(shader, ffi::COMPILE_STATUS, &mut status as *mut _); - if status == ffi::FALSE as i32 { - let mut max_len = 0; - gl.GetShaderiv(shader, ffi::INFO_LOG_LENGTH, &mut max_len as *mut _); - - let mut error = Vec::with_capacity(max_len as usize); - let mut len = 0; - gl.GetShaderInfoLog( - shader, - max_len as _, - &mut len as *mut _, - error.as_mut_ptr() as *mut _, - ); - error.set_len(len as usize); - - error!( - "[GL] {}", - std::str::from_utf8(&error).unwrap_or("") - ); - - gl.DeleteShader(shader); - return Err(GlesError::ShaderCompileError); - } - - Ok(shader) -} - -unsafe fn link_program( - gl: &ffi::Gles2, - vert: ffi::types::GLuint, - frag: ffi::types::GLuint, -) -> Result { - let program = gl.CreateProgram(); - gl.AttachShader(program, vert); - gl.AttachShader(program, frag); - gl.LinkProgram(program); - // gl.DetachShader(program, vert); - // gl.DetachShader(program, frag); - // gl.DeleteShader(vert); - // gl.DeleteShader(frag); - - let mut status = ffi::FALSE as i32; - gl.GetProgramiv(program, ffi::LINK_STATUS, &mut status as *mut _); - if status == ffi::FALSE as i32 { - let mut max_len = 0; - gl.GetProgramiv(program, ffi::INFO_LOG_LENGTH, &mut max_len as *mut _); - - let mut error = Vec::with_capacity(max_len as usize); - let mut len = 0; - gl.GetProgramInfoLog( - program, - max_len as _, - &mut len as *mut _, - error.as_mut_ptr() as *mut _, - ); - error.set_len(len as usize); - - error!( - "[GL] {}", - std::str::from_utf8(&error).unwrap_or("") - ); - - gl.DeleteProgram(program); - return Err(GlesError::ProgramLinkError); - } - - Ok(program) -} - -pub unsafe fn shader_inject( - c: &Gles2, - sk_shader: &mut Shader, - vert_str: &str, - frag_str: &str, -) -> Result<(), GlesError> { - let gl_vert = compile_shader(c, VERTEX_SHADER, vert_str)?; - let gl_frag = compile_shader(c, FRAGMENT_SHADER, frag_str)?; - let gl_prog = link_program(c, gl_vert, gl_frag)?; - - let shader = sk_shader.0.as_mut() as *mut _ShaderT as *mut FfiShader; - if let Some(shader) = shader.as_mut() { - shader.shader.vertex = gl_vert; - shader.shader.pixel = gl_frag; - shader.shader.program = gl_prog; - } - - Ok(()) -} diff --git a/src/nodes/drawable/text.rs b/src/nodes/drawable/text.rs index ed1ac3c..55ba8cf 100644 --- a/src/nodes/drawable/text.rs +++ b/src/nodes/drawable/text.rs @@ -3,10 +3,10 @@ use crate::{ client::Client, destroy_queue, error::Result, registry::Registry, resource::get_resource_file, }, - nodes::{spatial::Spatial, Node}, + nodes::{Node, spatial::Spatial}, }; use color_eyre::eyre::eyre; -use glam::{vec3, Mat4, Vec2}; +use glam::{Mat4, Vec2, vec3}; use once_cell::sync::OnceCell; use parking_lot::Mutex; use std::{ffi::OsStr, path::PathBuf, sync::Arc}; @@ -14,7 +14,7 @@ use stereokit_rust::{ font::Font, sk::MainThreadToken, system::{TextAlign, TextFit, TextStyle as SkTextStyle}, - util::{Color128, Color32}, + util::{Color32, Color128}, }; use super::{TextAspect, TextStyle}; diff --git a/src/nodes/fields.rs b/src/nodes/fields.rs index 32552fc..e0b6e59 100644 --- a/src/nodes/fields.rs +++ b/src/nodes/fields.rs @@ -1,16 +1,17 @@ use super::alias::{Alias, AliasInfo}; use super::spatial::{ - Spatial, SPATIAL_REF_GET_LOCAL_BOUNDING_BOX_SERVER_OPCODE, + SPATIAL_REF_GET_LOCAL_BOUNDING_BOX_SERVER_OPCODE, SPATIAL_REF_GET_RELATIVE_BOUNDING_BOX_SERVER_OPCODE, SPATIAL_REF_GET_TRANSFORM_SERVER_OPCODE, + Spatial, }; use super::{Aspect, AspectIdentifier, Node}; use crate::core::client::Client; use crate::core::error::Result; -use crate::nodes::spatial::Transform; use crate::nodes::spatial::SPATIAL_ASPECT_ALIAS_INFO; use crate::nodes::spatial::SPATIAL_REF_ASPECT_ALIAS_INFO; +use crate::nodes::spatial::Transform; use color_eyre::eyre::OptionExt; -use glam::{vec2, vec3, vec3a, Vec3, Vec3A, Vec3Swizzles}; +use glam::{Vec3, Vec3A, Vec3Swizzles, vec2, vec3, vec3a}; use once_cell::sync::Lazy; use parking_lot::Mutex; use rustc_hash::FxHashMap; diff --git a/src/nodes/input/hand.rs b/src/nodes/input/hand.rs index 8512583..892c1a7 100644 --- a/src/nodes/input/hand.rs +++ b/src/nodes/input/hand.rs @@ -1,7 +1,7 @@ use super::{Finger, Hand, InputDataTrait, InputHandler, InputMethod, Joint, Thumb}; use crate::nodes::fields::{Field, FieldTrait}; use crate::nodes::spatial::Spatial; -use glam::{vec3a, Mat4, Quat}; +use glam::{Mat4, Quat, vec3a}; use std::sync::Arc; impl Default for Joint { diff --git a/src/nodes/input/handler.rs b/src/nodes/input/handler.rs index 6bcd2c7..7d2776a 100644 --- a/src/nodes/input/handler.rs +++ b/src/nodes/input/handler.rs @@ -1,5 +1,5 @@ -use super::{InputHandlerAspect, INPUT_HANDLER_REGISTRY, INPUT_METHOD_REGISTRY}; -use crate::nodes::{alias::AliasList, fields::Field, spatial::Spatial, Node}; +use super::{INPUT_HANDLER_REGISTRY, INPUT_METHOD_REGISTRY, InputHandlerAspect}; +use crate::nodes::{Node, alias::AliasList, fields::Field, spatial::Spatial}; use color_eyre::eyre::Result; use std::sync::Arc; diff --git a/src/nodes/input/method.rs b/src/nodes/input/method.rs index fa0d48e..39d5d4b 100644 --- a/src/nodes/input/method.rs +++ b/src/nodes/input/method.rs @@ -1,15 +1,15 @@ use super::{ - input_method_client, InputData, InputDataTrait, InputDataType, InputHandler, InputMethodAspect, - InputMethodRefAspect, INPUT_HANDLER_REGISTRY, INPUT_METHOD_REF_ASPECT_ALIAS_INFO, - INPUT_METHOD_REGISTRY, + INPUT_HANDLER_REGISTRY, INPUT_METHOD_REF_ASPECT_ALIAS_INFO, INPUT_METHOD_REGISTRY, InputData, + InputDataTrait, InputDataType, InputHandler, InputMethodAspect, InputMethodRefAspect, + input_method_client, }; use crate::{ core::{client::Client, error::Result, registry::Registry}, nodes::{ - alias::{Alias, AliasList}, - fields::{Field, FIELD_ALIAS_INFO}, - spatial::Spatial, Node, + alias::{Alias, AliasList}, + fields::{FIELD_ALIAS_INFO, Field}, + spatial::Spatial, }, }; use parking_lot::Mutex; diff --git a/src/nodes/input/mod.rs b/src/nodes/input/mod.rs index 3d01c17..60aaa08 100644 --- a/src/nodes/input/mod.rs +++ b/src/nodes/input/mod.rs @@ -9,10 +9,10 @@ mod tip; pub use handler::*; pub use method::*; -use super::fields::Field; -use super::spatial::Spatial; use super::Aspect; use super::AspectIdentifier; +use super::fields::Field; +use super::spatial::Spatial; use crate::core::error::Result; use crate::nodes::spatial::SPATIAL_ASPECT_ALIAS_INFO; use crate::nodes::spatial::SPATIAL_REF_ASPECT_ALIAS_INFO; diff --git a/src/nodes/input/pointer.rs b/src/nodes/input/pointer.rs index d2b669e..4ce92f9 100644 --- a/src/nodes/input/pointer.rs +++ b/src/nodes/input/pointer.rs @@ -3,7 +3,7 @@ use crate::nodes::{ fields::{Field, FieldTrait, Ray, RayMarchResult}, spatial::Spatial, }; -use glam::{vec3, Mat4, Quat}; +use glam::{Mat4, Quat, vec3}; use std::sync::{Arc, Weak}; impl Default for Pointer { diff --git a/src/nodes/items/camera.rs b/src/nodes/items/camera.rs index b72615f..9f242fe 100644 --- a/src/nodes/items/camera.rs +++ b/src/nodes/items/camera.rs @@ -1,20 +1,20 @@ -use super::{create_item_acceptor_flex, register_item_ui_flex, Item, ItemType}; +use super::{Item, ItemType, create_item_acceptor_flex, register_item_ui_flex}; use crate::bail; use crate::core::error::Result; -use crate::nodes::items::ITEM_ACCEPTOR_ASPECT_ALIAS_INFO; -use crate::nodes::items::ITEM_ASPECT_ALIAS_INFO; use crate::nodes::Aspect; use crate::nodes::AspectIdentifier; +use crate::nodes::items::ITEM_ACCEPTOR_ASPECT_ALIAS_INFO; +use crate::nodes::items::ITEM_ASPECT_ALIAS_INFO; use crate::{ core::{client::Client, registry::Registry, scenegraph::MethodResponseSender}, nodes::{ + Message, Node, drawable::{ model::{MaterialWrapper, ModelPart}, shaders::UNLIT_SHADER_BYTES, }, items::TypeInfo, spatial::{Spatial, Transform}, - Message, Node, }, }; use glam::Mat4; diff --git a/src/nodes/items/mod.rs b/src/nodes/items/mod.rs index 5844082..a0255ae 100644 --- a/src/nodes/items/mod.rs +++ b/src/nodes/items/mod.rs @@ -4,7 +4,7 @@ pub mod panel; use self::camera::CameraItem; use self::panel::PanelItemTrait; use super::alias::AliasList; -use super::fields::{Field, FIELD_ALIAS_INFO}; +use super::fields::{FIELD_ALIAS_INFO, Field}; use super::spatial::Spatial; use super::{Alias, Aspect, AspectIdentifier, Node}; use crate::core::client::Client; @@ -12,8 +12,8 @@ use crate::core::error::Result; use crate::core::registry::Registry; use crate::ensure; use crate::nodes::alias::AliasInfo; -use crate::nodes::spatial::Transform; use crate::nodes::spatial::SPATIAL_ASPECT_ALIAS_INFO; +use crate::nodes::spatial::Transform; use parking_lot::Mutex; use std::hash::Hash; use std::sync::{Arc, Weak}; diff --git a/src/nodes/items/panel.rs b/src/nodes/items/panel.rs index a3cb813..78c5a8e 100644 --- a/src/nodes/items/panel.rs +++ b/src/nodes/items/panel.rs @@ -7,14 +7,14 @@ use crate::nodes::items::ITEM_ASPECT_ALIAS_INFO; use crate::nodes::{Aspect, AspectIdentifier}; use crate::{ core::{ - client::{get_env, state, Client, INTERNAL_CLIENT}, + client::{Client, INTERNAL_CLIENT, get_env, state}, registry::Registry, }, nodes::{ + Node, drawable::model::ModelPart, items::{Item, ItemType, TypeInfo}, spatial::{Spatial, Transform}, - Node, }, }; use glam::Mat4; diff --git a/src/nodes/mod.rs b/src/nodes/mod.rs index ef3289d..9e9507a 100644 --- a/src/nodes/mod.rs +++ b/src/nodes/mod.rs @@ -15,7 +15,7 @@ use crate::core::scenegraph::MethodResponseSender; use parking_lot::Mutex; use portable_atomic::{AtomicBool, Ordering}; use rustc_hash::FxHashMap; -use serde::{de::DeserializeOwned, Serialize}; +use serde::{Serialize, de::DeserializeOwned}; use spatial::Spatial; use stardust_xr::messenger::MessageSenderHandle; use stardust_xr::scenegraph::ScenegraphError; diff --git a/src/nodes/spatial/mod.rs b/src/nodes/spatial/mod.rs index cba7b0b..8722059 100644 --- a/src/nodes/spatial/mod.rs +++ b/src/nodes/spatial/mod.rs @@ -10,7 +10,7 @@ use crate::core::error::Result; use crate::core::registry::Registry; use crate::nodes::{Node, OWNED_ASPECT_ALIAS_INFO}; use color_eyre::eyre::OptionExt; -use glam::{vec3a, Mat4, Quat, Vec3}; +use glam::{Mat4, Quat, Vec3, vec3a}; use mint::Vector3; use once_cell::sync::OnceCell; use parking_lot::Mutex; diff --git a/src/nodes/spatial/zone.rs b/src/nodes/spatial/zone.rs index 2779ded..9f45391 100644 --- a/src/nodes/spatial/zone.rs +++ b/src/nodes/spatial/zone.rs @@ -1,13 +1,13 @@ use super::{ - Spatial, ZoneAspect, SPATIAL_ASPECT_ALIAS_INFO, SPATIAL_REF_ASPECT_ALIAS_INFO, - ZONEABLE_REGISTRY, + SPATIAL_ASPECT_ALIAS_INFO, SPATIAL_REF_ASPECT_ALIAS_INFO, Spatial, ZONEABLE_REGISTRY, + ZoneAspect, }; use crate::{ core::{client::Client, error::Result, registry::Registry}, nodes::{ - alias::{get_original, Alias, AliasList}, - fields::{Field, FieldTrait}, Node, + alias::{Alias, AliasList, get_original}, + fields::{Field, FieldTrait}, }, }; use glam::vec3a; diff --git a/src/objects/input/eye_pointer.rs b/src/objects/input/eye_pointer.rs index bae4316..04caf8b 100644 --- a/src/objects/input/eye_pointer.rs +++ b/src/objects/input/eye_pointer.rs @@ -1,14 +1,14 @@ use crate::{ core::client::INTERNAL_CLIENT, nodes::{ - fields::{FieldTrait, Ray}, - input::{InputDataType, InputMethod, Pointer, INPUT_HANDLER_REGISTRY}, - spatial::Spatial, Node, OwnedNode, + fields::{FieldTrait, Ray}, + input::{INPUT_HANDLER_REGISTRY, InputDataType, InputMethod, Pointer}, + spatial::Spatial, }, }; use color_eyre::eyre::Result; -use glam::{vec3, Mat4}; +use glam::{Mat4, vec3}; use serde::{Deserialize, Serialize}; use stardust_xr::values::Datamap; use std::sync::Arc; diff --git a/src/objects/input/mod.rs b/src/objects/input/mod.rs index 65f0c48..252a3c0 100644 --- a/src/objects/input/mod.rs +++ b/src/objects/input/mod.rs @@ -5,7 +5,7 @@ pub mod sk_hand; use crate::nodes::{ fields::{Field, FieldTrait, Ray}, - input::{InputDataTrait, InputDataType, InputHandler, InputMethod, INPUT_HANDLER_REGISTRY}, + input::{INPUT_HANDLER_REGISTRY, InputDataTrait, InputDataType, InputHandler, InputMethod}, spatial::Spatial, }; use glam::vec3; @@ -70,13 +70,13 @@ pub fn get_sorted_handlers( INPUT_HANDLER_REGISTRY .get_valid_contents() .into_iter() - .filter(|handler| handler.spatial.node().map_or(false, |node| node.enabled())) + .filter(|handler| handler.spatial.node().is_some_and(|node| node.enabled())) .filter(|handler| { handler .field .spatial .node() - .map_or(false, |node| node.enabled()) + .is_some_and(|node| node.enabled()) }) .filter_map(|handler| { distance_calculator(&method.spatial, &method.data.lock(), &handler.field) diff --git a/src/objects/input/mouse_pointer.rs b/src/objects/input/mouse_pointer.rs index 134ff10..a932cef 100644 --- a/src/objects/input/mouse_pointer.rs +++ b/src/objects/input/mouse_pointer.rs @@ -1,16 +1,16 @@ -use super::{get_sorted_handlers, CaptureManager, DistanceCalculator}; +use super::{CaptureManager, DistanceCalculator, get_sorted_handlers}; use crate::{ core::client::INTERNAL_CLIENT, nodes::{ - fields::{Field, FieldTrait, Ray, EXPORTED_FIELDS}, + Node, OwnedNode, + fields::{EXPORTED_FIELDS, Field, FieldTrait, Ray}, input::{InputDataType, InputMethod, Pointer}, items::panel::KEYMAPS, spatial::Spatial, - Node, OwnedNode, }, }; use color_eyre::eyre::Result; -use glam::{vec3, Mat4, Vec3}; +use glam::{Mat4, Vec3, vec3}; use mint::Vector2; use serde::{Deserialize, Serialize}; use slotmap::{DefaultKey, Key as SlotKey}; @@ -21,9 +21,9 @@ use stardust_xr::{ use std::sync::Arc; use stereokit_rust::system::{Input, Key}; use tokio::task::JoinSet; -use tokio::time::{timeout, Duration}; -use xkbcommon_rs::{xkb_keymap::CompileFlags, Context, Keymap, KeymapFormat}; -use zbus::{names::OwnedInterfaceName, Connection}; +use tokio::time::{Duration, timeout}; +use xkbcommon_rs::{Context, Keymap, KeymapFormat, xkb_keymap::CompileFlags}; +use zbus::{Connection, names::OwnedInterfaceName}; #[derive(Debug, Deserialize, Serialize)] struct MouseEvent { diff --git a/src/objects/input/sk_controller.rs b/src/objects/input/sk_controller.rs index da872ff..1d97066 100644 --- a/src/objects/input/sk_controller.rs +++ b/src/objects/input/sk_controller.rs @@ -1,11 +1,11 @@ -use super::{get_sorted_handlers, CaptureManager}; +use super::{CaptureManager, get_sorted_handlers}; use crate::{ core::client::INTERNAL_CLIENT, nodes::{ - fields::{Field, FieldTrait}, - input::{InputDataType, InputHandler, InputMethod, Tip, INPUT_HANDLER_REGISTRY}, - spatial::Spatial, Node, OwnedNode, + fields::{Field, FieldTrait}, + input::{INPUT_HANDLER_REGISTRY, InputDataType, InputHandler, InputMethod, Tip}, + spatial::Spatial, }, objects::{ObjectHandle, SpatialRef}, }; diff --git a/src/objects/input/sk_hand.rs b/src/objects/input/sk_hand.rs index 5b7090e..9352465 100644 --- a/src/objects/input/sk_hand.rs +++ b/src/objects/input/sk_hand.rs @@ -1,11 +1,11 @@ use crate::core::client::INTERNAL_CLIENT; -use crate::nodes::fields::{Field, FieldTrait}; -use crate::nodes::input::{InputDataType, InputHandler, INPUT_HANDLER_REGISTRY}; use crate::nodes::OwnedNode; +use crate::nodes::fields::{Field, FieldTrait}; +use crate::nodes::input::{INPUT_HANDLER_REGISTRY, InputDataType, InputHandler}; use crate::nodes::{ + Node, input::{Hand, InputMethod, Joint}, spatial::Spatial, - Node, }; use crate::objects::{ObjectHandle, SpatialRef}; use color_eyre::eyre::Result; @@ -19,7 +19,7 @@ use stereokit_rust::system::{HandJoint, HandSource, Handed, Input, LinePoint, Li use stereokit_rust::util::Color128; use zbus::Connection; -use super::{get_sorted_handlers, CaptureManager}; +use super::{CaptureManager, get_sorted_handlers}; fn convert_joint(joint: HandJoint) -> Joint { Joint { diff --git a/src/objects/mod.rs b/src/objects/mod.rs index 21bc9e4..1fc917f 100644 --- a/src/objects/mod.rs +++ b/src/objects/mod.rs @@ -3,12 +3,12 @@ use crate::{ core::client::INTERNAL_CLIENT, nodes::{ - fields::{Field, Shape, EXPORTED_FIELDS}, - spatial::{Spatial, EXPORTED_SPATIALS}, Node, OwnedNode, + fields::{EXPORTED_FIELDS, Field, Shape}, + spatial::{EXPORTED_SPATIALS, Spatial}, }, }; -use glam::{vec3, Mat4}; +use glam::{Mat4, vec3}; use input::{ eye_pointer::EyePointer, mouse_pointer::MousePointer, sk_controller::SkController, sk_hand::SkHand, @@ -22,7 +22,7 @@ use stereokit_rust::{ system::{Handed, Input, Key, World}, util::Device, }; -use zbus::{interface, object_server::Interface, zvariant::OwnedObjectPath, Connection}; +use zbus::{Connection, interface, object_server::Interface, zvariant::OwnedObjectPath}; pub mod input; pub mod play_space; diff --git a/src/objects/play_space.rs b/src/objects/play_space.rs index 498ceb4..5061311 100644 --- a/src/objects/play_space.rs +++ b/src/objects/play_space.rs @@ -1,5 +1,5 @@ use stereokit_rust::system::World; -use zbus::{interface, Connection, ObjectServer}; +use zbus::{Connection, ObjectServer, interface}; pub struct PlaySpaceBounds; impl PlaySpaceBounds { diff --git a/src/wayland/compositor.rs b/src/wayland/compositor.rs index 5124709..c57d12b 100644 --- a/src/wayland/compositor.rs +++ b/src/wayland/compositor.rs @@ -10,12 +10,12 @@ use crate::{ use parking_lot::Mutex; use rand::Rng; use smithay::{ - backend::renderer::utils::{on_commit_buffer_handler, RendererSurfaceStateUserData}, + backend::renderer::utils::{RendererSurfaceStateUserData, on_commit_buffer_handler}, delegate_compositor, desktop::PopupKind, - reexports::wayland_server::{protocol::wl_surface::WlSurface, Client}, + reexports::wayland_server::{Client, protocol::wl_surface::WlSurface}, wayland::compositor::{ - add_post_commit_hook, CompositorClientState, CompositorHandler, CompositorState, + CompositorClientState, CompositorHandler, CompositorState, add_post_commit_hook, }, }; use std::sync::Arc; diff --git a/src/wayland/data_device.rs b/src/wayland/data_device.rs index f10840e..5af9078 100644 --- a/src/wayland/data_device.rs +++ b/src/wayland/data_device.rs @@ -1,4 +1,5 @@ use smithay::reexports::wayland_server::{ + Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource, protocol::{ wl_data_device::{ Request::{Release, SetSelection, StartDrag}, @@ -13,7 +14,6 @@ use smithay::reexports::wayland_server::{ WlDataSource, }, }, - Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource, }; use super::state::WaylandState; diff --git a/src/wayland/decoration.rs b/src/wayland/decoration.rs index 92be6c5..4074ca2 100644 --- a/src/wayland/decoration.rs +++ b/src/wayland/decoration.rs @@ -13,8 +13,8 @@ use smithay::{ Mode as KdeMode, OrgKdeKwinServerDecoration, }, wayland_server::{ - protocol::wl_surface::WlSurface, Client, DataInit, Dispatch, DisplayHandle, - GlobalDispatch, New, Resource, WEnum, Weak, + Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource, WEnum, Weak, + protocol::wl_surface::WlSurface, }, }, wayland::shell::{self, kde::decoration::KdeDecorationHandler}, diff --git a/src/wayland/drm.rs b/src/wayland/drm.rs index 65a4c3a..8b9a4f3 100644 --- a/src/wayland/drm.rs +++ b/src/wayland/drm.rs @@ -23,8 +23,8 @@ mod generated { use super::state::WaylandState; use smithay::{ backend::allocator::{ - dmabuf::{Dmabuf, DmabufFlags}, Fourcc, Modifier, + dmabuf::{Dmabuf, DmabufFlags}, }, reexports::wayland_server::{ Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource, diff --git a/src/wayland/mod.rs b/src/wayland/mod.rs index af66172..6387df4 100644 --- a/src/wayland/mod.rs +++ b/src/wayland/mod.rs @@ -11,7 +11,7 @@ mod xdg_shell; use self::{state::WaylandState, surface::CORE_SURFACES}; use crate::{core::task, wayland::state::ClientState}; -use color_eyre::eyre::{ensure, Result}; +use color_eyre::eyre::{Result, ensure}; use once_cell::sync::OnceCell; use parking_lot::Mutex; use smithay::backend::allocator::dmabuf::Dmabuf; @@ -19,8 +19,8 @@ use smithay::backend::egl::EGLContext; use smithay::backend::renderer::gles::GlesRenderer; use smithay::backend::renderer::{ImportDma, Renderer}; use smithay::output::Output; -use smithay::reexports::wayland_server::backend::ClientId; use smithay::reexports::wayland_server::DisplayHandle; +use smithay::reexports::wayland_server::backend::ClientId; use smithay::reexports::wayland_server::{Display, ListeningSocket}; use smithay::wayland::dmabuf; use std::ffi::OsStr; diff --git a/src/wayland/seat.rs b/src/wayland/seat.rs index 8463473..bbe3d6a 100644 --- a/src/wayland/seat.rs +++ b/src/wayland/seat.rs @@ -1,7 +1,7 @@ use super::{state::WaylandState, surface::CoreSurface, utils::WlSurfaceExt}; use crate::{ core::task, - nodes::items::panel::{Backend, Geometry, PanelItem, KEYMAPS}, + nodes::items::panel::{Backend, Geometry, KEYMAPS, PanelItem}, }; use mint::Vector2; use parking_lot::Mutex; @@ -11,12 +11,12 @@ use smithay::{ backend::input::{AxisRelativeDirection, ButtonState, KeyState}, delegate_seat, input::{ + Seat, SeatHandler, keyboard::{FilterResult, LedState}, pointer::{AxisFrame, ButtonEvent, CursorImageStatus, MotionEvent}, touch::{self, DownEvent, UpEvent}, - Seat, SeatHandler, }, - reexports::wayland_server::{protocol::wl_surface::WlSurface, Resource, Weak as WlWeak}, + reexports::wayland_server::{Resource, Weak as WlWeak, protocol::wl_surface::WlSurface}, utils::SERIAL_COUNTER, wayland::compositor, }; diff --git a/src/wayland/state.rs b/src/wayland/state.rs index 30f708d..eaf2389 100644 --- a/src/wayland/state.rs +++ b/src/wayland/state.rs @@ -4,13 +4,13 @@ use once_cell::sync::OnceCell; use parking_lot::Mutex; use smithay::{ backend::{ - allocator::{dmabuf::Dmabuf, Fourcc}, + allocator::{Fourcc, dmabuf::Dmabuf}, egl::EGLDevice, renderer::gles::GlesRenderer, }, delegate_dmabuf, delegate_output, delegate_shm, desktop::PopupManager, - input::{keyboard::XkbConfig, SeatState}, + input::{SeatState, keyboard::XkbConfig}, output::{Mode, Output, Scale, Subpixel}, reexports::{ wayland_protocols::xdg::{ @@ -19,12 +19,12 @@ use smithay::{ }, wayland_protocols_misc::server_decoration::server::org_kde_kwin_server_decoration_manager::Mode as DecorationMode, wayland_server::{ + DisplayHandle, backend::{ClientData, ClientId, DisconnectReason}, protocol::{ wl_buffer::WlBuffer, wl_data_device_manager::WlDataDeviceManager, wl_output::WlOutput, }, - DisplayHandle, }, }, utils::{Size, Transform}, diff --git a/src/wayland/surface.rs b/src/wayland/surface.rs index 5044dc8..d8462de 100644 --- a/src/wayland/surface.rs +++ b/src/wayland/surface.rs @@ -14,13 +14,13 @@ use parking_lot::Mutex; use send_wrapper::SendWrapper; use smithay::{ backend::renderer::{ - gles::{GlesRenderer, GlesTexture}, - utils::{import_surface_tree, RendererSurfaceStateUserData}, Renderer, Texture, + gles::{GlesRenderer, GlesTexture}, + utils::{RendererSurfaceStateUserData, import_surface_tree}, }, desktop::utils::send_frames_surface_tree, output::Output, - reexports::wayland_server::{self, protocol::wl_surface::WlSurface, Resource}, + reexports::wayland_server::{self, Resource, protocol::wl_surface::WlSurface}, }; use std::{ffi::c_void, sync::Arc, time::Duration}; use stereokit_rust::{ diff --git a/src/wayland/xdg_shell.rs b/src/wayland/xdg_shell.rs index cdc0151..e50561b 100644 --- a/src/wayland/xdg_shell.rs +++ b/src/wayland/xdg_shell.rs @@ -1,5 +1,5 @@ use super::{ - seat::{handle_cursor, SeatWrapper}, + seat::{SeatWrapper, handle_cursor}, state::{ClientState, WaylandState}, surface::CoreSurface, utils::*, @@ -27,8 +27,8 @@ use smithay::{ shell::server::xdg_toplevel::{ResizeEdge, State}, }, wayland_server::{ - protocol::{wl_output::WlOutput, wl_seat::WlSeat, wl_surface::WlSurface}, Resource, + protocol::{wl_output::WlOutput, wl_seat::WlSeat, wl_surface::WlSurface}, }, }, utils::{Logical, Rectangle, Serial},