From b3bf740efe39bd5312f690f957d38f54be4db6d1 Mon Sep 17 00:00:00 2001 From: imawizard Date: Wed, 17 Apr 2024 03:09:39 +0200 Subject: [PATCH] fix(focusindicator): Don't update for unmanaged windows that are invisible --- lib/miguru/miguru.ahk | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/miguru/miguru.ahk b/lib/miguru/miguru.ahk index 336a4fc..8809071 100644 --- a/lib/miguru/miguru.ahk +++ b/lib/miguru/miguru.ahk @@ -268,12 +268,23 @@ class MiguruWM extends WMEvents { ;; e.g. appear for the first time by unhiding instead of ;; creation, add new windows on any event. window := this._manage(event, hwnd) + if !window { + ;; A new explorer window actually seems to get focused while + ;; still being invisible. So in case that same window is shown + ;; later on it should be additionally focused. if event == EV_WINDOW_FOCUSED && !WinExist("ahk_id" hwnd " ahk_group MIGURU_IGNORE") { - debug("Set active to non-managed {}", WinInfo(hwnd)) + + debug("Set maybe-active to non-managed {}", WinInfo(hwnd)) this._maybeActiveWindow := hwnd - this._focusIndicator.Unmanaged(hwnd) + + ;; Only update the focus indicator for non-managed windows + ;; that are visible, though. + if DllCall("IsWindowVisible", "Ptr", hwnd, "Int") + || !IsWindowCloaked(hwnd) { + this._focusIndicator.Unmanaged(hwnd) + } } return } @@ -342,7 +353,6 @@ class MiguruWM extends WMEvents { PINNED_WINDOW_FOCUSED, ) } - } else if event == EV_WINDOW_REPOSITIONED { debug(() => ["Repositioned: D={} WS={} {}", monitor.Index, ws.Index, WinInfo(hwnd)])