Skip to content

Conversation

nate-trojian
Copy link

@nate-trojian nate-trojian commented Jul 23, 2025

Adds a basic integration with tray_icon. Usage has been put behind the tray-icon feature flag.

Added the ability to:

  • Define a Tray Icon using either text or image
  • Process events for:
    • Mouse entering the icon
    • Exiting the icon
    • Pressing the mouse over the icon
    • Releasing the mouse over the icon
    • Double clicking the icon
    • Clicking a menu item
  • Add a menu to the Icon
  • Add a menu item with just text, a checkbox, an icon, or a predefined menu item

Current limitations:

  • No ability to modify the tray icon during the running of the application
  • Tray icon events must be processed from a subscription due to the fact they aren't tied to a window
  • Menu has to be open in order for "accelerators" to be used (limitation of how menus work in tray icon)
  • Clicking a predefined menu item does not generate a menu clicked event (this is a limitation inside of muda)

Screenshot of running example:
Screenshot 2025-07-29 at 23 25 18

@nate-trojian nate-trojian changed the title WIP: Tray Icon integration Tray Icon integration Jul 30, 2025
@nate-trojian nate-trojian marked this pull request as ready for review July 30, 2025 04:02
@dtzxporter
Copy link
Contributor

I'd like to see more of the code be disabled completely when the feature is disabled, IMO, nothing related to tray icon, even stubs, should be included because we have #[cfgs].

@n1ght-hunter
Copy link
Contributor

I'd like to see more of the code be disabled completely when the feature is disabled, IMO, nothing related to tray icon, even stubs, should be included because we have #[cfgs].

agreed that was just the first thing that popped out to me. really i think there should be pretty much no code included without enabling the feature

@nate-trojian
Copy link
Author

I'd like to see more of the code be disabled completely when the feature is disabled, IMO, nothing related to tray icon, even stubs, should be included because we have #[cfgs].

Because of how tightly integrated this feature needs to be within the system, I didn't originally want to do this. I think it hurts the readability of the code and will make it harder to add functionality to this feature in the future.

However, I've made the change to move the guards to all the public interfaces.

@Decodetalkers
Copy link
Contributor

https://github.com/tauri-apps/tray-icon/blob/dev/examples/winit.rs#L117-L125

I think on linux it needs gtk to show the tray icon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants