Skip to content

🐛 Windows: Fix right-click on tray icon dismissing its own menu#108

Merged
wmeddie merged 1 commit into
mainfrom
fahreza/fix-tray-rightclick-focus
May 27, 2026
Merged

🐛 Windows: Fix right-click on tray icon dismissing its own menu#108
wmeddie merged 1 commit into
mainfrom
fahreza/fix-tray-rightclick-focus

Conversation

@MFA-X-AI
Copy link
Copy Markdown
Member

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: the on_tray_icon_event handler matches TrayIconEvent::Click { .. }, which fires for every mouse button including right-click. On right-click it calls window.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:

if let TrayIconEvent::Click {
    button: MouseButton::Left,
    button_state: MouseButtonState::Up,
    ..
} = event

Right- and middle-clicks now fall through untouched, so the native tray menu opens and stays open. Gating on Up (rather than Down) 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.

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.
@wmeddie wmeddie merged commit 583e84c into main May 27, 2026
4 checks passed
@wmeddie wmeddie deleted the fahreza/fix-tray-rightclick-focus branch May 27, 2026 07:20
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