fix(hotkeys): attach to the foreground thread to focus the buried dialog
The autofill helper attaches the caller to the TARGET thread, but the dialog runs on our own thread, so the attach was a no-op and Windows kept refusing the foreground change - the dialog rose without focus. Attaching to the current foreground thread instead is what grants the call.
This commit is contained in:
@@ -272,12 +272,6 @@ type
|
||||
read FOnQuickSearchHotkey write FOnQuickSearchHotkey;
|
||||
end;
|
||||
|
||||
// Bring a window to the foreground despite the Win10/11 anti-focus-stealing
|
||||
// rules (AttachThreadInput + poll). Exposed because the host needs it to raise
|
||||
// a native dialog of ours that got buried — plain SetForegroundWindow is
|
||||
// refused when we are not the foreground process.
|
||||
function ForceForegroundWindow(ATargetHwnd: HWND): Boolean;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
@@ -313,6 +307,7 @@ function UnhookWinEvent(hWinEventHook: THandle): BOOL;
|
||||
// Defined further down but needed by the constructor / MinimizeToTray.
|
||||
function IsOwnProcessWindow(AHwnd: HWND): Boolean; forward;
|
||||
function IsShellWindow(AHwnd: HWND): Boolean; forward;
|
||||
function ForceForegroundWindow(ATargetHwnd: HWND): Boolean; forward;
|
||||
procedure ForegroundEventProc(hWinEventHook: THandle; AEvent: DWORD; AWnd: HWND;
|
||||
idObject, idChild: LongInt; idEventThread, dwmsEventTime: DWORD); stdcall; forward;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user