fix(window): don't filter the hook on the form HWND

The hook installed but never fired: an FMX app owns TWO top-level windows —
the form and the taskbar proxy (the one FindFMXAppWindow digs out in
PM.Bridge) — and Win+D minimises the proxy. Comparing the event HWND against
the form handle rejected every event.

Dropped the comparison; the hook is already scoped to our process and WebView2
lives in separate ones, so any window event arriving here is ours. Logs the
install result and each event's HWND so a silent failure is visible next time.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
r-zakarya
2026-07-25 22:50:26 +01:00
parent 7a19bdc13b
commit 72fe01f513
+9 -1
View File
@@ -213,6 +213,8 @@ begin
FWinEventHook := SetWinEventHook(
EVENT_SYSTEM_MINIMIZESTART, EVENT_SYSTEM_MINIMIZEEND, 0,
@WinStateEventProc, GetCurrentProcessId, 0, WINEVENT_OUTOFCONTEXT);
LogLine('[winstate] minimise hook installed=' +
BoolToStr(FWinEventHook <> 0, True));
FRestoring := False;
OnResize := FormResizeTrackState;
@@ -1561,7 +1563,13 @@ procedure WinStateEventProc(hWinEventHook: THandle; AEvent: DWORD; AWnd: HWND;
idObject, idChild: LongInt; idEventThread, dwmsEventTime: DWORD); stdcall;
begin
if (idObject <> OBJID_WINDOW) or (AWnd = 0) or (MainForm = nil) then Exit;
if AWnd <> WindowHandleToPlatform(MainForm.Handle).Wnd then Exit;
// No HWND filter: an FMX app owns TWO top-level windows — the form and the
// taskbar proxy (see FindFMXAppWindow in PM.Bridge) — and Win+D minimises
// the proxy, which an equality test against the form handle rejected. The
// hook is already scoped to our own process, and WebView2 lives in separate
// processes, so anything arriving here is ours.
MainForm.LogLine(Format('[winstate] hook event=%d hwnd=%d form=%d',
[AEvent, AWnd, WindowHandleToPlatform(MainForm.Handle).Wnd]));
if AEvent = EVENT_SYSTEM_MINIMIZESTART then MainForm.WinStateMinimizeStart
else if AEvent = EVENT_SYSTEM_MINIMIZEEND then MainForm.WinStateMinimizeEnd;
end;