🐛 Windows: Fix right-click on tray icon dismissing its own menu#108
Merged
Conversation
The on_tray_icon_event handler in tray.rs matched TrayIconEvent::Click { .. },
which fires for every mouse button — including right-click. On right-click it
called window.show() + set_focus(), stealing focus from the native context menu
the OS had just opened and closing it instantly. That made "Quit xpressclaw"
nearly impossible to reach, since the tray menu is the only way to quit.
Narrow the match to a left-click release only (button: Left, button_state: Up).
Right- and middle-clicks now fall through untouched, so the tray menu opens and
stays open. Gating on Up also avoids summoning the window on the press half of
a click.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On Windows the only way to quit the app is from the system tray, but right-clicking the tray icon flashes the context menu and dismisses it instantly - so "Quit xpressclaw" is almost impossible to hit. Left-clicking to summon the window works fine; it's specifically right-click that's broken.
dismissed.auto.mp4
The cause is in
crates/xpressclaw-tauri/src/tray.rs: theon_tray_icon_eventhandler matchesTrayIconEvent::Click { .. }, which fires for every mouse button including right-click. On right-click it callswindow.show()+window.set_focus(), and that focus change steals focus from the native context menu the OS just opened, closing it before you can click anything.The right-click should only ever open the tray menu, never summon the window. So this PR narrows the match to a left-click release only:
Right- and middle-clicks now fall through untouched, so the native tray menu opens and stays open. Gating on
Up(rather thanDown) also keeps the window from popping on the press half of a click.fixed.dismissed.auto.mp4
Verified with
cargo check -p xpressclaw-tauri(green) and by building the NSIS installer from this branch: left-click still opens the dashboard, right-click now holds the menu open long enough to reach Quit.