v4.1: two screen-reader fixes — silent start-in-tray, announce on restore

- Starting straight into the tray (StartMinimised / --minimized) no longer plays the "minimise"
  cue; only a genuine user minimise does (the startup path passes playCue:false)
- Restoring the window from the tray now lands focus on a real named control on the active tab so
  NVDA announces it, instead of resting on the role-less QuietTabControl and surfacing silently
- Shared the focus-a-leaf-for-announcement helper between the main window and Preferences

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Ednunp
2026-06-13 15:59:59 +01:00
co-authored by Claude Opus 4.8
parent a408d2b56e
commit 5abbeefe29
7 changed files with 73 additions and 54 deletions
+8 -4
View File
@@ -227,13 +227,17 @@ internal sealed class MainFormTrayController : IDisposable
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool SetForegroundWindow(IntPtr hWnd);
public void Minimize()
/// <summary>Hide the window to the tray. <paramref name="playCue"/> defaults true for a genuine
/// user-initiated minimise; the startup-minimise path passes false because that's not the user
/// choosing to hide the window — and the usual "was it visible?" guard can't tell the two apart,
/// since by the time the deferred startup minimise runs the window HAS been shown (Visible=true).</summary>
public void Minimize(bool playCue = true)
{
// Only sound the "hide" cue on a genuine shown -> hidden transition (not a startup-minimise
// before the window has ever been shown, nor a repeat call once already hidden).
// Only sound the "hide" cue on a genuine shown -> hidden transition the user asked for: not a
// startup-minimise (playCue:false), and not a repeat call once already hidden (wasVisible).
var wasVisible = owner.Visible;
owner.Hide();
if (wasVisible) (owner as MainForm)?.PlayWindowVisibilityCue(show: false);
if (wasVisible && playCue) (owner as MainForm)?.PlayWindowVisibilityCue(show: false);
// Refresh the tooltip BEFORE showing the icon so the shell's NIM_ADD call carries
// the current live state (peer count, send / receive routing, recording timer),
// not a stale "starting up" string set earlier. The shell tends to cache hover