feat: expose internal TrayIcon (#13959)

This commit is contained in:
Petr 2025-08-16 17:23:23 +01:00 committed by GitHub
parent 0c402bfb6b
commit f1232671ab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 0 deletions

View File

@ -0,0 +1,8 @@
---
"tauri": 'minor:enhance'
---
Introduce `with_inner_tray_icon` for Tauri `TrayIcon` to access the inner platform-specific tray icon.
Note that `tray-icon` crate may be updated in minor releases of Tauri.
Therefore, its recommended to pin Tauri to at least a minor version when youre using `with_inner_tray_icon`.

View File

@ -603,6 +603,18 @@ impl<R: Runtime> TrayIcon<R> {
})
})
}
/// Do something with the inner [`tray_icon::TrayIcon`] on main thread
///
/// Note that `tray-icon` crate may be updated in minor releases of Tauri.
/// Therefore, its recommended to pin Tauri to at least a minor version when youre using `with_inner_tray_icon`.
pub fn with_inner_tray_icon<F, T>(&self, f: F) -> crate::Result<T>
where
F: FnOnce(&tray_icon::TrayIcon) -> T + Send + 'static,
T: Send + 'static,
{
run_item_main_thread!(self, |self_: Self| { f(&self_.inner) })
}
}
impl<R: Runtime> Resource for TrayIcon<R> {