Skip to content

Commit 50531d7

Browse files
committed
feat(tray): minimize sends Settings to tray; rename Exit -> Quit
The app already used ShutdownMode=OnExplicitShutdown, so closing the Settings window via the X already kept the app alive in the tray. But the minimize ('-') button still went to the taskbar, which is the wrong UX for a tray app. Two small changes: * SettingsWindow.OnStateChanged: when WindowState becomes Minimized, close the window instead. The taskbar entry disappears and the app stays in the tray, identical to clicking X. Reopen via tray icon double-click or the tray's Settings menu item. * TrayIconHost: rename 'Exit' to 'Quit' to match the user-facing vocabulary (and to make it clear that this is the only path that fully terminates the process). Behavior summary after this change: * X on Settings -> window closes, app stays in tray * '-' on Settings -> window closes, app stays in tray (was: taskbar) * Save & close -> persists, window closes, app stays in tray * Cancel -> discards, window closes, app stays in tray * Tray > Quit -> ExitApp: dispose tray + monitor + Shutdown()
1 parent 82e2bb1 commit 50531d7

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

src/GamerGuardian/Tray/TrayIconHost.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ public TrayIconHost()
2323
_pauseItem = new ToolStripMenuItem("Pause monitoring", null, (_, _) => PauseToggleRequested?.Invoke());
2424
menu.Items.Add(_pauseItem);
2525
menu.Items.Add(new ToolStripSeparator());
26-
menu.Items.Add("Exit", null, (_, _) => ExitRequested?.Invoke());
26+
// 'Quit' is the only path that fully terminates the process. Closing or
27+
// minimizing the Settings window goes to the tray (App.xaml has
28+
// ShutdownMode=OnExplicitShutdown).
29+
menu.Items.Add("Quit", null, (_, _) => ExitRequested?.Invoke());
2730

2831
_icon = new NotifyIcon
2932
{

src/GamerGuardian/UI/SettingsWindow.xaml.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,22 @@ private void PersistFormToConfig()
619619

620620
private bool _suppressSaveOnClose = false;
621621

622+
/// <summary>
623+
/// Redirects minimize (the '-' button or Win+Down) to a close: the window
624+
/// destroys, taskbar entry disappears, app stays in the tray. Reopen via
625+
/// double-click on the tray icon or the tray's Settings menu item.
626+
/// Without this, minimize would just shrink to a taskbar entry, which is
627+
/// the wrong UX for a tray app.
628+
/// </summary>
629+
protected override void OnStateChanged(EventArgs e)
630+
{
631+
base.OnStateChanged(e);
632+
if (WindowState == WindowState.Minimized)
633+
{
634+
Close();
635+
}
636+
}
637+
622638
private void OnWindowClosing(object? sender, CancelEventArgs e)
623639
{
624640
if (_suppressSaveOnClose) return;

0 commit comments

Comments
 (0)