fix: preserve legacy Fn hotkey on Windows

This commit is contained in:
millionart committed 2026-05-04 21:27:06 +08:00
1 parent 47c0da299b
commit ce64e2e450
1 file changed
+12
+12
View File
@@ -346,6 +346,9 @@ fn legacy_trigger_code(trigger: HotkeyTrigger) -> &'static str {
HotkeyTrigger::RightControl => "ControlRight",
HotkeyTrigger::LeftControl => "ControlLeft",
HotkeyTrigger::RightCommand => "MetaRight",
#[cfg(target_os = "windows")]
HotkeyTrigger::Fn => "ControlRight",
#[cfg(not(target_os = "windows"))]
HotkeyTrigger::Fn => "Fn",
}
}
@@ -660,6 +663,15 @@ mod tests {
assert_eq!(binding.display_label(), "右 Control");
}
#[cfg(target_os = "windows")]
#[test]
fn legacy_fn_trigger_uses_windows_control_right_alias() {
let binding: HotkeyBinding =
serde_json::from_str(r#"{"trigger":"fn","mode":"toggle"}"#).unwrap();
assert_eq!(binding.effective_codes(), vec!["ControlRight".to_string()]);
}
#[test]
fn hotkey_binding_supports_combo_side_keys_mouse_and_double_click_mode() {
let binding = HotkeyBinding {