Skip to content

An open-source remote desktop application designed for self-hosting, as an alternative to TeamViewer.

Fix tray icon click (regression due to breaking change in tray-icon 0.17) (#15413)

Daniel Marschall0cbdb6ffb346
diff --git a/src/tray.rs b/src/tray.rs
index e8db0efc0..bd2952cdf 100644
--- a/src/tray.rs
+++ b/src/tray.rs
@@ -143,12 +143,21 @@ fn make_tray() -> hbb_common::ResultType<()> {
}
// We create the icon once the event loop is actually running
// to prevent issues like https://github.com/tauri-apps/tray-icon/issues/90
- let tray = TrayIconBuilder::new()
+ let mut builder = TrayIconBuilder::new()
.with_menu(Box::new(tray_menu.clone()))
.with_tooltip(tooltip(0))
- .with_icon(icon.clone())
- .with_icon_as_template(true) // mac only
- .build();
+ .with_icon(icon.clone());
+ #[cfg(target_os = "macos")]
+ {
+ builder = builder.with_icon_as_template(true);
+ }
+ #[cfg(target_os = "windows")]
+ {
+ // Required since tray-icon 0.17
+ // Fixes #15215, #15222, #15410
+ builder = builder.with_menu_on_left_click(false);
+ }
+ let tray = builder.build();
match tray {
Ok(tray) => _tray_icon = Arc::new(Mutex::new(Some(tray))),
Err(err) => {