fix(startup): start the server AFTER the tray hide, not before
The visible thing is only the taskbar button — the form window is never shown (form_visible_was=False throughout). That button belongs to the FMX proxy, created partway through FormCreate, and FormCreate runs for ~1 s because it opens the DB, binds the Indy server and kicks off WebView2. The thread pumps no message during that second, so nothing could hide the proxy until it ended: hooks and hide points alike were powerless by construction. So stop trying to react faster and remove the wait instead: on a --tray launch btnStartClick now runs inside the deferred block, after MinimizeToTray. FormCreate returns in milliseconds, the proxy is hidden immediately, and the server starts once nothing is on screen. FServer is constructed earlier (line 295), so FServer.Active stays safe meanwhile. Normal launches keep the original order untouched. The EVENT_OBJECT_SHOW hook stays armed across the deferred start, so a proxy re-shown during it is hidden again. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -342,6 +342,17 @@ begin
|
||||
FreeAndNil(configList);
|
||||
end;
|
||||
end;
|
||||
// Starting the server (DB open + Indy bind + WebView2 navigation) is what
|
||||
// makes FormCreate run for ~1 s. The FMX taskbar proxy is created somewhere
|
||||
// inside that second, and since the thread never pumps a message while it
|
||||
// runs, nothing can hide the proxy until it is over — that is the taskbar
|
||||
// button sitting there during the Windows logon.
|
||||
//
|
||||
// On a --tray launch, do it AFTER the tray hide instead: FormCreate then
|
||||
// returns in milliseconds, MinimizeToTray runs immediately, and the proxy is
|
||||
// gone before it can be drawn. A normal launch is unchanged (the window is
|
||||
// meant to be on screen anyway, so ordering does not matter there).
|
||||
if not FindCmdLineSwitch('tray', True) then
|
||||
btnStartClick(Nil);
|
||||
btnToggleLogClick(nil);
|
||||
|
||||
@@ -361,6 +372,8 @@ begin
|
||||
procedure
|
||||
begin
|
||||
FBridge.MinimizeToTray;
|
||||
// Hidden now — safe to pay the startup cost.
|
||||
btnStartClick(Nil);
|
||||
GTrayStartupPending := False;
|
||||
if FShowEventHook <> 0 then
|
||||
begin
|
||||
|
||||
Reference in New Issue
Block a user