Skip to content

Commit

Permalink
Clippy changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Vassili-Dev committed Nov 26, 2024
1 parent 7b1fcae commit 749c6a0
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions input-emulation/src/wlroots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,8 @@ impl VirtualInput {
KeyboardEvent::Key { time, key, state } => {
self.keyboard.key(time, key, state as u32);
if let Ok(mut mods) = self.modifiers.lock() {
if mods.from_key_event(key, state) {
log::trace!("Key triggers modifier change");
log::trace!("Modifiers: {:?}", mods);
if mods.update_by_key_event(key, state) {
log::trace!("Key triggers modifier change: {:?}", mods);
self.keyboard.modifiers(
mods.mask_pressed().bits(),
0,
Expand All @@ -240,8 +239,7 @@ impl VirtualInput {
} => {
// Synchronize internal modifier state, assuming server is authoritative
if let Ok(mut mods) = self.modifiers.lock() {
mods.from_mods_event(e);
log::trace!("Modifiers: {:?}", mods);
mods.update_by_mods_event(e);
}
self.keyboard
.modifiers(mods_depressed, mods_latched, mods_locked, group);
Expand Down Expand Up @@ -321,18 +319,16 @@ bitflags! {
}

impl XMods {
fn from_mods_event(&mut self, evt: KeyboardEvent) {
match evt {
KeyboardEvent::Modifiers {
depressed, locked, ..
} => {
*self = XMods::from_bits_truncate(depressed) | XMods::from_bits_truncate(locked);
}
_ => {}
fn update_by_mods_event(&mut self, evt: KeyboardEvent) {
if let KeyboardEvent::Modifiers {
depressed, locked, ..
} = evt
{
*self = XMods::from_bits_truncate(depressed) | XMods::from_bits_truncate(locked);
}
}

fn from_key_event(&mut self, key: u32, state: u8) -> bool {
fn update_by_key_event(&mut self, key: u32, state: u8) -> bool {
if let Ok(key) = scancode::Linux::try_from(key) {
log::trace!("Attempting to process modifier from: {:#?}", key);
let pressed_mask = match key {
Expand Down

0 comments on commit 749c6a0

Please sign in to comment.