diff --git a/app_grid/src/main.rs b/app_grid/src/main.rs index 2d0673b..7ffd585 100644 --- a/app_grid/src/main.rs +++ b/app_grid/src/main.rs @@ -198,7 +198,7 @@ impl App { // } fn frame(&mut self, info: &FrameInfo) { - let _ = self.grabbable.update(&info); + let _ = self.grabbable.update(info); if self.grabbable.grab_action().actor_stopped() { self.grabbable.cancel_angular_velocity(); diff --git a/hexagon_launcher/src/app.rs b/hexagon_launcher/src/app.rs index d2fb62b..ba56304 100644 --- a/hexagon_launcher/src/app.rs +++ b/hexagon_launcher/src/app.rs @@ -190,7 +190,7 @@ impl App { } pub fn frame(&mut self, info: &FrameInfo, state: &State) { - let _ = self.grabbable.update(&info); + let _ = self.grabbable.update(info); if let Some(grabbable_move) = &mut self.grabbable_move { if !grabbable_move.is_finished() { diff --git a/hexagon_launcher/src/hex.rs b/hexagon_launcher/src/hex.rs index b76ed89..b41ace3 100644 --- a/hexagon_launcher/src/hex.rs +++ b/hexagon_launcher/src/hex.rs @@ -1,7 +1,9 @@ +use std::ops::Add; + use crate::{APP_SIZE, PADDING}; use tween::TweenTime; -#[derive(Clone)] +#[derive(Clone, Copy, Debug, Default)] pub struct Hex { q: isize, r: isize, @@ -30,15 +32,18 @@ impl Hex { [x, y, 0.0] } - pub fn add(self, vec: &Hex) -> Self { - Hex::new(self.q + vec.q, self.r + vec.r, self.s + vec.s) - } - pub fn neighbor(self, direction: usize) -> Self { - self.add(&HEX_DIRECTION_VECTORS[direction]) + self + HEX_DIRECTION_VECTORS[direction] } pub fn scale(self, factor: isize) -> Self { Hex::new(self.q * factor, self.r * factor, self.s * factor) } } +impl Add for Hex { + type Output = Hex; + + fn add(self, rhs: Self) -> Self::Output { + Hex::new(self.q + rhs.q, self.r + rhs.r, self.s + rhs.s) + } +} diff --git a/hexagon_launcher/src/main.rs b/hexagon_launcher/src/main.rs index 775fc53..0ae6030 100644 --- a/hexagon_launcher/src/main.rs +++ b/hexagon_launcher/src/main.rs @@ -76,7 +76,7 @@ impl AppHexGrid { let movable_root = Spatial::create(client.get_root(), Transform::identity(), false).unwrap(); - let button = CenterButton::new(client, &client.get_state()).unwrap(); + let button = CenterButton::new(client, client.get_state()).unwrap(); tokio::time::sleep(Duration::from_millis(10)).await; // give it a bit of time to send the messages properly let mut desktop_files: Vec = get_desktop_files() @@ -89,7 +89,7 @@ impl AppHexGrid { let mut apps = Vec::new(); let mut radius = 1; while !desktop_files.is_empty() { - let mut hex = HEX_CENTER.add(&HEX_DIRECTION_VECTORS[4].clone().scale(radius)); + let mut hex = HEX_CENTER + HEX_DIRECTION_VECTORS[4].scale(radius); for i in 0..6 { if desktop_files.is_empty() { break; @@ -187,7 +187,7 @@ impl CenterButton { let grabbable = Grabbable::create( client.get_root(), Transform::none(), - &button.touch_plane().field(), + button.touch_plane().field(), GrabbableSettings { max_distance: 0.025, pointer_mode: PointerMode::Align, @@ -224,7 +224,7 @@ impl CenterButton { } fn frame(&mut self, info: &FrameInfo) { - let _ = self.grabbable.update(&info); + let _ = self.grabbable.update(info); self.button.update(); } } diff --git a/protostar/src/xdg.rs b/protostar/src/xdg.rs index 08f4f96..c2d77c1 100644 --- a/protostar/src/xdg.rs +++ b/protostar/src/xdg.rs @@ -61,8 +61,8 @@ fn get_data_dirs() -> Vec { .split(':') .filter_map(|dir| PathBuf::from_str(dir).ok()) .chain(dirs::home_dir().into_iter().map(|d| d.join(".local/share"))) // $HOME/.local/share - .chain(PathBuf::from_str("/usr/share").into_iter()) // /usr/share - .chain(PathBuf::from_str("/usr/local/share").into_iter()) // /usr/local/share + .chain(PathBuf::from_str("/usr/share")) // /usr/share + .chain(PathBuf::from_str("/usr/local/share")) // /usr/local/share .filter(|dir| dir.exists() && dir.is_dir()) .unique() .collect() @@ -214,9 +214,7 @@ const ICON_SIZES: [u16; 7] = [512, 256, 128, 64, 48, 32, 24]; impl DesktopFile { pub fn get_icon(&self, preferred_px_size: u16) -> Option { // Get the name of the icon from the DesktopFile struct - let Some(icon_name) = self.icon.as_ref() else { - return None; - }; + let icon_name = self.icon.as_ref()?; let test_icon_path = self.path.join(Path::new(icon_name)); if test_icon_path.exists() { if let Some(icon) = Icon::from_path(test_icon_path, preferred_px_size) { diff --git a/sirius/src/main.rs b/sirius/src/main.rs index 88c3358..d3d01cf 100644 --- a/sirius/src/main.rs +++ b/sirius/src/main.rs @@ -374,7 +374,7 @@ impl App { } fn frame(&mut self, info: &FrameInfo) { - let _ = self.grabbable.update(&info); + let _ = self.grabbable.update(info); if let Some(grabbable_move) = &mut self.grabbable_move { if !grabbable_move.is_finished() {