fix(tray): a -tray launch does take the foreground, so give it back

FMX shows its taskbar proxy before we hide it, so the launching console was left inactive. GStartupForeground, captured in the unit initialization before any window of ours exists, holds it. A Windows-startup launch is unaffected: the foreground is a shell window there, which the capture filters out.
This commit is contained in:
r-zakarya
2026-07-28 19:38:02 +01:00
parent 7c08a69bb2
commit 80711272c4
2 changed files with 14 additions and 8 deletions
+7 -3
View File
@@ -369,9 +369,13 @@ begin
TThread.ForceQueue(nil,
procedure
begin
// No foreground handback: a -tray launch never took the foreground from
// anyone, so there is nobody to give it back to.
FBridge.MinimizeToTray(True, False);
// Hand the foreground back: a -tray launch DOES take it for a moment —
// FMX puts its taskbar proxy up before we hide it — so the application
// that launched us (a console, Explorer) would otherwise be left
// inactive. GStartupForeground caught it before any window of ours
// existed. Nothing to give back on a Windows-startup launch: the
// foreground is then a shell window, which the capture filters out.
FBridge.MinimizeToTray(True, True);
// Hidden now — safe to pay the startup cost.
btnStartClick(Nil);
LogLine('Launched with --tray, started hidden (balloon suppressed)');