Skip to content

feat(Windows): add is_menu_showing() method to check tray menu visibi…#302

Open
iKineticate wants to merge 2 commits into
tauri-apps:devfrom
iKineticate:dev
Open

feat(Windows): add is_menu_showing() method to check tray menu visibi…#302
iKineticate wants to merge 2 commits into
tauri-apps:devfrom
iKineticate:dev

Conversation

@iKineticate

Copy link
Copy Markdown
Contributor

No description provided.

@amrbashir amrbashir left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, what would be the use case of this function?

Comment thread src/platform_impl/windows/mod.rs Outdated
Comment on lines +51 to +52
/// Whether the tray menu is currently showing
static IS_MENU_SHOWING: AtomicBool = AtomicBool::new(false);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work because we allow creating multiple tray icons, each with their own set of data and menu.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed it to a HashMap<usize, bool> keyed by HWND address, so each tray icon now tracks its own menu state independently.
refactor: support multiple tray icons by storing menu state per HWND

@iKineticate

Copy link
Copy Markdown
Contributor Author

Just curious, what would be the use case of this function?

Use case: Avoid interrupting user interaction. When a background thread or async task calls set_menu() while the menu is open, it closes abruptly. With is_menu_showing(), we can defer updates until the menu closes, improving UX.

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.

2 participants