mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 00:35:38 +08:00
fix: always occupies hotkey globally when app launch silently (#5866)
* fix: always occupies hotkey when app launch silently * docs: update Changelog.md * chore: update
This commit is contained in:
@@ -287,8 +287,12 @@ singleton!(Hotkey, INSTANCE);
|
||||
|
||||
impl Hotkey {
|
||||
pub async fn init(&self, skip: bool) -> Result<()> {
|
||||
if skip {
|
||||
logging!(debug, Type::Hotkey, "skip register all hotkeys");
|
||||
return Ok(());
|
||||
}
|
||||
let verge = Config::verge().await;
|
||||
let enable_global_hotkey = !skip && verge.data_arc().enable_global_hotkey.unwrap_or(true);
|
||||
let enable_global_hotkey = verge.latest_arc().enable_global_hotkey.unwrap_or(true);
|
||||
|
||||
logging!(
|
||||
debug,
|
||||
@@ -298,7 +302,7 @@ impl Hotkey {
|
||||
);
|
||||
|
||||
// Extract hotkeys data before async operations
|
||||
let hotkeys = verge.data_arc().hotkeys.clone();
|
||||
let hotkeys = verge.latest_arc().hotkeys.clone();
|
||||
|
||||
if let Some(hotkeys) = hotkeys {
|
||||
logging!(debug, Type::Hotkey, "Has {} hotkeys need to register", hotkeys.len());
|
||||
|
||||
@@ -336,7 +336,9 @@ pub fn run() {
|
||||
.register_system_hotkey(SystemHotkey::CmdW)
|
||||
.await;
|
||||
}
|
||||
let _ = hotkey::Hotkey::global().init(true).await;
|
||||
if !is_enable_global_hotkey {
|
||||
let _ = hotkey::Hotkey::global().init(false).await;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -131,7 +131,9 @@ pub(super) async fn init_timer() {
|
||||
}
|
||||
|
||||
pub(super) async fn init_hotkey() {
|
||||
logging_error!(Type::Setup, Hotkey::global().init(false).await);
|
||||
// if hotkey is not use by global, skip init it
|
||||
let skip_register_hotkeys = !Config::verge().await.latest_arc().enable_global_hotkey.unwrap_or(true);
|
||||
logging_error!(Type::Setup, Hotkey::global().init(skip_register_hotkeys).await);
|
||||
}
|
||||
|
||||
pub(super) async fn init_auto_lightweight_boot() {
|
||||
|
||||
Reference in New Issue
Block a user