style(detect): fix formatting
This commit is contained in:
parent
be68a1f8ff
commit
d11af8b1c2
|
@ -199,26 +199,70 @@ impl Device {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn update_modifier_state(&mut self, modifiers_state: &ModifiersState, modifiers_map: &HashMap<String, u32>) {
|
||||
pub fn update_modifier_state(
|
||||
&mut self,
|
||||
modifiers_state: &ModifiersState,
|
||||
modifiers_map: &HashMap<String, u32>,
|
||||
) {
|
||||
if modifiers_state.alt {
|
||||
self.update_key(*modifiers_map.get("alt").expect("unable to find modifiers key in map"), true);
|
||||
self.update_key(
|
||||
*modifiers_map
|
||||
.get("alt")
|
||||
.expect("unable to find modifiers key in map"),
|
||||
true,
|
||||
);
|
||||
}
|
||||
if modifiers_state.ctrl {
|
||||
self.update_key(*modifiers_map.get("ctrl").expect("unable to find modifiers key in map"), true);
|
||||
self.update_key(
|
||||
*modifiers_map
|
||||
.get("ctrl")
|
||||
.expect("unable to find modifiers key in map"),
|
||||
true,
|
||||
);
|
||||
}
|
||||
if modifiers_state.meta {
|
||||
self.update_key(*modifiers_map.get("meta").expect("unable to find modifiers key in map"), true);
|
||||
self.update_key(
|
||||
*modifiers_map
|
||||
.get("meta")
|
||||
.expect("unable to find modifiers key in map"),
|
||||
true,
|
||||
);
|
||||
}
|
||||
if modifiers_state.num_lock {
|
||||
self.update_key(*modifiers_map.get("num_lock").expect("unable to find modifiers key in map"), true);
|
||||
self.update_key(*modifiers_map.get("num_lock").expect("unable to find modifiers key in map"), false);
|
||||
self.update_key(
|
||||
*modifiers_map
|
||||
.get("num_lock")
|
||||
.expect("unable to find modifiers key in map"),
|
||||
true,
|
||||
);
|
||||
self.update_key(
|
||||
*modifiers_map
|
||||
.get("num_lock")
|
||||
.expect("unable to find modifiers key in map"),
|
||||
false,
|
||||
);
|
||||
}
|
||||
if modifiers_state.shift {
|
||||
self.update_key(*modifiers_map.get("shift").expect("unable to find modifiers key in map"), true);
|
||||
self.update_key(
|
||||
*modifiers_map
|
||||
.get("shift")
|
||||
.expect("unable to find modifiers key in map"),
|
||||
true,
|
||||
);
|
||||
}
|
||||
if modifiers_state.caps_lock {
|
||||
self.update_key(*modifiers_map.get("caps_lock").expect("unable to find modifiers key in map"), true);
|
||||
self.update_key(*modifiers_map.get("caps_lock").expect("unable to find modifiers key in map"), false);
|
||||
self.update_key(
|
||||
*modifiers_map
|
||||
.get("caps_lock")
|
||||
.expect("unable to find modifiers key in map"),
|
||||
true,
|
||||
);
|
||||
self.update_key(
|
||||
*modifiers_map
|
||||
.get("caps_lock")
|
||||
.expect("unable to find modifiers key in map"),
|
||||
false,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -178,7 +178,7 @@ pub fn get_modifiers_state() -> Result<Option<super::ModifiersState>> {
|
|||
redraw(&mut pool, window.surface(), dimensions).expect("Failed to draw");
|
||||
}
|
||||
None => {
|
||||
let result_clone= result.clone();
|
||||
let result_clone = result.clone();
|
||||
let result_ref = result_clone.borrow();
|
||||
|
||||
if let Some(result) = &*result_ref {
|
||||
|
@ -191,10 +191,7 @@ pub fn get_modifiers_state() -> Result<Option<super::ModifiersState>> {
|
|||
display.flush().unwrap();
|
||||
|
||||
event_loop
|
||||
.dispatch(
|
||||
Some(std::time::Duration::from_millis(10)),
|
||||
&mut next_action,
|
||||
)
|
||||
.dispatch(Some(std::time::Duration::from_millis(10)), &mut next_action)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
|
|
|
@ -22,16 +22,13 @@ use std::process::Command;
|
|||
use log::error;
|
||||
|
||||
pub fn get_active_layout() -> Option<String> {
|
||||
match Command::new("setxkbmap")
|
||||
.arg("-query")
|
||||
.output()
|
||||
{
|
||||
match Command::new("setxkbmap").arg("-query").output() {
|
||||
Ok(output) => {
|
||||
let output_str = String::from_utf8_lossy(&output.stdout);
|
||||
let layout_line = output_str.lines().find(|line| line.contains("layout:"))?;
|
||||
let layout_raw: Vec<&str> = layout_line.split("layout:").collect();
|
||||
Some(layout_raw.get(1)?.trim().to_string())
|
||||
},
|
||||
}
|
||||
Err(err) => {
|
||||
error!(
|
||||
"unable to retrieve current keyboard layout with 'setxkbmap': {}",
|
||||
|
|
|
@ -94,7 +94,10 @@ impl Default for SourceCreationOptions {
|
|||
#[cfg(target_os = "windows")]
|
||||
pub fn get_source(options: SourceCreationOptions) -> Result<Box<dyn Source>> {
|
||||
info!("using Win32Source");
|
||||
Ok(Box::new(win32::Win32Source::new(&options.hotkeys, options.win32_exclude_orphan_events)))
|
||||
Ok(Box::new(win32::Win32Source::new(
|
||||
&options.hotkeys,
|
||||
options.win32_exclude_orphan_events,
|
||||
)))
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
|
|
Loading…
Reference in New Issue
Block a user