chore: Fix remaining clippy lints

This commit is contained in:
Victoria Brekenfeld 2026-03-20 13:40:06 +01:00 committed by Victoria Brekenfeld
parent 0a016991a4
commit 5216eb50ba
14 changed files with 64 additions and 50 deletions

View file

@ -747,7 +747,7 @@ impl KmsGuard<'_> {
.crtcs() .crtcs()
.iter() .iter()
.filter(|crtc| { .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 // TODO: We can't do this. See https://github.com/Smithay/smithay/pull/1820
//.is_some_and(|surface| surface.output.is_enabled()) //.is_some_and(|surface| surface.output.is_enabled())
}) })

View file

@ -511,8 +511,10 @@ fn surface_thread(
let egui = { let egui = {
let state = let state =
smithay_egui::EguiState::new(smithay::utils::Rectangle::from_size((400, 800).into())); smithay_egui::EguiState::new(smithay::utils::Rectangle::from_size((400, 800).into()));
let mut visuals: egui::style::Visuals = Default::default(); let visuals = egui::style::Visuals {
visuals.window_shadow = egui::Shadow::NONE; window_shadow: egui::Shadow::NONE,
..Default::default()
};
state.context().set_visuals(visuals); state.context().set_visuals(visuals);
state state
}; };

View file

@ -44,6 +44,7 @@ use tracing::{debug, error, info, warn};
use super::render::{ScreenFilterStorage, init_shaders}; use super::render::{ScreenFilterStorage, init_shaders};
#[derive(Debug)] #[derive(Debug)]
#[allow(clippy::large_enum_variant)]
enum Allocator { enum Allocator {
Gbm(GbmAllocator<DrmDeviceFd>), Gbm(GbmAllocator<DrmDeviceFd>),
Vulkan(PhysicalDevice), Vulkan(PhysicalDevice),

View file

@ -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 SUBMITTED_COLOR: Color32 = Color32::from_rgb(253, 178, 39);
pub const DISPLAY_COLOR: Color32 = Color32::from_rgb(41, 184, 209); pub const DISPLAY_COLOR: Color32 = Color32::from_rgb(41, 184, 209);
pub fn fps_ui<'a>( pub fn fps_ui(
gpu: Option<&DrmNode>, gpu: Option<&DrmNode>,
debug_active: bool, debug_active: bool,
seats: &[Seat<State>], seats: &[Seat<State>],
@ -122,23 +122,19 @@ pub fn fps_ui<'a>(
if let Ok(vendor) = std::fs::read_to_string(format!( if let Ok(vendor) = std::fs::read_to_string(format!(
"/sys/class/drm/renderD{}/device/vendor", "/sys/class/drm/renderD{}/device/vendor",
gpu.minor() gpu.minor()
)) { )) && let Some(img) = match vendor.trim() {
if let Some(img) = match vendor.trim() { "0x10de" => {
"0x10de" => Some(egui::include_image!( Some(egui::include_image!("../resources/icons/nvidia.svg"))
"../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()),
);
} }
"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<PointerFocusTarget>) -> String {
), ),
Some(ResizeFork(_)) => String::from("Resize UI"), Some(ResizeFork(_)) => String::from("Resize UI"),
Some(ZoomUI(_)) => String::from("Zoom UI"), Some(ZoomUI(_)) => String::from("Zoom UI"),
None => format!("None"), None => "None".to_string(),
} }
} }
@ -348,8 +344,8 @@ fn format_keyboard_focus(focus: Option<KeyboardFocusTarget>) -> String {
), ),
Some(LayerSurface(x)) => format!("LayerSurface {}", x.wl_surface().id().protocol_id()), Some(LayerSurface(x)) => format!("LayerSurface {}", x.wl_surface().id().protocol_id()),
Some(Popup(x)) => format!("Popup {}", 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()), Some(LockSurface(x)) => format!("LockSurface {}", x.wl_surface().id().protocol_id()),
None => format!("None"), None => "None".to_string(),
} }
} }

View file

@ -1,3 +1,8 @@
#![allow(
clippy::too_many_arguments,
clippy::type_complexity,
clippy::len_without_is_empty
)]
// SPDX-License-Identifier: GPL-3.0-only // SPDX-License-Identifier: GPL-3.0-only
use calloop::timer::{TimeoutAction, Timer}; use calloop::timer::{TimeoutAction, Timer};

View file

@ -812,7 +812,7 @@ impl CosmicMapped {
scale.x, scale.x,
0.8, 0.8,
) { ) {
Ok(element) => vec![CosmicMappedRenderElement::from(element).into()], Ok(element) => vec![CosmicMappedRenderElement::from(element)],
Err(err) => { Err(err) => {
debug!(?err, "Error rendering debug overlay."); debug!(?err, "Error rendering debug overlay.");
Vec::new() Vec::new()

View file

@ -154,6 +154,8 @@ impl Focus {
} }
} }
/// # Safety
/// `value` must be in the range of `Focus`
pub unsafe fn from_u8(value: u8) -> Option<Focus> { pub unsafe fn from_u8(value: u8) -> Option<Focus> {
match value { match value {
0 => None, 0 => None,

View file

@ -61,6 +61,7 @@ pub enum PointerFocusTarget {
} }
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]
#[allow(clippy::large_enum_variant)]
pub enum PointerFocusToplevel { pub enum PointerFocusToplevel {
Surface(CosmicSurface), Surface(CosmicSurface),
Popup(PopupKind), Popup(PopupKind),

View file

@ -737,6 +737,8 @@ impl MoveGrab {
release: ReleaseMode, release: ReleaseMode,
evlh: LoopHandle<'static, State>, evlh: LoopHandle<'static, State>,
) -> MoveGrab { ) -> MoveGrab {
// false-positive: `Output`s hash is based on it's inner ptr
#[allow(clippy::mutable_key_type)]
let mut outputs = HashSet::new(); let mut outputs = HashSet::new();
outputs.insert(cursor_output.clone()); outputs.insert(cursor_output.clone());
window.output_enter(&cursor_output, window.geometry()); // not accurate but... 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. // No more buttons are pressed, release the grab.
let output = self.cursor_output.clone(); let output = self.cursor_output.clone();
let seat = self.seat.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::<HashSet<_>>(); let window_outputs = self.window_outputs.drain().collect::<HashSet<_>>();
let previous = self.previous; let previous = self.previous;
let window = self.window.clone(); let window = self.window.clone();

View file

@ -1459,35 +1459,32 @@ impl TilingLayout {
let _ = tree.remove_node(node.clone(), RemoveBehavior::DropChildren); let _ = tree.remove_node(node.clone(), RemoveBehavior::DropChildren);
// fixup parent node // fixup parent node
match parent_id { if let Some(id) = parent_id {
Some(id) => { let position = position.unwrap();
let position = position.unwrap(); let group = tree.get_mut(&id).unwrap().data_mut();
let group = tree.get_mut(&id).unwrap().data_mut(); assert!(group.is_group());
assert!(group.is_group());
if group.len() > 2 { if group.len() > 2 {
group.remove_window(position); group.remove_window(position);
} else { } else {
trace!("Removing Group"); trace!("Removing Group");
let other_child = tree.children_ids(&id).unwrap().next().cloned().unwrap(); let other_child = tree.children_ids(&id).unwrap().next().cloned().unwrap();
let fork_pos = parent_parent_id.as_ref().and_then(|parent_id| { let fork_pos = parent_parent_id.as_ref().and_then(|parent_id| {
tree.children_ids(parent_id).unwrap().position(|i| i == &id) tree.children_ids(parent_id).unwrap().position(|i| i == &id)
}); });
let _ = tree.remove_node(id.clone(), RemoveBehavior::OrphanChildren); let _ = tree.remove_node(id.clone(), RemoveBehavior::OrphanChildren);
tree.move_node( tree.move_node(
&other_child, &other_child,
parent_parent_id parent_parent_id
.as_ref() .as_ref()
.map(MoveBehavior::ToParent) .map(MoveBehavior::ToParent)
.unwrap_or(MoveBehavior::ToRoot), .unwrap_or(MoveBehavior::ToRoot),
) )
.unwrap(); .unwrap();
if let Some(old_pos) = fork_pos { if let Some(old_pos) = fork_pos {
tree.make_nth_sibling(&other_child, old_pos).unwrap(); tree.make_nth_sibling(&other_child, old_pos).unwrap();
}
} }
} }
None => {} // root
} }
} }

View file

@ -1186,6 +1186,8 @@ impl Workspaces {
let len = self.sets[0].workspaces.len(); let len = self.sets[0].workspaces.len();
let mut active = self.sets[0].active; let mut active = self.sets[0].active;
let mut keep = vec![true; len]; let mut keep = vec![true; len];
// false-positive: we iterate over multiple sets
#[allow(clippy::needless_range_loop)]
for i in 0..len { for i in 0..len {
let has_windows = self let has_windows = self
.sets .sets

View file

@ -319,6 +319,7 @@ pub struct FullscreenRestoreData {
} }
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]
#[allow(clippy::large_enum_variant)]
pub enum FocusResult { pub enum FocusResult {
None, None,
Handled, Handled,

View file

@ -300,6 +300,7 @@ pub struct Common {
} }
#[derive(Debug)] #[derive(Debug)]
#[allow(clippy::large_enum_variant)]
pub enum BackendData { pub enum BackendData {
X11(X11State), X11(X11State),
Winit(WinitState), Winit(WinitState),

View file

@ -1,3 +1,5 @@
#![allow(clippy::wrong_self_convention)]
use std::sync::Mutex; use std::sync::Mutex;
use smithay::{ use smithay::{