From 5216eb50ba4c73ac3cb6856084d8bd0448be2189 Mon Sep 17 00:00:00 2001 From: Victoria Brekenfeld Date: Fri, 20 Mar 2026 13:40:06 +0100 Subject: [PATCH] chore: Fix remaining clippy lints --- src/backend/kms/mod.rs | 2 +- src/backend/kms/surface/mod.rs | 6 +++-- src/backend/x11.rs | 1 + src/debug.rs | 36 +++++++++++-------------- src/lib.rs | 5 ++++ src/shell/element/mod.rs | 2 +- src/shell/element/window.rs | 2 ++ src/shell/focus/target.rs | 1 + src/shell/grabs/moving.rs | 4 +++ src/shell/layout/tiling/mod.rs | 49 ++++++++++++++++------------------ src/shell/mod.rs | 2 ++ src/shell/workspace.rs | 1 + src/state.rs | 1 + src/utils/geometry.rs | 2 ++ 14 files changed, 64 insertions(+), 50 deletions(-) diff --git a/src/backend/kms/mod.rs b/src/backend/kms/mod.rs index 94964213..eb3a25f1 100644 --- a/src/backend/kms/mod.rs +++ b/src/backend/kms/mod.rs @@ -747,7 +747,7 @@ impl KmsGuard<'_> { .crtcs() .iter() .filter(|crtc| { - device.inner.surfaces.get(crtc).is_none() + !device.inner.surfaces.contains_key(crtc) // TODO: We can't do this. See https://github.com/Smithay/smithay/pull/1820 //.is_some_and(|surface| surface.output.is_enabled()) }) diff --git a/src/backend/kms/surface/mod.rs b/src/backend/kms/surface/mod.rs index 358c5dee..88a70891 100644 --- a/src/backend/kms/surface/mod.rs +++ b/src/backend/kms/surface/mod.rs @@ -511,8 +511,10 @@ fn surface_thread( let egui = { let state = smithay_egui::EguiState::new(smithay::utils::Rectangle::from_size((400, 800).into())); - let mut visuals: egui::style::Visuals = Default::default(); - visuals.window_shadow = egui::Shadow::NONE; + let visuals = egui::style::Visuals { + window_shadow: egui::Shadow::NONE, + ..Default::default() + }; state.context().set_visuals(visuals); state }; diff --git a/src/backend/x11.rs b/src/backend/x11.rs index 6a344b0d..bd0e1b34 100644 --- a/src/backend/x11.rs +++ b/src/backend/x11.rs @@ -44,6 +44,7 @@ use tracing::{debug, error, info, warn}; use super::render::{ScreenFilterStorage, init_shaders}; #[derive(Debug)] +#[allow(clippy::large_enum_variant)] enum Allocator { Gbm(GbmAllocator), Vulkan(PhysicalDevice), diff --git a/src/debug.rs b/src/debug.rs index f167213c..e50596c0 100644 --- a/src/debug.rs +++ b/src/debug.rs @@ -27,7 +27,7 @@ pub const RENDER_COLOR: Color32 = Color32::from_rgb(29, 114, 58); pub const SUBMITTED_COLOR: Color32 = Color32::from_rgb(253, 178, 39); pub const DISPLAY_COLOR: Color32 = Color32::from_rgb(41, 184, 209); -pub fn fps_ui<'a>( +pub fn fps_ui( gpu: Option<&DrmNode>, debug_active: bool, seats: &[Seat], @@ -122,23 +122,19 @@ pub fn fps_ui<'a>( if let Ok(vendor) = std::fs::read_to_string(format!( "/sys/class/drm/renderD{}/device/vendor", gpu.minor() - )) { - if let Some(img) = match vendor.trim() { - "0x10de" => Some(egui::include_image!( - "../resources/icons/nvidia.svg" - )), - "0x1002" => { - Some(egui::include_image!("../resources/icons/amd.svg")) - } - "0x8086" => Some(egui::include_image!( - "../resources/icons/intel.svg" - )), - _ => None, - } { - ui.add( - egui::Image::new(img).max_height(resp.rect.height()), - ); + )) && let Some(img) = match vendor.trim() { + "0x10de" => { + Some(egui::include_image!("../resources/icons/nvidia.svg")) } + "0x1002" => { + Some(egui::include_image!("../resources/icons/amd.svg")) + } + "0x8086" => { + Some(egui::include_image!("../resources/icons/intel.svg")) + } + _ => None, + } { + ui.add(egui::Image::new(img).max_height(resp.rect.height())); } }); } @@ -311,7 +307,7 @@ fn format_pointer_focus(focus: Option) -> String { ), Some(ResizeFork(_)) => String::from("Resize UI"), Some(ZoomUI(_)) => String::from("Zoom UI"), - None => format!("None"), + None => "None".to_string(), } } @@ -348,8 +344,8 @@ fn format_keyboard_focus(focus: Option) -> String { ), Some(LayerSurface(x)) => format!("LayerSurface {}", x.wl_surface().id().protocol_id()), Some(Popup(x)) => format!("Popup {}", x.wl_surface().id().protocol_id()), - Some(Group(_)) => format!("Window Group"), + Some(Group(_)) => "Window Group".to_string(), Some(LockSurface(x)) => format!("LockSurface {}", x.wl_surface().id().protocol_id()), - None => format!("None"), + None => "None".to_string(), } } diff --git a/src/lib.rs b/src/lib.rs index 04d122e2..20c32a29 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,8 @@ +#![allow( + clippy::too_many_arguments, + clippy::type_complexity, + clippy::len_without_is_empty +)] // SPDX-License-Identifier: GPL-3.0-only use calloop::timer::{TimeoutAction, Timer}; diff --git a/src/shell/element/mod.rs b/src/shell/element/mod.rs index bc07c3b8..7c65e23b 100644 --- a/src/shell/element/mod.rs +++ b/src/shell/element/mod.rs @@ -812,7 +812,7 @@ impl CosmicMapped { scale.x, 0.8, ) { - Ok(element) => vec![CosmicMappedRenderElement::from(element).into()], + Ok(element) => vec![CosmicMappedRenderElement::from(element)], Err(err) => { debug!(?err, "Error rendering debug overlay."); Vec::new() diff --git a/src/shell/element/window.rs b/src/shell/element/window.rs index a63e4da3..08343425 100644 --- a/src/shell/element/window.rs +++ b/src/shell/element/window.rs @@ -154,6 +154,8 @@ impl Focus { } } + /// # Safety + /// `value` must be in the range of `Focus` pub unsafe fn from_u8(value: u8) -> Option { match value { 0 => None, diff --git a/src/shell/focus/target.rs b/src/shell/focus/target.rs index 63bf0a56..b1124fcf 100644 --- a/src/shell/focus/target.rs +++ b/src/shell/focus/target.rs @@ -61,6 +61,7 @@ pub enum PointerFocusTarget { } #[derive(Debug, Clone, PartialEq)] +#[allow(clippy::large_enum_variant)] pub enum PointerFocusToplevel { Surface(CosmicSurface), Popup(PopupKind), diff --git a/src/shell/grabs/moving.rs b/src/shell/grabs/moving.rs index ca60a17e..b49bdd84 100644 --- a/src/shell/grabs/moving.rs +++ b/src/shell/grabs/moving.rs @@ -737,6 +737,8 @@ impl MoveGrab { release: ReleaseMode, evlh: LoopHandle<'static, State>, ) -> MoveGrab { + // false-positive: `Output`s hash is based on it's inner ptr + #[allow(clippy::mutable_key_type)] let mut outputs = HashSet::new(); outputs.insert(cursor_output.clone()); window.output_enter(&cursor_output, window.geometry()); // not accurate but... @@ -798,6 +800,8 @@ impl Drop for MoveGrab { // No more buttons are pressed, release the grab. let output = self.cursor_output.clone(); let seat = self.seat.clone(); + // false-positive: `Output`s hash is based on it's inner ptr + #[allow(clippy::mutable_key_type)] let window_outputs = self.window_outputs.drain().collect::>(); let previous = self.previous; let window = self.window.clone(); diff --git a/src/shell/layout/tiling/mod.rs b/src/shell/layout/tiling/mod.rs index b0cad18c..6db8aef2 100644 --- a/src/shell/layout/tiling/mod.rs +++ b/src/shell/layout/tiling/mod.rs @@ -1459,35 +1459,32 @@ impl TilingLayout { let _ = tree.remove_node(node.clone(), RemoveBehavior::DropChildren); // fixup parent node - match parent_id { - Some(id) => { - let position = position.unwrap(); - let group = tree.get_mut(&id).unwrap().data_mut(); - assert!(group.is_group()); + if let Some(id) = parent_id { + let position = position.unwrap(); + let group = tree.get_mut(&id).unwrap().data_mut(); + assert!(group.is_group()); - if group.len() > 2 { - group.remove_window(position); - } else { - trace!("Removing Group"); - let other_child = tree.children_ids(&id).unwrap().next().cloned().unwrap(); - let fork_pos = parent_parent_id.as_ref().and_then(|parent_id| { - tree.children_ids(parent_id).unwrap().position(|i| i == &id) - }); - let _ = tree.remove_node(id.clone(), RemoveBehavior::OrphanChildren); - tree.move_node( - &other_child, - parent_parent_id - .as_ref() - .map(MoveBehavior::ToParent) - .unwrap_or(MoveBehavior::ToRoot), - ) - .unwrap(); - if let Some(old_pos) = fork_pos { - tree.make_nth_sibling(&other_child, old_pos).unwrap(); - } + if group.len() > 2 { + group.remove_window(position); + } else { + trace!("Removing Group"); + let other_child = tree.children_ids(&id).unwrap().next().cloned().unwrap(); + let fork_pos = parent_parent_id.as_ref().and_then(|parent_id| { + tree.children_ids(parent_id).unwrap().position(|i| i == &id) + }); + let _ = tree.remove_node(id.clone(), RemoveBehavior::OrphanChildren); + tree.move_node( + &other_child, + parent_parent_id + .as_ref() + .map(MoveBehavior::ToParent) + .unwrap_or(MoveBehavior::ToRoot), + ) + .unwrap(); + if let Some(old_pos) = fork_pos { + tree.make_nth_sibling(&other_child, old_pos).unwrap(); } } - None => {} // root } } diff --git a/src/shell/mod.rs b/src/shell/mod.rs index f58f4f9a..85dbbd95 100644 --- a/src/shell/mod.rs +++ b/src/shell/mod.rs @@ -1186,6 +1186,8 @@ impl Workspaces { let len = self.sets[0].workspaces.len(); let mut active = self.sets[0].active; let mut keep = vec![true; len]; + // false-positive: we iterate over multiple sets + #[allow(clippy::needless_range_loop)] for i in 0..len { let has_windows = self .sets diff --git a/src/shell/workspace.rs b/src/shell/workspace.rs index bbff088d..30c49493 100644 --- a/src/shell/workspace.rs +++ b/src/shell/workspace.rs @@ -319,6 +319,7 @@ pub struct FullscreenRestoreData { } #[derive(Debug, Clone, PartialEq)] +#[allow(clippy::large_enum_variant)] pub enum FocusResult { None, Handled, diff --git a/src/state.rs b/src/state.rs index 1dc86008..81e16e4e 100644 --- a/src/state.rs +++ b/src/state.rs @@ -300,6 +300,7 @@ pub struct Common { } #[derive(Debug)] +#[allow(clippy::large_enum_variant)] pub enum BackendData { X11(X11State), Winit(WinitState), diff --git a/src/utils/geometry.rs b/src/utils/geometry.rs index 0ac53d18..c86427e7 100644 --- a/src/utils/geometry.rs +++ b/src/utils/geometry.rs @@ -1,3 +1,5 @@ +#![allow(clippy::wrong_self_convention)] + use std::sync::Mutex; use smithay::{