Revised "active window" tracking

This commit is contained in:
joten 2015-03-07 12:14:37 +01:00
parent ec10980bbc
commit 79635f8ced
3 changed files with 29 additions and 39 deletions

View file

@ -83,12 +83,6 @@ Manager_activateMonitor(i, d = 0) {
Manager_aMonitor := Manager_loop(i, d, 1, Manager_monitorCount)
v := Monitor_#%Manager_aMonitor%_aView_#1
wndId := View_getActiveWindow(Manager_aMonitor, v)
If Not (wndId And WinExist("ahk_id" wndId)) {
If View_#%Manager_aMonitor%_#%v%_wndIds
wndId := SubStr(View_#%Manager_aMonitor%_#%v%_wndIds, 1, InStr(View_#%Manager_aMonitor%_#%v%_wndIds, ";") - 1)
Else
wndId := 0
}
Debug_logMessage("DEBUG[1] Manager_activateMonitor: Manager_aMonitor: " Manager_aMonitor ", i: " i ", d: " d ", wndId: " wndId, 1)
Manager_winActivate(wndId)
}
@ -177,22 +171,12 @@ Manager_cleanup()
}
Manager_closeWindow() {
Local aView, aWndId, wndId0, wndIds
Local aWndId
WinGet, aWndId, ID, A
If Window_isProg(aWndId) {
;; Prior to closing, find the next window that should have focus.
;; If there is no such window, choose the bar on the same monitor.
aView := Monitor_#%Manager_aMonitor%_aView_#1
StringTrimRight, wndIds, View_#%Manager_aMonitor%_#%aView%_wndIds, 1
StringSplit, wndId, wndIds, `;
If (wndId0 >= 2)
View_activateWindow(0, +1)
Else
Manager_winActivate(0)
If Window_isProg(aWndId)
Window_close(aWndId)
}
}
; Asynchronous management of various WM properties.
; We want to make sure that we can recover the layout and windows in the event of
@ -491,6 +475,7 @@ Manager_onShellMessage(wParam, lParam) {
;; The current position of the mouse cursor defines the active monitor, if the desktop has been activated.
If m
Manager_aMonitor := m
View_setActiveWindow(Manager_aMonitor, Monitor_#%Manager_aMonitor%_aView_#1, lParam)
Bar_updateTitle()
}
@ -1094,24 +1079,17 @@ Manager_sync(ByRef wndIds = "")
}
Manager_unmanage(wndId) {
Local a, aView, wndId0, wndIds
Local a, aView
;; Find the next window that should have focus.
;; If there is no such window, choose the bar on the same monitor.
aView := Monitor_#%Manager_aMonitor%_aView_#1
StringTrimRight, wndIds, View_#%Manager_aMonitor%_#%aView%_wndIds, 1
StringSplit, wndId, wndIds, `;
If (wndId0 >= 2)
View_activateWindow(0, +1)
Else
Manager_winActivate(0)
;; Do our best to make sure that any unmanaged windows are left visible.
Window_show(wndId)
a := Window_#%wndId%_tags & 1 << aView - 1
Loop, % Config_viewCount {
If (Window_#%wndId%_tags & 1 << A_Index - 1) {
StringReplace, View_#%Manager_aMonitor%_#%A_Index%_wndIds, View_#%Manager_aMonitor%_#%A_Index%_wndIds, %wndId%`;,
StringReplace, View_#%Manager_aMonitor%_#%A_Index%_wndIds, View_#%Manager_aMonitor%_#%A_Index%_wndIds, % wndId ";",, All
StringReplace, View_#%Manager_aMonitor%_#%A_Index%_aWndIds, View_#%Manager_aMonitor%_#%A_Index%_aWndIds, % wndId ";",, All
Bar_updateView(Manager_aMonitor, A_Index)
}
}

View file

@ -99,13 +99,6 @@ Monitor_activateView(i, d = 0) {
}
wndId := View_getActiveWindow(Manager_aMonitor, i)
If Not (wndId And WinExist("ahk_id" wndId)) {
If View_#%Manager_aMonitor%_#%i%_wndIds {
wndId := SubStr(View_#%Manager_aMonitor%_#%i%_wndIds, 1, InStr(View_#%Manager_aMonitor%_#%i%_wndIds, ";")-1)
View_setActiveWindow(Manager_aMonitor, i, wndId)
} Else
wndId := 0
}
Manager_winActivate(wndId)
}

View file

@ -18,7 +18,7 @@ View_init(m, v)
Global
View_#%m%_#%v%_area_#0 := 0
View_#%m%_#%v%_aWndId := 0
View_#%m%_#%v%_aWndIds := "0;"
View_#%m%_#%v%_layout_#1 := 1
View_#%m%_#%v%_layout_#2 := 1
View_#%m%_#%v%_layoutAxis_#1 := Config_layoutAxis_#1
@ -144,9 +144,25 @@ View_arrange(m, v, setLayout = False) {
}
View_getActiveWindow(m, v) {
Global
Local wndId
Return, View_#%m%_#%v%_aWndId
Loop, Parse, View_#%m%_#%v%_aWndIds, `;
{
If Not A_LoopField
Break
Else If Not WinExist("ahk_id" A_LoopField)
Continue
Else {
wndId := A_LoopField
Break
}
}
If Not wndId And View_#%m%_#%v%_wndIds {
wndId := SubStr(View_#%m%_#%v%_wndIds, 1, InStr(View_#%m%_#%v%_wndIds, ";") - 1)
View_setActiveWindow(m, v, wndId)
}
Return, wndId
}
View_getTiledWndIds(m, v)
@ -196,7 +212,10 @@ View_moveWindow(i=0, d=0) {
View_setActiveWindow(m, v, wndId) {
Global
View_#%m%_#%v%_aWndId := wndId
If wndId {
StringReplace, View_#%m%_#%v%_aWndIds, View_#%m%_#%v%_aWndIds, % wndId ";", All
View_#%m%_#%v%_aWndIds := wndId ";" View_#%m%_#%v%_aWndIds
}
}
View_setGapWidth(i, d = 0) {