Skip to content

fix: restore tray-hidden windows#404

Merged
Splode merged 1 commit into
Splode:mainfrom
SeanTong11:bugfix/tray-window-restore
Apr 26, 2026
Merged

fix: restore tray-hidden windows#404
Splode merged 1 commit into
Splode:mainfrom
SeanTong11:bugfix/tray-window-restore

Conversation

@SeanTong11

Copy link
Copy Markdown
Contributor

Summary

This fixes two tray-related window restore issues:

  • Restores the main window correctly when it is minimized but still reported as visible.
  • Clears stale titlebar hover/focus state after restoring the window from the tray.

Problem

When system tray support and close-to-tray are enabled, but minimize-to-tray is disabled, the main window can enter states that are not handled correctly by the current tray restore logic.

Case 1: minimized window does not restore from tray

Configuration:

  • Always on top: enabled
  • System tray: enabled
  • Close to tray: enabled
  • Minimize to tray: disabled

Steps:

  1. Minimize the main window.
  2. Click the tray icon.

Expected:

The main window should be restored and focused.

Actual:

The window may remain hidden/minimized because the tray click handler only checks is_visible(). On some platforms a minimized window can still be reported as visible, so the handler chooses hide() instead of restore.

Case 2: close button remains visually selected after tray restore

Configuration:

  • Always on top: enabled
  • System tray: enabled
  • Close to tray: enabled
  • Minimize to tray: disabled

Steps:

  1. Click the window close button.
  2. The window is hidden to tray.
  3. Click the tray icon to restore it.

Expected:

The restored window should not keep the close button in a hover/focus-like visual state, and pressing Enter should not trigger the previously focused close button.

Actual:

The close button can remain visually highlighted/red after restore, and the focused control state is not cleared.

Changes

  • Adds a small TrayWindowAction decision helper that treats minimized windows as restore targets.
  • Restores hidden/minimized windows with show(), unminimize(), and set_focus().
  • Applies the same restore behavior to the tray menu Show action.
  • Adds unit tests for the tray click decision matrix.
  • Clears stale titlebar focus/hover state before minimizing or closing.
  • Suppresses titlebar hover visuals until the user moves the pointer again after restore.
  • Keeps keyboard focus visibility via :focus-visible.

Testing

Tested manually on Windows:

  • Minimize the window, then click the tray icon: the window restores correctly.
  • Close to tray, then click the tray icon: the window restores without the close button staying red/selected.
  • Pressing Enter after restore no longer closes the window via stale close-button focus.

Commands run:

cargo test --manifest-path src-tauri/Cargo.toml tray_click
npm run check

@Splode

Splode commented Apr 26, 2026

Copy link
Copy Markdown
Owner

Looks good, and thank you for the contribution!

@Splode Splode merged commit 9741528 into Splode:main Apr 26, 2026
5 checks passed
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