From bab9c1dc926c6639d006e1dd054889ed94f54acf Mon Sep 17 00:00:00 2001 From: Federico Terzi Date: Wed, 6 Oct 2021 19:06:43 +0200 Subject: [PATCH] fix(detect): fix warnings on Wayland --- espanso-detect/src/evdev/device.rs | 2 +- espanso-detect/src/evdev/hotkey.rs | 1 + espanso-detect/src/evdev/sync/wayland.rs | 25 ++++++++++++------------ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/espanso-detect/src/evdev/device.rs b/espanso-detect/src/evdev/device.rs index e48d574..2dd0b25 100644 --- a/espanso-detect/src/evdev/device.rs +++ b/espanso-detect/src/evdev/device.rs @@ -140,7 +140,7 @@ impl Device { let is_down = value == KEY_STATE_PRESS; // Check if the current event originated from a mouse - if code >= 0x110 && code <= 0x117 { + if (0x110..=0x117).contains(&code) { // Mouse event return Some(RawInputEvent::Mouse(RawMouseEvent { code, is_down })); } diff --git a/espanso-detect/src/evdev/hotkey.rs b/espanso-detect/src/evdev/hotkey.rs index 41ec5a4..bb768c3 100644 --- a/espanso-detect/src/evdev/hotkey.rs +++ b/espanso-detect/src/evdev/hotkey.rs @@ -108,6 +108,7 @@ impl HotKeyFilter { // Remove duplicates and revert if !to_be_removed.is_empty() { + #[allow(clippy::stable_sort_primitive)] to_be_removed.sort(); to_be_removed.dedup(); to_be_removed.reverse(); diff --git a/espanso-detect/src/evdev/sync/wayland.rs b/espanso-detect/src/evdev/sync/wayland.rs index 6d7ce6c..750b053 100644 --- a/espanso-detect/src/evdev/sync/wayland.rs +++ b/espanso-detect/src/evdev/sync/wayland.rs @@ -44,13 +44,13 @@ pub fn get_modifiers_state() -> Result> { .create_window::(surface, None, dimensions, move |evt, mut dispatch_data| { let next_action = dispatch_data.get::>().unwrap(); // Keep last event in priority order : Close > Configure > Refresh - let replace = match (&evt, &*next_action) { + let replace = matches!( + (&evt, &*next_action), (_, &None) - | (_, &Some(WEvent::Refresh)) - | (&WEvent::Configure { .. }, &Some(WEvent::Configure { .. })) - | (&WEvent::Close, _) => true, - _ => false, - }; + | (_, &Some(WEvent::Refresh)) + | (&WEvent::Configure { .. }, &Some(WEvent::Configure { .. })) + | (&WEvent::Close, _) + ); if replace { *next_action = Some(evt); } @@ -138,12 +138,10 @@ pub fn get_modifiers_state() -> Result> { } } } - } else { - if let Some((kbd, source)) = opt_kbd.take() { - // the keyboard has been removed, cleanup - kbd.release(); - loop_handle.remove(source); - } + } else if let Some((kbd, source)) = opt_kbd.take() { + // the keyboard has been removed, cleanup + kbd.release(); + loop_handle.remove(source); } }); @@ -182,7 +180,7 @@ pub fn get_modifiers_state() -> Result> { let result_ref = result_clone.borrow(); if let Some(result) = &*result_ref { - return Ok(Some(result.clone())); + return Ok(Some(*result)); } } } @@ -215,6 +213,7 @@ fn keyboard_event_handler( } } +#[allow(clippy::many_single_char_names)] fn redraw( pool: &mut AutoMemPool, surface: &wl_surface::WlSurface,