fix(tray): do not un-minimise the application we hand the foreground back to
ForceForegroundWindow restores an iconic target, so closing to the tray would pop back open a window the user had deliberately minimised. Skip the handback in that case and leave the choice to Windows. A -tray launch also skips it: it never took the foreground from anyone. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -726,7 +726,11 @@ begin
|
|||||||
// captured our own window as its target. Callers that already placed the
|
// captured our own window as its target. Callers that already placed the
|
||||||
// foreground themselves (post-autofill) pass False.
|
// foreground themselves (post-autofill) pass False.
|
||||||
CaptureForegroundOwner;
|
CaptureForegroundOwner;
|
||||||
if AReturnForeground and (FPrevForeground <> 0) and IsWindow(FPrevForeground) then
|
// Not when it is minimised: ForceForegroundWindow un-minimises its target, and
|
||||||
|
// popping another application's window back open is not ours to decide. The
|
||||||
|
// user put it away — leave the foreground to Windows.
|
||||||
|
if AReturnForeground and (FPrevForeground <> 0) and IsWindow(FPrevForeground) and
|
||||||
|
(not IsIconic(FPrevForeground)) then
|
||||||
ForceForegroundWindow(FPrevForeground);
|
ForceForegroundWindow(FPrevForeground);
|
||||||
|
|
||||||
// 1. Hide the visible form via both FMX state and Win32 ShowWindow.
|
// 1. Hide the visible form via both FMX state and Win32 ShowWindow.
|
||||||
|
|||||||
@@ -369,7 +369,9 @@ begin
|
|||||||
TThread.ForceQueue(nil,
|
TThread.ForceQueue(nil,
|
||||||
procedure
|
procedure
|
||||||
begin
|
begin
|
||||||
FBridge.MinimizeToTray;
|
// 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);
|
||||||
// Hidden now — safe to pay the startup cost.
|
// Hidden now — safe to pay the startup cost.
|
||||||
btnStartClick(Nil);
|
btnStartClick(Nil);
|
||||||
LogLine('Launched with --tray, started hidden (balloon suppressed)');
|
LogLine('Launched with --tray, started hidden (balloon suppressed)');
|
||||||
|
|||||||
Reference in New Issue
Block a user