From 770504ea03b012e05908db093ba495f3bcf1f656 Mon Sep 17 00:00:00 2001 From: r-zakarya <82443831+r-zakarya@users.noreply.github.com> Date: Sun, 12 Jul 2026 20:12:41 +0100 Subject: [PATCH] fix(quick-search): only tray-hidden windows go back to the tray on close wasHidden counted IsIconic too, so a window merely minimised to the taskbar ("visible" to the user) was treated as tray-origin: Esc/pick sent it to the TRAY, vanishing from the taskbar it came from. wasHidden is now strictly "came from the tray" (Visible=false); an iconic window gets restored by the hotkey and simply stays open when the modal closes. Co-Authored-By: Claude Opus 4.8 --- delphi-backend/UMainForm.pas | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/delphi-backend/UMainForm.pas b/delphi-backend/UMainForm.pas index 259d853..95a4000 100644 --- a/delphi-backend/UMainForm.pas +++ b/delphi-backend/UMainForm.pas @@ -341,8 +341,11 @@ begin // the password into it. Then pop the modal in fill mode. if not FServer.Active then Exit; FAutofillTargetHWND := ATargetHWND; - LWasHidden := (not Self.Visible) or - IsIconic(WindowHandleToPlatform(Self.Handle).Wnd); + // Tray-hidden ONLY (Visible=false). A window merely minimised to the + // taskbar must NOT count: hide-after would send it to the TRAY on close — + // it vanishes from the taskbar it came from. Restored-from-iconic just + // stays open after the modal closes. + LWasHidden := not Self.Visible; FBridge.RestoreFromTray; LWasHiddenJs := BoolToStr(LWasHidden, True).ToLower; // Second arg forFill=true tells JS to SendInput on pick instead of copy. @@ -362,11 +365,11 @@ begin // see the modal, then ask JS to open it. JS handles the locked-vault // case (shows the auth screen with master-pw focused instead). if not FServer.Active then Exit; - // Remember whether the window was hidden BEFORE we restore — after the - // user picks an entry the JS layer asks us to minimize back so they can - // paste into the target app without an extra alt-tab. - LWasHidden := (not Self.Visible) or - IsIconic(WindowHandleToPlatform(Self.Handle).Wnd); + // Remember whether the window was TRAY-hidden BEFORE we restore — after + // the user picks an entry the JS layer asks us to minimize back so they + // can paste into the target app without an extra alt-tab. Iconic-only + // (taskbar) does NOT count — see BridgeQuickSearchHotkey. + LWasHidden := not Self.Visible; FBridge.RestoreFromTray; LWasHiddenJs := BoolToStr(LWasHidden, True).ToLower; WebBrowser.ExecuteJavaScript(