Skip to content

Commit 20f7316

Browse files
committed
fix clippy issues
1 parent f5c79ae commit 20f7316

File tree

20 files changed

+103
-93
lines changed

20 files changed

+103
-93
lines changed

src/backend/wayland/frozen.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ impl CaptureSession {
9393
}
9494

9595
/// End-to-end controller for frozen mode capture and image storage.
96+
#[allow(clippy::type_complexity)]
9697
pub struct FrozenState {
9798
manager: Option<ZwlrScreencopyManagerV1>,
9899
active_output: Option<wl_output::WlOutput>,
@@ -139,7 +140,7 @@ impl FrozenState {
139140
}
140141

141142
pub fn active_output_matches(&self, info_id: u32) -> bool {
142-
self.active_output_id.map_or(false, |id| id == info_id)
143+
self.active_output_id == Some(info_id)
143144
}
144145

145146
pub fn image(&self) -> Option<&FrozenImage> {

src/backend/wayland/frozen_geometry.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ impl OutputGeometry {
3131
}
3232

3333
#[cfg(test)]
34+
#[allow(clippy::items_after_test_module)]
3435
mod tests {
3536
use super::*;
3637

src/backend/wayland/handlers/pointer.rs

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -162,55 +162,59 @@ impl PointerHandler for WaylandState {
162162
0
163163
};
164164

165-
if self.input_state.modifiers.shift {
166-
if scroll_direction > 0 {
165+
match scroll_direction.cmp(&0) {
166+
std::cmp::Ordering::Greater if self.input_state.modifiers.shift => {
167167
self.input_state.adjust_font_size(-2.0);
168168
debug!(
169169
"Font size decreased: {:.1}px",
170170
self.input_state.current_font_size
171171
);
172-
} else if scroll_direction < 0 {
172+
}
173+
std::cmp::Ordering::Less if self.input_state.modifiers.shift => {
173174
self.input_state.adjust_font_size(2.0);
174175
debug!(
175176
"Font size increased: {:.1}px",
176177
self.input_state.current_font_size
177178
);
178179
}
179-
} else if scroll_direction != 0 {
180-
let delta = if scroll_direction > 0 { -1.0 } else { 1.0 };
181-
let eraser_active = self.input_state.active_tool() == Tool::Eraser;
182-
#[cfg(tablet)]
183-
let prev_thickness = self.input_state.current_thickness;
180+
std::cmp::Ordering::Greater | std::cmp::Ordering::Less => {
181+
let delta = if scroll_direction > 0 { -1.0 } else { 1.0 };
182+
let eraser_active = self.input_state.active_tool() == Tool::Eraser;
183+
#[cfg(tablet)]
184+
let prev_thickness = self.input_state.current_thickness;
184185

185-
if self.input_state.nudge_thickness_for_active_tool(delta) {
186-
if eraser_active {
187-
debug!(
188-
"Eraser size adjusted: {:.0}px",
189-
self.input_state.eraser_size
190-
);
191-
} else {
192-
debug!(
193-
"Thickness adjusted: {:.0}px",
194-
self.input_state.current_thickness
195-
);
186+
if self.input_state.nudge_thickness_for_active_tool(delta) {
187+
if eraser_active {
188+
debug!(
189+
"Eraser size adjusted: {:.0}px",
190+
self.input_state.eraser_size
191+
);
192+
} else {
193+
debug!(
194+
"Thickness adjusted: {:.0}px",
195+
self.input_state.current_thickness
196+
);
197+
}
198+
self.input_state.needs_redraw = true;
196199
}
197-
self.input_state.needs_redraw = true;
198-
}
199-
#[cfg(tablet)]
200-
if !eraser_active
201-
&& (self.input_state.current_thickness - prev_thickness).abs()
202-
> f64::EPSILON
203-
{
204-
self.stylus_base_thickness = Some(self.input_state.current_thickness);
205-
if self.stylus_tip_down {
206-
self.stylus_pressure_thickness =
200+
#[cfg(tablet)]
201+
if !eraser_active
202+
&& (self.input_state.current_thickness - prev_thickness).abs()
203+
> f64::EPSILON
204+
{
205+
self.stylus_base_thickness =
207206
Some(self.input_state.current_thickness);
208-
self.record_stylus_peak(self.input_state.current_thickness);
209-
} else {
210-
self.stylus_pressure_thickness = None;
211-
self.stylus_peak_thickness = None;
207+
if self.stylus_tip_down {
208+
self.stylus_pressure_thickness =
209+
Some(self.input_state.current_thickness);
210+
self.record_stylus_peak(self.input_state.current_thickness);
211+
} else {
212+
self.stylus_pressure_thickness = None;
213+
self.stylus_peak_thickness = None;
214+
}
212215
}
213216
}
217+
std::cmp::Ordering::Equal => {}
214218
}
215219
}
216220
}

src/backend/wayland/handlers/tablet.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
//! Wayland tablet/stylus protocol handling (zwp_tablet_v2).
22
3-
#![cfg(tablet)]
4-
53
use log::{debug, info};
64
use wayland_client::{Connection, Dispatch, Proxy, QueueHandle};
75
use wayland_protocols::wp::tablet::zv2::client::{
@@ -401,9 +399,11 @@ impl Dispatch<ZwpTabletToolV2, ()> for WaylandState {
401399
}
402400
Event::Motion { x, y } => {
403401
if state.stylus_on_toolbar {
404-
state.stylus_last_pos = Some((x as f64, y as f64));
402+
let xf = x;
403+
let yf = y;
404+
state.stylus_last_pos = Some((xf, yf));
405405
if let Some(surface) = state.stylus_surface.as_ref() {
406-
let evt = state.toolbar.pointer_motion(surface, (x as f64, y as f64));
406+
let evt = state.toolbar.pointer_motion(surface, (xf, yf));
407407
if state.toolbar_dragging {
408408
if let Some(evt) = evt {
409409
state.handle_toolbar_event(evt);
@@ -423,7 +423,9 @@ impl Dispatch<ZwpTabletToolV2, ()> for WaylandState {
423423
}
424424
state.current_mouse_x = x as i32;
425425
state.current_mouse_y = y as i32;
426-
state.stylus_last_pos = Some((x as f64, y as f64));
426+
let xf = x;
427+
let yf = y;
428+
state.stylus_last_pos = Some((xf, yf));
427429
state
428430
.input_state
429431
.on_mouse_motion(state.current_mouse_x, state.current_mouse_y);

src/backend/wayland/state.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,12 @@ impl WaylandState {
176176
) -> Self {
177177
#[cfg(tablet)]
178178
let tablet_settings = {
179-
let mut settings = TabletSettings::default();
180-
settings.enabled = config.tablet.enabled;
181-
settings.pressure_enabled = config.tablet.pressure_enabled;
182-
settings.min_thickness = config.tablet.min_thickness;
183-
settings.max_thickness = config.tablet.max_thickness;
184-
settings
179+
TabletSettings {
180+
enabled: config.tablet.enabled,
181+
pressure_enabled: config.tablet.pressure_enabled,
182+
min_thickness: config.tablet.min_thickness,
183+
max_thickness: config.tablet.max_thickness,
184+
}
185185
};
186186

187187
Self {

src/backend/wayland/toolbar.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#![allow(clippy::too_many_arguments)]
2+
#![allow(clippy::type_complexity)]
3+
14
use anyhow::{Context, Result};
25
use smithay_client_toolkit::{
36
compositor::CompositorState,
@@ -1773,7 +1776,7 @@ fn render_side_palette(
17731776
let icon_btn_size = 42.0; // Unified with top toolbar
17741777
let icon_gap = 6.0;
17751778
let icons_per_row = 5;
1776-
let _icon_rows = (all_actions.len() + icons_per_row - 1) / icons_per_row;
1779+
let _icon_rows = all_actions.len().div_ceil(icons_per_row);
17771780
let icon_size = 22.0;
17781781
let total_icons_w =
17791782
icons_per_row as f64 * icon_btn_size + (icons_per_row - 1) as f64 * icon_gap;

src/config/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ pub struct LoadedConfig {
8686

8787
#[cfg(test)]
8888
mod tests {
89-
use super::ColorSpec;
9089
use super::*;
9190
use crate::config::test_helpers::with_temp_config_home;
9291
use std::fs;

src/daemon.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ use std::thread;
1313
use std::thread::JoinHandle;
1414
use std::time::{Duration, Instant};
1515

16-
#[cfg(unix)]
17-
use libc;
18-
1916
/// Overlay state for daemon mode
2017
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
2118
pub enum OverlayState {

src/draw/frame.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ pub struct ShapeSnapshot {
9494
/// Undoable actions stored in the frame history.
9595
#[derive(Clone, Debug, Serialize, Deserialize)]
9696
#[serde(tag = "kind", rename_all = "snake_case")]
97+
#[allow(clippy::large_enum_variant)]
9798
pub enum UndoAction {
9899
Create {
99100
shapes: Vec<(usize, DrawnShape)>,
@@ -692,8 +693,8 @@ mod frame_storage {
692693
use crate::draw::shape::Shape;
693694
use serde::{Deserialize, Deserializer, Serialize, Serializer};
694695

695-
pub fn serialize<S>(shapes: &Vec<DrawnShape>, serializer: S) -> Result<S::Ok, S::Error>
696-
where
696+
pub fn serialize<S>(shapes: &[DrawnShape], serializer: S) -> Result<S::Ok, S::Error>
697+
where
697698
S: Serializer,
698699
{
699700
let helper: Vec<SerializedDrawnShape<'_>> = shapes

src/draw/render.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ pub fn render_shape(ctx: &cairo::Context, shape: &Shape) {
263263
}
264264

265265
/// Renders a circular click highlight with configurable fill/outline colors.
266+
#[allow(clippy::too_many_arguments)]
266267
pub fn render_click_highlight(
267268
ctx: &cairo::Context,
268269
center_x: f64,
@@ -447,6 +448,7 @@ fn render_line(ctx: &cairo::Context, x1: i32, y1: i32, x2: i32, y2: i32, color:
447448
}
448449

449450
/// Render a rectangle (outline)
451+
#[allow(clippy::too_many_arguments)]
450452
fn render_rect(
451453
ctx: &cairo::Context,
452454
x: i32,
@@ -485,6 +487,7 @@ fn render_rect(
485487
}
486488

487489
/// Render an ellipse using Cairo's arc with scaling
490+
#[allow(clippy::too_many_arguments)]
488491
fn render_ellipse(
489492
ctx: &cairo::Context,
490493
cx: i32,

0 commit comments

Comments
 (0)