fix(quick-search): stop teleporting + hiding an already-open window

Two bugs when Ctrl+Shift+Q fires while the app window is open beside the
target app:
- RestoreFromTray re-applied FSavedPlacement (captured at the LAST
  MinimizeToTray) to an already-visible window -> it jumped to a stale
  position. Now: visible and not iconic -> just SetForegroundWindow.
- ExecuteAutofill minimizes our window when it is foreground (the user just
  clicked the entry) and never brought it back when hide_after was false.
  New ARestoreAfter param (= not HideAfter): restore with SW_SHOWNOACTIVATE
  after the fill, so the window returns to its position without stealing
  focus from the freshly-filled target.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
r-zakarya
2026-07-11 19:52:26 +01:00
parent 01426a48b1
commit 3b32a621e8
2 changed files with 58 additions and 27 deletions
+5 -1
View File
@@ -1466,7 +1466,11 @@ begin
TTimer(Sender).Enabled := False;
TTimer(Sender).Free;
FBridge.ExecuteAutofill(TargetHwnd, PendingUser, PendingPass, UserOnly);
// ARestoreAfter = not HideAfter: if the app was open before the hotkey
// (quick-search beside the target), it comes back after the fill; if it
// started hidden, the MinimizeToTray below re-hides it anyway.
FBridge.ExecuteAutofill(TargetHwnd, PendingUser, PendingPass, UserOnly,
not HideAfter);
ForegroundAfter := GetForegroundWindow;
LogLine(Format('Autofill executed — target=%s, foreground_after=%s, match=%s',
[IntToHex(TargetHwnd, 8), IntToHex(ForegroundAfter, 8),