Skip to content

Commit 22e5f36

Browse files
author
Mohammod Al Amin Ashik
committed
fix: Explicitly set tray icon to improve visibility
- Add image crate dependency for PNG decoding - Load 32x32.png explicitly for system tray instead of using default - Convert PNG to RGBA format required by Tauri - This ensures proper tray icon rendering on Windows Note: For best results across all themes, consider creating a dedicated monochrome tray icon (dark icon on transparent background)
1 parent 4f76075 commit 22e5f36

3 files changed

Lines changed: 69 additions & 4 deletions

File tree

Cargo.lock

Lines changed: 56 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/desktop/src-tauri/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ tauri-plugin-single-instance = "2"
2121
tauri-plugin-deep-link = "2"
2222
tauri-plugin-updater = "2"
2323
tauri-plugin-autostart = "2"
24+
image = { version = "0.25", default-features = false, features = ["png"] }
2425
serde.workspace = true
2526
serde_json.workspace = true
2627
tokio.workspace = true

apps/desktop/src-tauri/src/tray.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//! - Quit application
77
88
use tauri::{
9+
image::Image,
910
menu::{Menu, MenuBuilder, SubmenuBuilder},
1011
tray::{MouseButton, MouseButtonState, TrayIconBuilder, TrayIconEvent},
1112
AppHandle, Emitter, Manager, Runtime,
@@ -34,8 +35,19 @@ pub fn setup_tray<R: Runtime>(app: &AppHandle<R>) -> tauri::Result<()> {
3435

3536
let menu = build_tray_menu(app)?;
3637

38+
// Load tray icon - decode PNG and convert to RGBA
39+
let icon_bytes = include_bytes!("../icons/32x32.png");
40+
let img = image::load_from_memory(icon_bytes)
41+
.map_err(|e| {
42+
tauri::Error::InvalidIcon(std::io::Error::new(std::io::ErrorKind::InvalidData, e))
43+
})?
44+
.to_rgba8();
45+
let (width, height) = img.dimensions();
46+
let icon = Image::new_owned(img.into_raw(), width, height);
47+
3748
let _tray = TrayIconBuilder::with_id("mcpmux-tray")
3849
.tooltip("McpMux - MCP Server Manager")
50+
.icon(icon)
3951
.menu(&menu)
4052
.show_menu_on_left_click(false)
4153
.on_menu_event(move |app, event| {

0 commit comments

Comments
 (0)