mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-12-02 11:40:04 +08:00
fix(tray): wake the main window from Linux tray clicks
Use StatusNotifierItem activation to wake the dashboard, including lightweight mode. Closes #8517
This commit is contained in:
Generated
+39
@@ -1659,6 +1659,15 @@ dependencies = [
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-queue"
|
||||
version = "0.3.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "03e8bd762f7479489c70ed6c768ddca99d7296857de437a68dcb2a94365b3fae"
|
||||
dependencies = [
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-utils"
|
||||
version = "0.8.22"
|
||||
@@ -3874,6 +3883,26 @@ dependencies = [
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ksni"
|
||||
version = "0.3.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d49a7ac89853917f01d75f6bac3e7c8e282ae621dd63fbbfc50fe331304fa580"
|
||||
dependencies = [
|
||||
"arc-swap",
|
||||
"async-executor",
|
||||
"async-io",
|
||||
"async-lock",
|
||||
"crossbeam-queue",
|
||||
"futures-channel",
|
||||
"futures-lite",
|
||||
"futures-util",
|
||||
"pastey",
|
||||
"serde",
|
||||
"task-local",
|
||||
"zbus",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy-regex"
|
||||
version = "3.6.1"
|
||||
@@ -7084,6 +7113,15 @@ version = "0.13.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca"
|
||||
|
||||
[[package]]
|
||||
name = "task-local"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2972044a9e5e448a506a7ff6f0d03b566d8ef4cd6918a58fc59835a0f8666626"
|
||||
dependencies = [
|
||||
"pin-project-lite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tauri"
|
||||
version = "2.13.0"
|
||||
@@ -8343,6 +8381,7 @@ checksum = "19886363e700addca09f3787a1394eda88a80c89b9305f96effb9ea5ce09146d"
|
||||
dependencies = [
|
||||
"crossbeam-channel",
|
||||
"dirs 7.0.0",
|
||||
"ksni",
|
||||
"libappindicator",
|
||||
"muda",
|
||||
"objc2",
|
||||
|
||||
@@ -59,6 +59,7 @@
|
||||
**🐧 Linux**
|
||||
|
||||
- 修复 Linux OpenRC 环境下服务安装失败
|
||||
- 修复 Linux 左键点击托盘图标时无法唤回主窗口
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
@@ -110,6 +110,7 @@ specta-typescript = "=0.0.13"
|
||||
libc = "0.2.191"
|
||||
|
||||
[target.'cfg(target_os = "linux")'.dependencies]
|
||||
tauri = { workspace = true, features = ["linux-ksni"] }
|
||||
# Upstream has no session-end signal support on Linux; see crates/clash-verge-signal.
|
||||
clash-verge-signal = { workspace = true }
|
||||
|
||||
|
||||
@@ -856,9 +856,14 @@ fn on_tray_icon_event(_tray_icon: &TrayIcon, tray_event: TrayIconEvent) {
|
||||
return;
|
||||
}
|
||||
|
||||
const CLICK_STATE: MouseButtonState = if cfg!(target_os = "linux") {
|
||||
MouseButtonState::Up
|
||||
} else {
|
||||
MouseButtonState::Down
|
||||
};
|
||||
if let TrayIconEvent::Click {
|
||||
button: MouseButton::Left,
|
||||
button_state: MouseButtonState::Down,
|
||||
button_state: CLICK_STATE,
|
||||
..
|
||||
} = tray_event
|
||||
{
|
||||
@@ -868,9 +873,13 @@ fn on_tray_icon_event(_tray_icon: &TrayIcon, tray_event: TrayIconEvent) {
|
||||
}
|
||||
|
||||
AsyncHandler::spawn(|| async move {
|
||||
let verge = Config::verge().await.data_arc();
|
||||
let verge_tray_event = verge.tray_event.clone().unwrap_or_else(|| "main_window".into());
|
||||
let verge_tray_action = TrayAction::from(verge_tray_event.as_str());
|
||||
let configured_event = if cfg!(target_os = "linux") {
|
||||
None
|
||||
} else {
|
||||
Config::verge().await.data_arc().tray_event.clone()
|
||||
};
|
||||
let verge_tray_event = configured_event.as_deref().unwrap_or("main_window");
|
||||
let verge_tray_action = TrayAction::from(verge_tray_event);
|
||||
logging!(debug, Type::Tray, "tray event: {verge_tray_action:?}");
|
||||
match verge_tray_action {
|
||||
TrayAction::SystemProxy => {
|
||||
|
||||
Reference in New Issue
Block a user