fix: clippy
This commit is contained in:
@@ -142,11 +142,8 @@ impl Client {
|
||||
let client = client.clone();
|
||||
async move {
|
||||
loop {
|
||||
match messenger_rx.dispatch(&*scenegraph).await {
|
||||
Err(e) => {
|
||||
client.disconnect(Err(e.into()));
|
||||
}
|
||||
_ => (),
|
||||
if let Err(e) = messenger_rx.dispatch(&*scenegraph).await {
|
||||
client.disconnect(Err(e.into()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -160,11 +157,8 @@ impl Client {
|
||||
let client = client.clone();
|
||||
async move {
|
||||
loop {
|
||||
match messenger_tx.flush().await {
|
||||
Err(e) => {
|
||||
client.disconnect(Err(e.into()));
|
||||
}
|
||||
_ => (),
|
||||
if let Err(e) = messenger_tx.flush().await {
|
||||
client.disconnect(Err(e.into()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,11 +65,11 @@ impl ClientStateParsed {
|
||||
let file_string = std::fs::read_to_string(file).ok()?;
|
||||
toml::from_str(&file_string).ok()
|
||||
}
|
||||
pub fn to_file(self, directory: &Path) {
|
||||
pub fn to_file(&self, directory: &Path) {
|
||||
let app_name = self
|
||||
.launch_info
|
||||
.as_ref()
|
||||
.map(|l| l.cmdline.get(0).unwrap().split('/').last().unwrap())
|
||||
.map(|l| l.cmdline.first().unwrap().split('/').last().unwrap())
|
||||
.unwrap_or("unknown");
|
||||
let state_file_path = directory
|
||||
.join(format!("{app_name}-{}", nanoid::nanoid!()))
|
||||
|
||||
@@ -3,9 +3,11 @@ use parking_lot::Mutex;
|
||||
use std::any::Any;
|
||||
use tokio::sync::mpsc::{self, unbounded_channel};
|
||||
|
||||
type Anything = Box<dyn Any + Send + Sync>;
|
||||
|
||||
static MAIN_DESTROY_QUEUE: Lazy<(
|
||||
mpsc::UnboundedSender<Box<dyn Any + Send + Sync>>,
|
||||
Mutex<mpsc::UnboundedReceiver<Box<dyn Any + Send + Sync>>>,
|
||||
mpsc::UnboundedSender<Anything>,
|
||||
Mutex<mpsc::UnboundedReceiver<Anything>>,
|
||||
)> = Lazy::new(|| {
|
||||
let (tx, rx) = unbounded_channel();
|
||||
(tx, Mutex::new(rx))
|
||||
|
||||
@@ -14,7 +14,7 @@ impl<T: Send + Sync + ?Sized> Registry<T> {
|
||||
}
|
||||
fn lock(&self) -> MappedMutexGuard<FxHashMap<usize, Weak<T>>> {
|
||||
MutexGuard::map(self.0.lock(), |r| {
|
||||
r.get_or_insert_with(|| FxHashMap::default())
|
||||
r.get_or_insert_with(FxHashMap::default)
|
||||
})
|
||||
}
|
||||
pub fn add(&self, t: T) -> Arc<T>
|
||||
@@ -63,7 +63,7 @@ impl<T: Send + Sync + ?Sized> Registry<T> {
|
||||
.collect()
|
||||
}
|
||||
pub fn set(&self, other: &Registry<T>) {
|
||||
*self.lock() = other.lock().clone();
|
||||
self.lock().clone_from(&other.lock());
|
||||
}
|
||||
pub fn take_valid_contents(&self) -> Vec<Arc<T>> {
|
||||
self.0
|
||||
@@ -119,7 +119,7 @@ impl<T: Send + Sync + ?Sized> OwnedRegistry<T> {
|
||||
}
|
||||
fn lock(&self) -> MappedMutexGuard<FxHashMap<usize, Arc<T>>> {
|
||||
MutexGuard::map(self.0.lock(), |r| {
|
||||
r.get_or_insert_with(|| FxHashMap::default())
|
||||
r.get_or_insert_with(FxHashMap::default)
|
||||
})
|
||||
}
|
||||
pub fn add(&self, t: T) -> Arc<T>
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
use stardust_xr::values::ResourceID;
|
||||
use std::{ffi::OsStr, path::PathBuf};
|
||||
use std::{
|
||||
ffi::OsStr,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
use super::client::Client;
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
static ref THEMES: Vec<PathBuf> = std::env::var("STARDUST_THEMES").map(|s| s.split(":").map(PathBuf::from).collect()).unwrap_or_default();
|
||||
static ref THEMES: Vec<PathBuf> = std::env::var("STARDUST_THEMES").map(|s| s.split(':').map(PathBuf::from).collect()).unwrap_or_default();
|
||||
}
|
||||
|
||||
fn has_extension(path: &PathBuf, extensions: &[&OsStr]) -> bool {
|
||||
fn has_extension(path: &Path, extensions: &[&OsStr]) -> bool {
|
||||
if let Some(path_extension) = path.extension() {
|
||||
extensions.contains(&path_extension)
|
||||
} else {
|
||||
|
||||
@@ -47,7 +47,8 @@ impl Scenegraph {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct MethodResponseSender(oneshot::Sender<Result<(Vec<u8>, Vec<OwnedFd>), ScenegraphError>>);
|
||||
pub type MethodResponse = Result<(Vec<u8>, Vec<OwnedFd>), ScenegraphError>;
|
||||
pub struct MethodResponseSender(oneshot::Sender<MethodResponse>);
|
||||
impl MethodResponseSender {
|
||||
pub fn send(self, t: Result<Message, ScenegraphError>) {
|
||||
let _ = self.0.send(t.map(|m| (m.data, m.fds)));
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#![allow(clippy::empty_docs)]
|
||||
mod core;
|
||||
mod nodes;
|
||||
mod objects;
|
||||
@@ -399,7 +400,7 @@ fn run_client(
|
||||
#[cfg(feature = "wayland")]
|
||||
{
|
||||
if let Some(wayland_socket) = wayland.socket_name.as_ref() {
|
||||
command.env("WAYLAND_DISPLAY", &wayland_socket);
|
||||
command.env("WAYLAND_DISPLAY", wayland_socket);
|
||||
}
|
||||
command.env(
|
||||
"DISPLAY",
|
||||
@@ -429,7 +430,7 @@ async fn save_session(project_dirs: &ProjectDirs) {
|
||||
local_set.spawn_local(async move {
|
||||
tokio::select! {
|
||||
biased;
|
||||
s = client.save_state() => {s.map(|s| s.to_file(&session_dir));},
|
||||
s = client.save_state() => {if let Some(s) = s { s.to_file(&session_dir) }},
|
||||
_ = tokio::time::sleep(Duration::from_millis(100)) => (),
|
||||
}
|
||||
});
|
||||
|
||||
@@ -59,7 +59,7 @@ impl Alias {
|
||||
|
||||
fn add_to(new_node: &Arc<Node>, original: &Arc<Node>, info: AliasInfo) -> Result<()> {
|
||||
let alias = Alias {
|
||||
node: Arc::downgrade(&new_node),
|
||||
node: Arc::downgrade(new_node),
|
||||
original: Arc::downgrade(original),
|
||||
info,
|
||||
};
|
||||
|
||||
@@ -36,7 +36,7 @@ pub fn mask_matches(mask_map_lesser: &Datamap, mask_map_greater: &Datamap) -> bo
|
||||
let greater_key = get_mask(mask_map_greater)?.index(key)?;
|
||||
// otherwise zero-length vectors don't count the same as a single type vector
|
||||
if lesser_key.flexbuffer_type().is_heterogenous_vector()
|
||||
&& lesser_key.as_vector().len() == 0
|
||||
&& lesser_key.as_vector().is_empty()
|
||||
&& greater_key.flexbuffer_type().is_vector()
|
||||
{
|
||||
continue;
|
||||
|
||||
@@ -76,7 +76,7 @@ impl Lines {
|
||||
thickness: (first.thickness + last.thickness) * 0.5,
|
||||
color: color.into(),
|
||||
};
|
||||
points.push_front(connect_point.clone());
|
||||
points.push_front(connect_point);
|
||||
points.push_back(connect_point);
|
||||
}
|
||||
stereokit_rust::system::Lines::add_list(token, points.make_contiguous());
|
||||
|
||||
@@ -26,12 +26,12 @@ pub fn draw(token: &MainThreadToken) {
|
||||
text::draw_all(token);
|
||||
|
||||
if let Some(skytex) = QUEUED_SKYTEX.lock().take() {
|
||||
if let Ok(skytex) = SHCubemap::from_cubemap_equirectangular(&skytex, true, 100) {
|
||||
if let Ok(skytex) = SHCubemap::from_cubemap_equirectangular(skytex, true, 100) {
|
||||
Renderer::skytex(skytex.tex);
|
||||
}
|
||||
}
|
||||
if let Some(skylight) = QUEUED_SKYLIGHT.lock().take() {
|
||||
if let Ok(skylight) = SHCubemap::from_cubemap_equirectangular(&skylight, true, 100) {
|
||||
if let Ok(skylight) = SHCubemap::from_cubemap_equirectangular(skylight, true, 100) {
|
||||
Renderer::skylight(skylight.sh);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ impl MaterialParameter {
|
||||
}
|
||||
MaterialParameter::Texture(resource) => {
|
||||
let Some(texture_path) =
|
||||
get_resource_file(&resource, &client, &[OsStr::new("png"), OsStr::new("jpg")])
|
||||
get_resource_file(resource, client, &[OsStr::new("png"), OsStr::new("jpg")])
|
||||
else {
|
||||
return;
|
||||
};
|
||||
|
||||
@@ -3,8 +3,7 @@ use smithay::backend::renderer::gles::{
|
||||
ffi::{self, Gles2, FRAGMENT_SHADER, VERTEX_SHADER},
|
||||
GlesError,
|
||||
};
|
||||
use std::mem::transmute;
|
||||
use stereokit_rust::shader::Shader;
|
||||
use stereokit_rust::shader::{Shader, _ShaderT};
|
||||
use tracing::error;
|
||||
|
||||
// Simula shader with fancy lanzcos sampling
|
||||
@@ -133,7 +132,7 @@ pub unsafe fn shader_inject(
|
||||
let gl_frag = compile_shader(c, FRAGMENT_SHADER, frag_str)?;
|
||||
let gl_prog = link_program(c, gl_vert, gl_frag)?;
|
||||
|
||||
let shader: *mut FfiShader = transmute(sk_shader.0.as_mut());
|
||||
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;
|
||||
|
||||
@@ -46,7 +46,7 @@ impl Text {
|
||||
let text = TEXT_REGISTRY.add(Text {
|
||||
space: node.get_aspect::<Spatial>().unwrap().clone(),
|
||||
font_path: style.font.as_ref().and_then(|res| {
|
||||
get_resource_file(&res, &client, &[OsStr::new("ttf"), OsStr::new("otf")])
|
||||
get_resource_file(res, &client, &[OsStr::new("ttf"), OsStr::new("otf")])
|
||||
}),
|
||||
style: OnceCell::new(),
|
||||
|
||||
@@ -93,7 +93,7 @@ impl Text {
|
||||
super::TextFit::Exact => TextFit::Exact,
|
||||
super::TextFit::Overflow => TextFit::Overflow,
|
||||
},
|
||||
Some(style.clone()),
|
||||
Some(*style),
|
||||
Some(Color128::new(
|
||||
data.color.c.r,
|
||||
data.color.c.g,
|
||||
|
||||
@@ -54,7 +54,7 @@ impl BoxFieldAspect for BoxField {
|
||||
let Field::Box(this_field) = &*this_field else {
|
||||
return Ok(());
|
||||
};
|
||||
this_field.set_size(size.into());
|
||||
this_field.set_size(size);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,9 +161,7 @@ pub fn process_input() {
|
||||
// Iterate over the distance links and send input to them
|
||||
for (i, input_link) in input_links.into_iter().enumerate() {
|
||||
let handler = input_link.handler.spatial.node().unwrap();
|
||||
if !handler_input.contains_key(&handler.id) {
|
||||
handler_input.insert(handler.id, (handler.clone(), Vec::new(), Vec::new()));
|
||||
}
|
||||
handler_input.entry(handler.id).or_insert_with(|| (handler.clone(), Vec::new(), Vec::new()));
|
||||
let (_, methods, datas) = handler_input.get_mut(&handler.id).unwrap();
|
||||
|
||||
let method_alias = input_link
|
||||
|
||||
@@ -140,7 +140,7 @@ impl CameraItem {
|
||||
let sk_mat = self
|
||||
.sk_mat
|
||||
.get_or_try_init(|| -> Result<Arc<MaterialWrapper>> {
|
||||
let shader = Shader::from_memory(&UNLIT_SHADER_BYTES)?;
|
||||
let shader = Shader::from_memory(UNLIT_SHADER_BYTES)?;
|
||||
let mut mat = Material::new(&shader, None);
|
||||
mat.get_all_param_info().set_texture("diffuse", &sk_tex.0);
|
||||
mat.transparency(Transparency::Blend);
|
||||
|
||||
@@ -35,7 +35,7 @@ fn release(item: &Item) {
|
||||
*captured_acceptor = Weak::default();
|
||||
acceptor.handle_release(item);
|
||||
if let Some(ui) = item.type_info.ui.lock().upgrade() {
|
||||
ui.handle_release_item(item, &acceptor);
|
||||
ui.handle_release_item(item, acceptor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ use stereokit_rust::maths::Bounds;
|
||||
|
||||
stardust_xr_server_codegen::codegen_spatial_protocol!();
|
||||
impl Transform {
|
||||
pub fn to_mat4(self, position: bool, rotation: bool, scale: bool) -> Mat4 {
|
||||
pub fn to_mat4(&self, position: bool, rotation: bool, scale: bool) -> Mat4 {
|
||||
let position = position
|
||||
.then_some(self.translation)
|
||||
.flatten()
|
||||
@@ -184,7 +184,7 @@ impl Spatial {
|
||||
}
|
||||
fn set_parent(self: &Arc<Self>, new_parent: Option<&Arc<Spatial>>) {
|
||||
if let Some(parent) = self.get_parent() {
|
||||
parent.children.remove(&self);
|
||||
parent.children.remove(self);
|
||||
}
|
||||
if let Some(new_parent) = &new_parent {
|
||||
new_parent.children.add_raw(self);
|
||||
@@ -218,7 +218,7 @@ impl Spatial {
|
||||
}
|
||||
|
||||
self.set_local_transform(Spatial::space_to_space_matrix(
|
||||
Some(&self),
|
||||
Some(self),
|
||||
parent.map(AsRef::as_ref),
|
||||
));
|
||||
self.set_parent(parent);
|
||||
|
||||
@@ -47,7 +47,7 @@ impl EyePointer {
|
||||
pub fn update(&self) {
|
||||
let ray = Input::get_eyes();
|
||||
self.spatial.set_local_transform(
|
||||
Mat4::from_rotation_translation(ray.orientation.into(), ray.position.into()).into(),
|
||||
Mat4::from_rotation_translation(ray.orientation.into(), ray.position.into()),
|
||||
);
|
||||
{
|
||||
// Set pointer input datamap
|
||||
|
||||
@@ -157,7 +157,7 @@ impl MousePointer {
|
||||
.pointer
|
||||
.capture_requests
|
||||
.get_valid_contents()
|
||||
.contains(&capture)
|
||||
.contains(capture)
|
||||
{
|
||||
self.capture.take();
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ impl SkController {
|
||||
.input
|
||||
.capture_requests
|
||||
.get_valid_contents()
|
||||
.contains(&capture)
|
||||
.contains(capture)
|
||||
{
|
||||
self.capture.take();
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ impl SkHand {
|
||||
.input
|
||||
.capture_requests
|
||||
.get_valid_contents()
|
||||
.contains(&capture)
|
||||
.contains(capture)
|
||||
{
|
||||
self.capture.take();
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ impl PlaySpace {
|
||||
pub fn update(&self) {
|
||||
let pose = World::get_bounds_pose();
|
||||
self.spatial.set_local_transform(
|
||||
Mat4::from_rotation_translation(pose.orientation.into(), pose.position.into()).into(),
|
||||
Mat4::from_rotation_translation(pose.orientation.into(), pose.position.into()),
|
||||
);
|
||||
let Field::Box(box_field) = self.field.as_ref() else {
|
||||
return;
|
||||
|
||||
@@ -165,7 +165,7 @@ impl Wayland {
|
||||
let dh1 = display.handle();
|
||||
let mut dh2 = dh1.clone();
|
||||
|
||||
Ok(task::new(|| "wayland loop", async move {
|
||||
task::new(|| "wayland loop", async move {
|
||||
let _socket = socket; // Keep the socket alive
|
||||
loop {
|
||||
tokio::select! {
|
||||
@@ -191,7 +191,7 @@ impl Wayland {
|
||||
}
|
||||
}
|
||||
}
|
||||
})?)
|
||||
})
|
||||
}
|
||||
|
||||
#[instrument(level = "debug", name = "Wayland frame", skip(self))]
|
||||
|
||||
@@ -239,7 +239,7 @@ impl SeatWrapper {
|
||||
for key in keys {
|
||||
keyboard.input(
|
||||
&mut state.lock(),
|
||||
key.abs() as u32,
|
||||
key.unsigned_abs(),
|
||||
if key > 0 {
|
||||
KeyState::Pressed
|
||||
} else {
|
||||
|
||||
@@ -107,7 +107,7 @@ impl CoreSurface {
|
||||
)))
|
||||
});
|
||||
self.sk_mat.get_or_init(|| {
|
||||
let shader = Shader::from_memory(&PANEL_SHADER_BYTES).unwrap();
|
||||
let shader = Shader::from_memory(PANEL_SHADER_BYTES).unwrap();
|
||||
// let _ = renderer.with_context(|c| unsafe {
|
||||
// shader_inject(c, &mut shader, SIMULA_VERT_STR, SIMULA_FRAG_STR)
|
||||
// });
|
||||
|
||||
@@ -100,7 +100,7 @@ impl XdgShellHandler for WaylandState {
|
||||
toplevel.clone(),
|
||||
client_state.seat.clone(),
|
||||
)),
|
||||
client_state.pid.clone(),
|
||||
client_state.pid,
|
||||
);
|
||||
handle_cursor(&panel_item, panel_item.backend.seat.cursor_info_rx.clone());
|
||||
utils::insert_data(toplevel.wl_surface(), Arc::downgrade(&panel_item));
|
||||
@@ -430,14 +430,13 @@ impl Backend for XdgBackend {
|
||||
.clone()
|
||||
});
|
||||
let toplevel_cached_state = compositor::with_states(toplevel.wl_surface(), |states| {
|
||||
states.cached_state.current::<SurfaceCachedState>().clone()
|
||||
*states.cached_state.current::<SurfaceCachedState>()
|
||||
});
|
||||
let toplevel_core_surface = CoreSurface::from_wl_surface(toplevel.wl_surface()).unwrap();
|
||||
|
||||
let size = toplevel
|
||||
.current_state()
|
||||
.size
|
||||
.clone()
|
||||
.map(|s| Vector2::from([s.w as u32, s.h as u32]))
|
||||
.or_else(|| toplevel_core_surface.size())
|
||||
.unwrap_or(Vector2::from([0; 2]));
|
||||
@@ -571,7 +570,7 @@ impl Backend for XdgBackend {
|
||||
}
|
||||
|
||||
fn pointer_motion(&self, surface: &SurfaceId, position: Vector2<f32>) {
|
||||
let Some(surface) = self.wl_surface_from_id(&surface) else {
|
||||
let Some(surface) = self.wl_surface_from_id(surface) else {
|
||||
return;
|
||||
};
|
||||
self.seat.pointer_motion(surface, position)
|
||||
@@ -589,14 +588,14 @@ impl Backend for XdgBackend {
|
||||
}
|
||||
|
||||
fn keyboard_keys(&self, surface: &SurfaceId, keymap_id: u64, keys: Vec<i32>) {
|
||||
let Some(surface) = self.wl_surface_from_id(&surface) else {
|
||||
let Some(surface) = self.wl_surface_from_id(surface) else {
|
||||
return;
|
||||
};
|
||||
self.seat.keyboard_keys(surface, keymap_id, keys)
|
||||
}
|
||||
|
||||
fn touch_down(&self, surface: &SurfaceId, id: u32, position: Vector2<f32>) {
|
||||
let Some(surface) = self.wl_surface_from_id(&surface) else {
|
||||
let Some(surface) = self.wl_surface_from_id(surface) else {
|
||||
return;
|
||||
};
|
||||
self.seat.touch_down(surface, id, position)
|
||||
|
||||
Reference in New Issue
Block a user