diff --git a/wgui/src/layout.rs b/wgui/src/layout.rs index b6aed2b..861c038 100644 --- a/wgui/src/layout.rs +++ b/wgui/src/layout.rs @@ -256,7 +256,7 @@ impl Layout { if self.tree.dirty(self.root_node)? || self.prev_size != size { self.needs_redraw = true; - println!("re-computing layout, size {}x{}", size.x, size.y); + log::debug!("re-computing layout, size {}x{}", size.x, size.y); self.prev_size = size; self.tree.compute_layout_with_measure( self.root_node, @@ -316,4 +316,4 @@ impl Layout { }; widget.lock().unwrap().add_event_listener(listener); } -} \ No newline at end of file +} diff --git a/wlx-overlay-s/src/backend/notifications.rs b/wlx-overlay-s/src/backend/notifications.rs index 203e5f6..d7ee9e6 100644 --- a/wlx-overlay-s/src/backend/notifications.rs +++ b/wlx-overlay-s/src/backend/notifications.rs @@ -7,8 +7,9 @@ use dbus::{ use serde::Deserialize; use std::{ sync::{ + Arc, atomic::{AtomicBool, Ordering}, - mpsc, Arc, + mpsc, }, time::Duration, }; @@ -172,7 +173,7 @@ impl NotificationManager { let toast = Toast::new( ToastTopic::XSNotification, msg.title, - msg.content.unwrap_or_else(|| "".into()), + msg.content.unwrap_or(String::new()), ) .with_timeout(msg.timeout.unwrap_or(5.)) .with_sound(msg.volume.unwrap_or(-1.) >= 0.); // XSOverlay still plays at 0, @@ -264,11 +265,9 @@ fn parse_dbus(msg: &dbus::Message) -> anyhow::Result { summary }; - Ok( - Toast::new(ToastTopic::DesktopNotification, title.into(), body.into()) - .with_timeout(5.0) - .with_opacity(1.0), - ) + Ok(Toast::new(ToastTopic::DesktopNotification, title, body) + .with_timeout(5.0) + .with_opacity(1.0)) // leave the audio part to the desktop env } diff --git a/wlx-overlay-s/src/backend/openvr/mod.rs b/wlx-overlay-s/src/backend/openvr/mod.rs index 9e9779c..a47a815 100644 --- a/wlx-overlay-s/src/backend/openvr/mod.rs +++ b/wlx-overlay-s/src/backend/openvr/mod.rs @@ -2,18 +2,18 @@ use std::{ collections::VecDeque, ops::Add, sync::{ - atomic::{AtomicBool, AtomicUsize, Ordering}, Arc, + atomic::{AtomicBool, AtomicUsize, Ordering}, }, time::{Duration, Instant}, }; -use anyhow::{anyhow, Result}; +use anyhow::{Result, anyhow}; use ovr_overlay::{ - sys::{ETrackedDeviceProperty, EVRApplicationType, EVREventType}, TrackedDeviceIndex, + sys::{ETrackedDeviceProperty, EVRApplicationType, EVREventType}, }; -use vulkano::{device::physical::PhysicalDevice, Handle, VulkanObject}; +use vulkano::{Handle, VulkanObject, device::physical::PhysicalDevice}; use crate::{ backend::{ @@ -22,7 +22,7 @@ use crate::{ notifications::NotificationManager, openvr::{ helpers::adjust_gain, - input::{set_action_manifest, OpenVrInputSource}, + input::{OpenVrInputSource, set_action_manifest}, lines::LinePool, manifest::{install_manifest, uninstall_manifest}, overlay::OpenVrOverlayData, @@ -30,10 +30,10 @@ use crate::{ overlay::{OverlayData, ShouldRender}, task::{SystemTask, TaskType}, }, - graphics::{init_openvr_graphics, CommandBuffers}, + graphics::{CommandBuffers, init_openvr_graphics}, overlays::{ toast::{Toast, ToastTopic}, - watch::{watch_fade, WATCH_NAME}, + watch::{WATCH_NAME, watch_fade}, }, state::AppState, }; @@ -185,12 +185,8 @@ pub fn openvr_run( let ipd = (ipd * 10000.0).round() * 0.1; if (ipd - state.input_state.ipd).abs() > 0.05 { log::info!("IPD: {:.1} mm -> {:.1} mm", state.input_state.ipd, ipd); - Toast::new( - ToastTopic::IpdChange, - "IPD".into(), - format!("{ipd:.1} mm").into(), - ) - .submit(&mut state); + Toast::new(ToastTopic::IpdChange, "IPD".into(), format!("{ipd:.1} mm")) + .submit(&mut state); } state.input_state.ipd = ipd; } diff --git a/wlx-overlay-s/src/backend/openxr/mod.rs b/wlx-overlay-s/src/backend/openxr/mod.rs index 01e411e..adb4476 100644 --- a/wlx-overlay-s/src/backend/openxr/mod.rs +++ b/wlx-overlay-s/src/backend/openxr/mod.rs @@ -330,12 +330,8 @@ pub fn openxr_run( if (app.input_state.ipd - ipd).abs() > 0.01 { log::info!("IPD changed: {} -> {}", app.input_state.ipd, ipd); app.input_state.ipd = ipd; - Toast::new( - ToastTopic::IpdChange, - "IPD".into(), - format!("{ipd:.1} mm").into(), - ) - .submit(&mut app); + Toast::new(ToastTopic::IpdChange, "IPD".into(), format!("{ipd:.1} mm")) + .submit(&mut app); } overlays diff --git a/wlx-overlay-s/src/backend/wayvr/server_ipc.rs b/wlx-overlay-s/src/backend/wayvr/server_ipc.rs index 2e54529..e5e28aa 100644 --- a/wlx-overlay-s/src/backend/wayvr/server_ipc.rs +++ b/wlx-overlay-s/src/backend/wayvr/server_ipc.rs @@ -1,9 +1,9 @@ use crate::state::AppState; -use super::{display, process, window, TickTask, WayVRSignal}; +use super::{TickTask, WayVRSignal, display, process, window}; use bytes::BufMut; use glam::Vec3A; -use interprocess::local_socket::{self, traits::Listener, ToNsName}; +use interprocess::local_socket::{self, ToNsName, traits::Listener}; use smallvec::SmallVec; use std::io::{Read, Write}; use wayvr_ipc::{ @@ -81,11 +81,10 @@ pub fn gen_args_vec(input: &str) -> Vec<&str> { } pub fn gen_env_vec(input: &[String]) -> Vec<(&str, &str)> { - let res = input + input .iter() .filter_map(|e| e.as_str().split_once('=')) - .collect(); - res + .collect() } impl Connection { diff --git a/wlx-overlay-s/src/gui/panel.rs b/wlx-overlay-s/src/gui/panel.rs index d52dc2a..bb60fee 100644 --- a/wlx-overlay-s/src/gui/panel.rs +++ b/wlx-overlay-s/src/gui/panel.rs @@ -23,18 +23,18 @@ pub struct GuiPanel { pub layout: Layout, context: WguiContext, timestep: Timestep, - pub width: u32, - pub height: u32, + pub max_width: u32, + pub max_height: u32, } impl GuiPanel { pub fn new_from_template( app: &AppState, - width: u32, - height: u32, + max_width: u32, + max_height: u32, path: &str, ) -> anyhow::Result { - let mut me = Self::new_blank(app, width, height)?; + let mut me = Self::new_blank(app, max_width, max_height)?; let parent = me.layout.root_widget; let _res = wgui::parser::parse_from_assets(&mut me.layout, parent, path)?; @@ -42,7 +42,7 @@ impl GuiPanel { Ok(me) } - pub fn new_blank(app: &AppState, width: u32, height: u32) -> anyhow::Result { + pub fn new_blank(app: &AppState, max_width: u32, max_height: u32) -> anyhow::Result { let layout = Layout::new(Box::new(GuiAsset {}))?; let context = WguiContext::new(app.gfx.clone(), app.gfx.surface_format, 1.0)?; let mut timestep = Timestep::new(); @@ -52,8 +52,8 @@ impl GuiPanel { layout, context, timestep, - width, - height, + max_width, + max_height, }) } } @@ -74,7 +74,7 @@ impl InteractionHandler for GuiPanel { shift: vec2(delta_x, delta_y), pos: hit.uv, })) - .unwrap() + .unwrap(); } fn on_hover(&mut self, _app: &mut AppState, hit: &PointerHit) -> Option { @@ -154,7 +154,7 @@ impl OverlayRenderer for GuiPanel { fn frame_meta(&mut self) -> Option { Some(FrameMeta { - extent: [self.width, self.height, 1], + extent: [self.max_width, self.max_height, 1], ..Default::default() }) } diff --git a/wlx-overlay-s/src/gui/timestep.rs b/wlx-overlay-s/src/gui/timestep.rs index 0be34f6..a1bf49e 100644 --- a/wlx-overlay-s/src/gui/timestep.rs +++ b/wlx-overlay-s/src/gui/timestep.rs @@ -18,8 +18,8 @@ pub struct Timestep { } impl Timestep { - pub fn new() -> Timestep { - let mut timestep = Timestep { + pub fn new() -> Self { + let mut timestep = Self { speed: 1.0, ..Default::default() }; diff --git a/wlx-overlay-s/src/main.rs b/wlx-overlay-s/src/main.rs index 041ac52..c2246c6 100644 --- a/wlx-overlay-s/src/main.rs +++ b/wlx-overlay-s/src/main.rs @@ -29,8 +29,8 @@ mod config_wayvr; use std::{ path::PathBuf, sync::{ - atomic::{AtomicBool, Ordering}, Arc, + atomic::{AtomicBool, Ordering}, }, }; @@ -38,7 +38,7 @@ use backend::notifications::DbusNotificationSender; use clap::Parser; use sysinfo::Pid; use tracing::level_filters::LevelFilter; -use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter}; +use tracing_subscriber::{EnvFilter, layer::SubscriberExt, util::SubscriberInitExt}; /// The lightweight desktop overlay for OpenVR and OpenXR #[derive(Default, Parser, Debug)] @@ -126,7 +126,7 @@ fn main() -> Result<(), Box> { Ok(()) } -#[allow(unused_mut)] +#[allow(unused_mut, clippy::similar_names)] fn auto_run(running: Arc, args: Args) { use backend::common::BackendError; diff --git a/wlx-overlay-s/src/overlays/toast.rs b/wlx-overlay-s/src/overlays/toast.rs index da50cb9..e178a1e 100644 --- a/wlx-overlay-s/src/overlays/toast.rs +++ b/wlx-overlay-s/src/overlays/toast.rs @@ -5,7 +5,7 @@ use std::{ time::Instant, }; -use glam::{vec3a, Quat}; +use glam::{Quat, vec3a}; use idmap_derive::IntegerId; use serde::{Deserialize, Serialize}; use wgui::{ @@ -232,7 +232,7 @@ fn new_toast(toast: Toast, app: &mut AppState) -> Option<(OverlayState, Box