Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions openless-all/app/src-tauri/src/coordinator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1963,6 +1963,8 @@ fn window_key_matches_trigger(trigger: crate::types::HotkeyTrigger, key: &str, c
HotkeyTrigger::LeftOption => (key == "Alt" || key == "AltGraph") && code == "AltLeft",
HotkeyTrigger::RightCommand => key == "Meta" && code == "MetaRight",
HotkeyTrigger::Fn => key == "Control" && code == "ControlRight",
// MediaPlayPause 走 WH_KEYBOARD_LL,不走 window hotkey fallback
HotkeyTrigger::MediaPlayPause => false,
// Custom 走 global-hotkey crate,不走 window hotkey fallback
HotkeyTrigger::Custom => false,
}
Expand Down
4 changes: 4 additions & 0 deletions openless-all/app/src-tauri/src/hotkey.rs
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ mod platform {
HotkeyTrigger::RightOption | HotkeyTrigger::RightAlt => 61,
HotkeyTrigger::RightCommand => 54,
HotkeyTrigger::Fn => 63,
HotkeyTrigger::MediaPlayPause => 0,
HotkeyTrigger::Custom => unreachable!("custom combo hotkeys use ComboHotkeyMonitor"),
}
}
Expand All @@ -633,6 +634,7 @@ mod platform {
FLAG_MASK_ALTERNATE
}
HotkeyTrigger::Fn => FLAG_MASK_SECONDARY_FN,
HotkeyTrigger::MediaPlayPause => 0,
HotkeyTrigger::Custom => unreachable!("custom combo hotkeys use ComboHotkeyMonitor"),
}
}
Expand Down Expand Up @@ -766,6 +768,7 @@ mod platform {
const VK_LMENU: u32 = 0xA4;
const VK_RMENU: u32 = 0xA5;
const VK_RWIN: u32 = 0x5C;
const VK_MEDIA_PLAY_PAUSE: u32 = 0xB3;
const LLKHF_INJECTED: u32 = 0x0000_0010;
const ACCEPT_INJECTED_ENV: &str = "OPENLESS_ACCEPT_SYNTHETIC_HOTKEY_EVENTS";

Expand Down Expand Up @@ -1024,6 +1027,7 @@ mod platform {
HotkeyTrigger::RightCommand => VK_RWIN,
HotkeyTrigger::LeftOption => VK_LMENU,
HotkeyTrigger::Fn => VK_RCONTROL,
HotkeyTrigger::MediaPlayPause => VK_MEDIA_PLAY_PAUSE,
HotkeyTrigger::Custom => unreachable!("custom combo hotkeys use ComboHotkeyMonitor"),
}
}
Expand Down
12 changes: 11 additions & 1 deletion openless-all/app/src-tauri/src/linux_fcitx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ fn trigger_to_keysym(trigger: crate::types::HotkeyTrigger) -> u32 {
crate::types::HotkeyTrigger::LeftOption => KEYSYM_ALT_L,
crate::types::HotkeyTrigger::RightCommand => KEYSYM_SUPER_R,
crate::types::HotkeyTrigger::Fn => KEYSYM_CONTROL_R,
crate::types::HotkeyTrigger::MediaPlayPause => unreachable!("Windows-only"),
crate::types::HotkeyTrigger::Custom => unreachable!(),
}
}
Expand All @@ -112,13 +113,16 @@ fn trigger_name(trigger: crate::types::HotkeyTrigger) -> &'static str {
crate::types::HotkeyTrigger::LeftOption => "Alt_L",
crate::types::HotkeyTrigger::RightCommand => "Super_R",
crate::types::HotkeyTrigger::Fn => "Control_R",
crate::types::HotkeyTrigger::MediaPlayPause => unreachable!("Windows-only"),
crate::types::HotkeyTrigger::Custom => unreachable!(),
}
}

/// 将 OpenLess 的主听写热键绑定同步到 fcitx5 插件。
pub fn sync_binding_to_plugin(binding: &crate::types::HotkeyBinding) {
if binding.trigger == crate::types::HotkeyTrigger::Custom {
if binding.trigger == crate::types::HotkeyTrigger::Custom
|| binding.trigger == crate::types::HotkeyTrigger::MediaPlayPause
{
return;
}
let sym = trigger_to_keysym(binding.trigger);
Expand Down Expand Up @@ -185,6 +189,9 @@ pub fn sync_qa_binding(trigger: Option<crate::types::HotkeyTrigger>) {
let _ = set_qa_hotkey_raw(0, 0);
return;
};
if trigger == crate::types::HotkeyTrigger::MediaPlayPause {
return;
}
let sym = trigger_to_keysym(trigger);
let name = trigger_name(trigger);
match set_qa_hotkey_raw(sym, 0) {
Expand All @@ -199,6 +206,9 @@ pub fn sync_translation_binding(trigger: Option<crate::types::HotkeyTrigger>) {
let _ = set_translation_hotkey_raw(0, 0);
return;
};
if trigger == crate::types::HotkeyTrigger::MediaPlayPause {
return;
}
let sym = trigger_to_keysym(trigger);
let name = trigger_name(trigger);
match set_translation_hotkey_raw(sym, 0) {
Expand Down
2 changes: 2 additions & 0 deletions openless-all/app/src-tauri/src/shortcut_binding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ pub fn legacy_modifier_trigger(binding: &ShortcutBinding) -> Option<HotkeyTrigge
Some(HotkeyTrigger::RightCommand)
}
"fn" | "function" => Some(HotkeyTrigger::Fn),
"mediaplaypause" | "mediaplay" | "playpause" => Some(HotkeyTrigger::MediaPlayPause),
_ => None,
}
}
Expand All @@ -66,6 +67,7 @@ pub fn binding_from_legacy_trigger(trigger: HotkeyTrigger) -> ShortcutBinding {
HotkeyTrigger::LeftControl => "LeftControl",
HotkeyTrigger::RightCommand => "RightCommand",
HotkeyTrigger::Fn => "Fn",
HotkeyTrigger::MediaPlayPause => "MediaPlayPause",
HotkeyTrigger::Custom => "RightOption",
};
ShortcutBinding {
Expand Down
4 changes: 4 additions & 0 deletions openless-all/app/src-tauri/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1847,6 +1847,7 @@ pub enum HotkeyTrigger {
RightCommand,
Fn,
RightAlt, // Windows synonym for RightOption
MediaPlayPause,
Custom,
}

Expand All @@ -1860,6 +1861,7 @@ impl HotkeyTrigger {
HotkeyTrigger::RightCommand => "右 Command",
HotkeyTrigger::Fn => "Fn (地球键)",
HotkeyTrigger::RightAlt => "右 Alt",
HotkeyTrigger::MediaPlayPause => "⏯ Media 播放/暂停",
HotkeyTrigger::Custom => "自定义组合键",
}
}
Expand Down Expand Up @@ -1951,6 +1953,7 @@ fn legacy_trigger_code(trigger: HotkeyTrigger) -> &'static str {
HotkeyTrigger::Fn => "ControlRight",
#[cfg(not(target_os = "windows"))]
HotkeyTrigger::Fn => "Fn",
HotkeyTrigger::MediaPlayPause => "MediaPlayPause",
HotkeyTrigger::Custom => "",
}
}
Expand Down Expand Up @@ -2071,6 +2074,7 @@ impl HotkeyCapability {
HotkeyTrigger::RightAlt,
HotkeyTrigger::LeftControl,
HotkeyTrigger::RightCommand,
HotkeyTrigger::MediaPlayPause,
HotkeyTrigger::Custom,
],
requires_accessibility_permission: false,
Expand Down
1 change: 1 addition & 0 deletions openless-all/app/src/i18n/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,7 @@ export const en: typeof zhCN = {
rightCommand: 'Right Command',
fn: 'Fn (Globe key)',
rightAlt: 'Right Alt',
mediaPlayPause: '⏯ Media Play/Pause',
custom: 'Custom combination\u2026',
},
fallback: 'Global hotkey',
Expand Down
1 change: 1 addition & 0 deletions openless-all/app/src/i18n/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,7 @@ export const ja: typeof zhCN = {
rightCommand: '右 Command',
fn: 'Fn (地球キー)',
rightAlt: '右 Alt',
mediaPlayPause: '⏯ メディア再生/一時停止',
custom: 'カスタム組み合わせ…',
},
fallback: 'グローバルショートカット',
Expand Down
1 change: 1 addition & 0 deletions openless-all/app/src/i18n/ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,7 @@ export const ko: typeof zhCN = {
rightCommand: '오른쪽 Command',
fn: 'Fn (지구본 키)',
rightAlt: '오른쪽 Alt',
mediaPlayPause: '⏯ 미디어 재생/일시정지',
custom: '사용자 지정 조합…',
},
fallback: '전역 단축키',
Expand Down
1 change: 1 addition & 0 deletions openless-all/app/src/i18n/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,7 @@ export const zhCN = {
rightCommand: '右 Command',
fn: 'Fn (地球键)',
rightAlt: '右 Alt',
mediaPlayPause: '⏯ 媒体播放/暂停',
custom: '自定义组合键…',
},
fallback: '全局快捷键',
Expand Down
1 change: 1 addition & 0 deletions openless-all/app/src/i18n/zh-TW.ts
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,7 @@ export const zhTW: typeof zhCN = {
rightCommand: '右 Command',
fn: 'Fn (地球鍵)',
rightAlt: '右 Alt',
mediaPlayPause: '⏯ 媒體播放/暫停',
custom: '自訂組合…',
},
fallback: '全局快捷鍵',
Expand Down
3 changes: 3 additions & 0 deletions openless-all/app/src/lib/hotkey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ function legacyTriggerCode(trigger: HotkeyTrigger | null | undefined): string |
return 'MetaRight';
case 'fn':
return 'Fn';
case 'mediaPlayPause':
return 'MediaPlayPause';
default:
return null;
}
Expand Down Expand Up @@ -259,6 +261,7 @@ function formatPrimary(primary: string): string {
case 'leftcontrol': return isMac ? 'Left ⌃' : 'Left Ctrl';
case 'rightcommand': return isMac ? 'Right ⌘' : (currentPlatform().isWindows ? 'Right Win' : 'Right Super');
case 'fn': return 'Fn';
case 'mediaplaypause': return '⏯ Media';
case 'shift': return isMac ? '⇧' : 'Shift';
}
return trimmed;
Expand Down
1 change: 1 addition & 0 deletions openless-all/app/src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export type HotkeyTrigger =
| 'rightCommand'
| 'fn'
| 'rightAlt'
| 'mediaPlayPause'
| 'custom';

export type HotkeyMode = 'toggle' | 'hold' | 'doubleClick';
Expand Down
Loading