-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Fix macOS tray icon visibility on light menu bars #1580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -616,6 +616,12 @@ pub fn get_mode_icon(mode: RecordingMode) -> &'static [u8] { | |||||
| } | ||||||
| } | ||||||
|
|
||||||
| fn set_tray_template_icon(tray: &tauri::tray::TrayIcon, icon: Image<'_>) { | ||||||
| let _ = tray.set_icon(Some(icon)); | ||||||
| #[cfg(target_os = "macos")] | ||||||
| let _ = tray.set_icon_as_template(true); | ||||||
| } | ||||||
|
gupsammy marked this conversation as resolved.
|
||||||
|
|
||||||
| pub fn update_tray_icon_for_mode(app: &AppHandle, mode: RecordingMode) { | ||||||
| if cfg!(target_os = "windows") { | ||||||
| return; | ||||||
|
|
@@ -626,7 +632,7 @@ pub fn update_tray_icon_for_mode(app: &AppHandle, mode: RecordingMode) { | |||||
| }; | ||||||
|
|
||||||
| if let Ok(icon) = Image::from_bytes(get_mode_icon(mode)) { | ||||||
| let _ = tray.set_icon(Some(icon)); | ||||||
| set_tray_template_icon(&tray, icon); | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -660,6 +666,7 @@ pub fn create_tray(app: &AppHandle) -> tauri::Result<()> { | |||||
|
|
||||||
| let _ = TrayIconBuilder::with_id("tray") | ||||||
| .icon(initial_icon) | ||||||
| .icon_as_template(true) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Previous:
Suggested change
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! Prompt To Fix With AIThis is a comment left during a code review.
Path: apps/desktop/src-tauri/src/tray.rs
Line: 669:669
Comment:
`.icon_as_template(true)` is now unconditional. The previous code used `cfg!(target_os = "macos")` to conditionally apply this only on macOS. While this doesn't cause runtime issues (the method exists on all platforms), using an unconditional `true` is slightly less clear than the previous version. Consider keeping the `cfg!` macro for clarity.
Previous:
```suggestion
.icon_as_template(cfg!(target_os = "macos"))
```
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise.
gupsammy marked this conversation as resolved.
Outdated
|
||||||
| .menu(&menu) | ||||||
| .show_menu_on_left_click(true) | ||||||
| .on_menu_event({ | ||||||
|
|
@@ -886,7 +893,7 @@ pub fn create_tray(app: &AppHandle) -> tauri::Result<()> { | |||||
| }; | ||||||
|
|
||||||
| if let Ok(icon) = Image::from_bytes(include_bytes!("../icons/tray-stop-icon.png")) { | ||||||
| let _ = tray.set_icon(Some(icon)); | ||||||
| set_tray_template_icon(&tray, icon); | ||||||
| } | ||||||
| } | ||||||
| }); | ||||||
|
|
@@ -907,7 +914,7 @@ pub fn create_tray(app: &AppHandle) -> tauri::Result<()> { | |||||
|
|
||||||
| let current_mode = get_current_mode(&app_handle); | ||||||
| if let Ok(icon) = Image::from_bytes(get_mode_icon(current_mode)) { | ||||||
| let _ = tray.set_icon(Some(icon)); | ||||||
| set_tray_template_icon(&tray, icon); | ||||||
| } | ||||||
| } | ||||||
| }); | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.