standardized the checking of the active window

This commit is contained in:
joten 2012-10-14 23:16:34 +02:00
parent 7ba6efb080
commit de1b284f14
3 changed files with 26 additions and 20 deletions

View file

@ -57,21 +57,17 @@ Manager_init()
Manager_activateMonitor(d) 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) If (Manager_monitorCount > 1)
{ {
aView := Monitor_#%Manager_aMonitor%_aView_#1 aView := Monitor_#%Manager_aMonitor%_aView_#1
WinGet, aWndId, ID, A aWndId := View_getActiveWindow(Manager_aMonitor, aView)
If WinExist("ahk_id" aWndId) If aWndId
{ {
WinGetClass, aWndClass, ahk_id %aWndId% WinGetPos, aWndX, aWndY, aWndWidth, aWndHeight, ahk_id %aWndId%
If Not (aWndClass = "Progman") And Not (aWndClass = "AutoHotkeyGui") And Not (aWndClass = "DesktopBackgroundClass") 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) Manager_aMonitor := Manager_loop(Manager_aMonitor, d, 1, Manager_monitorCount)

View file

@ -36,7 +36,7 @@ Monitor_init(m)
Monitor_activateView(v) Monitor_activateView(v)
{ {
Local aView, aWndClass, aWndId, aWndTitle, m, n, wndId, wndIds Local aView, aWndId, m, n, wndId, wndIds
If (v = -1) If (v = -1)
v := Monitor_#%Manager_aMonitor%_aView_#2 v := Monitor_#%Manager_aMonitor%_aView_#2
@ -45,7 +45,7 @@ Monitor_activateView(v)
Else If (v = "<") Else If (v = "<")
v := Manager_loop(Monitor_#%Manager_aMonitor%_aView_#1, -1, 1, Config_viewCount) 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 If (v <= 0) Or (v > Config_viewCount) Or Manager_hideShow
Return Return
;; Re-arrange the windows on the active view. ;; Re-arrange the windows on the active view.
@ -56,14 +56,9 @@ Monitor_activateView(v)
} }
aView := Monitor_#%Manager_aMonitor%_aView_#1 aView := Monitor_#%Manager_aMonitor%_aView_#1
WinGet, aWndId, ID, A aWndId := View_getActiveWindow(Manager_aMonitor, aView)
If WinExist("ahk_id" aWndId) And InStr(View_#%Manager_aMonitor%_#%aView%_wndIds, aWndId ";") If aWndId
{ View_#%Manager_aMonitor%_#%aView%_aWndId := 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
}
n := Config_syncMonitorViews n := Config_syncMonitorViews
If (n = 1) If (n = 1)

View file

@ -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_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) View_getLayoutSymbol_tile(m, v, n)
{ {
Local axis1, axis2, axis3, masterDim, masterDiv, mx, my, stackSym Local axis1, axis2, axis3, masterDim, masterDiv, mx, my, stackSym