diff --git a/src/Manager.ahk b/src/Manager.ahk index 54b8834..8b7c647 100644 --- a/src/Manager.ahk +++ b/src/Manager.ahk @@ -57,21 +57,17 @@ Manager_init() Manager_activateMonitor(d) { - Local aView, aWndClass, aWndHeight, aWndId, aWndWidth, aWndX, aWndY, v, wndId + Local aView, aWndHeight, aWndId, aWndWidth, aWndX, aWndY, v, wndId If (Manager_monitorCount > 1) { aView := Monitor_#%Manager_aMonitor%_aView_#1 - WinGet, aWndId, ID, A - If WinExist("ahk_id" aWndId) + aWndId := View_getActiveWindow(Manager_aMonitor, aView) + If aWndId { - WinGetClass, aWndClass, ahk_id %aWndId% - If Not (aWndClass = "Progman") And Not (aWndClass = "AutoHotkeyGui") And Not (aWndClass = "DesktopBackgroundClass") - { - WinGetPos, aWndX, aWndY, aWndWidth, aWndHeight, ahk_id %aWndId% - If (Monitor_get(aWndX + aWndWidth / 2, aWndY + aWndHeight / 2) = Manager_aMonitor) - View_#%Manager_aMonitor%_#%aView%_aWndId := aWndId - } + WinGetPos, aWndX, aWndY, aWndWidth, aWndHeight, ahk_id %aWndId% + If (Monitor_get(aWndX + aWndWidth / 2, aWndY + aWndHeight / 2) = Manager_aMonitor) + View_#%Manager_aMonitor%_#%aView%_aWndId := aWndId } Manager_aMonitor := Manager_loop(Manager_aMonitor, d, 1, Manager_monitorCount) diff --git a/src/Monitor.ahk b/src/Monitor.ahk index 4aa05a2..b166055 100644 --- a/src/Monitor.ahk +++ b/src/Monitor.ahk @@ -36,7 +36,7 @@ Monitor_init(m) Monitor_activateView(v) { - Local aView, aWndClass, aWndId, aWndTitle, m, n, wndId, wndIds + Local aView, aWndId, m, n, wndId, wndIds If (v = -1) v := Monitor_#%Manager_aMonitor%_aView_#2 @@ -45,7 +45,7 @@ Monitor_activateView(v) Else If (v = "<") v := Manager_loop(Monitor_#%Manager_aMonitor%_aView_#1, -1, 1, Config_viewCount) - Debug_logMessage("DEBUG[1] Monitor_activateView(" . v . ") Manager_aMonitor: " . Manager_aMonitor . "; wndIds: " . View_#%m%_#%aView%_wndIds, 1) + Debug_logMessage("DEBUG[1] Monitor_activateView(" . v . ") Manager_aMonitor: " . Manager_aMonitor . "; wndIds: " . View_#%Manager_aMonitor%_#%v%_wndIds, 1) If (v <= 0) Or (v > Config_viewCount) Or Manager_hideShow Return ;; Re-arrange the windows on the active view. @@ -56,14 +56,9 @@ Monitor_activateView(v) } aView := Monitor_#%Manager_aMonitor%_aView_#1 - WinGet, aWndId, ID, A - If WinExist("ahk_id" aWndId) And InStr(View_#%Manager_aMonitor%_#%aView%_wndIds, aWndId ";") - { - WinGetClass, aWndClass, ahk_id %aWndId% - WinGetTitle, aWndTitle, ahk_id %aWndId% - If Not (aWndClass = "Progman") And Not (aWndClass = "AutoHotkeyGui" And SubStr(aWndTitle, 1, 10) = "bug.n_BAR_") And Not (aWndClass = "DesktopBackgroundClass") - View_#%Manager_aMonitor%_#%aView%_aWndId := aWndId - } + aWndId := View_getActiveWindow(Manager_aMonitor, aView) + If aWndId + View_#%Manager_aMonitor%_#%aView%_aWndId := aWndId n := Config_syncMonitorViews If (n = 1) diff --git a/src/View.ahk b/src/View.ahk index cea6c67..9b66e6b 100644 --- a/src/View.ahk +++ b/src/View.ahk @@ -224,6 +224,21 @@ View_arrange_tile(m, v, x, y, w, h) View_stackWindows("View_tiledWndId", mSplit + 1, stackLen, +1, axis3, x2, y2, w2, h2, gapW) } +View_getActiveWindow(m, v) +{ + Local aWndClass, aWndId, aWndTitle + + WinGet, aWndId, ID, A + If WinExist("ahk_id" aWndId) And InStr(View_#%m%_#%v%_wndIds, aWndId ";") + { + WinGetClass, aWndClass, ahk_id %aWndId% + WinGetTitle, aWndTitle, ahk_id %aWndId% + If Not (aWndClass = "Progman") And Not (aWndClass = "AutoHotkeyGui" And SubStr(aWndTitle, 1, 10) = "bug.n_BAR_") And Not (aWndClass = "DesktopBackgroundClass") + Return, aWndId + } + Return, 0 +} + View_getLayoutSymbol_tile(m, v, n) { Local axis1, axis2, axis3, masterDim, masterDiv, mx, my, stackSym