fix(detect): fix warnings
This commit is contained in:
parent
42d4351f4b
commit
2ecf86d9fa
|
@ -129,7 +129,7 @@ impl Source for Win32Source {
|
|||
|
||||
// Register the hotkeys
|
||||
self.hotkeys.iter().for_each(|hk| {
|
||||
let raw = convert_hotkey_to_raw(&hk);
|
||||
let raw = convert_hotkey_to_raw(hk);
|
||||
if let Some(raw_hk) = raw {
|
||||
if unsafe { detect_register_hotkey(handle, raw_hk) } == 0 {
|
||||
error!("unable to register hotkey: {}", hk);
|
||||
|
@ -160,12 +160,13 @@ impl Source for Win32Source {
|
|||
// Filter out keyboard events without an explicit HID device source.
|
||||
// This is needed to filter out the software-generated events, including
|
||||
// those from espanso.
|
||||
if event.event_type == INPUT_EVENT_TYPE_KEYBOARD && event.has_known_source == 0 {
|
||||
if unsafe { (*_self).exclude_orphan_events } {
|
||||
if event.event_type == INPUT_EVENT_TYPE_KEYBOARD
|
||||
&& event.has_known_source == 0
|
||||
&& unsafe { (*_self).exclude_orphan_events }
|
||||
{
|
||||
trace!("skipping keyboard event with unknown HID source (probably software generated).");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let event: Option<InputEvent> = event.into();
|
||||
if let Some(callback) = unsafe { (*_self).callback.borrow() } {
|
||||
|
@ -205,8 +206,6 @@ impl Drop for Win32Source {
|
|||
|
||||
fn convert_hotkey_to_raw(hk: &HotKey) -> Option<RawHotKey> {
|
||||
let key_code = hk.key.to_code()?;
|
||||
let code: Result<u32, _> = key_code.try_into();
|
||||
if let Ok(code) = code {
|
||||
let mut flags = 0x4000; // NOREPEAT flags
|
||||
if hk.has_ctrl() {
|
||||
flags |= 0x0002;
|
||||
|
@ -223,13 +222,9 @@ fn convert_hotkey_to_raw(hk: &HotKey) -> Option<RawHotKey> {
|
|||
|
||||
Some(RawHotKey {
|
||||
id: hk.id,
|
||||
code,
|
||||
code: key_code,
|
||||
flags,
|
||||
})
|
||||
} else {
|
||||
error!("unable to generate raw hotkey, the key_code is overflowing");
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
|
|
Loading…
Reference in New Issue
Block a user