Revert "Revised "active window" tracking"
This reverts commit ae88c5f1ff
.
This commit is contained in:
parent
eb4395fbea
commit
8562e2f9df
4 changed files with 54 additions and 58 deletions
|
@ -106,7 +106,7 @@ Debug_logWindowInfo(wndId)
|
|||
Else
|
||||
isWinFocus := " "
|
||||
v := Monitor_#%Manager_aMonitor%_aView_#1
|
||||
If View_getActiveWindow(Manager_aMonitor, v) = %wndId%
|
||||
If View_#%Manager_aMonitor%_#%v%_aWndId = %wndId%
|
||||
isBugnActive := "*"
|
||||
Else
|
||||
isBugnActive := " "
|
||||
|
|
|
@ -70,11 +70,11 @@ Manager_activateMonitor(i, d = 0) {
|
|||
|
||||
If (Manager_monitorCount > 1) {
|
||||
aView := Monitor_#%Manager_aMonitor%_aView_#1
|
||||
WinGet, aWndId, ID, A
|
||||
If WinExist("ahk_id" aWndId) And InStr(View_#%Manager_aMonitor%_#%aView%_wndIds, aWndId ";") And Window_isProg(aWndId) {
|
||||
aWndId := View_getActiveWindow(Manager_aMonitor, aView)
|
||||
If aWndId {
|
||||
WinGetPos, aWndX, aWndY, aWndWidth, aWndHeight, ahk_id %aWndId%
|
||||
If (Monitor_get(aWndX + aWndWidth / 2, aWndY + aWndHeight / 2) = Manager_aMonitor)
|
||||
View_setActiveWindow(Manager_aMonitor, aView, aWndId)
|
||||
View_#%Manager_aMonitor%_#%aView%_aWndId := aWndId
|
||||
}
|
||||
|
||||
;; Manually set the active monitor.
|
||||
|
@ -82,7 +82,13 @@ Manager_activateMonitor(i, d = 0) {
|
|||
i := Manager_aMonitor
|
||||
Manager_aMonitor := Manager_loop(i, d, 1, Manager_monitorCount)
|
||||
v := Monitor_#%Manager_aMonitor%_aView_#1
|
||||
wndId := View_getActiveWindow(Manager_aMonitor, v)
|
||||
wndId := View_#%Manager_aMonitor%_#%v%_aWndId
|
||||
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)
|
||||
}
|
||||
|
@ -242,7 +248,7 @@ Manager_getWindowList()
|
|||
Local text, v, aWndId, wndIds, aWndTitle
|
||||
|
||||
v := Monitor_#%Manager_aMonitor%_aView_#1
|
||||
aWndId := View_getActiveWindow(Manager_aMonitor, v)
|
||||
aWndId := View_#%Manager_aMonitor%_#%v%_aWndId
|
||||
WinGetTitle, aWndTitle, ahk_id %aWndId%
|
||||
text := "Active Window`n" aWndId ":`t" aWndTitle
|
||||
|
||||
|
@ -529,7 +535,7 @@ Manager_onShellMessage(wParam, lParam) {
|
|||
;; ... or additionally tag the window for the current view.
|
||||
v := Monitor_#%Manager_aMonitor%_aView_#1
|
||||
View_#%Manager_aMonitor%_#%v%_wndIds := lParam ";" View_#%Manager_aMonitor%_#%v%_wndIds
|
||||
View_setActiveWindow(Manager_aMonitor, v, lParam)
|
||||
View_#%Manager_aMonitor%_#%v%_aWndId := lParam
|
||||
Window_#%lParam%_tags += 1 << v - 1
|
||||
Bar_updateView(Manager_aMonitor, v)
|
||||
If Config_dynamicTiling
|
||||
|
@ -626,7 +632,7 @@ Manager_resetMonitorConfiguration() {
|
|||
{
|
||||
Loop, % Config_viewCount {
|
||||
StringReplace, View_#%i%_#%A_Index%_wndIds, View_#%i%_#%A_Index%_wndIds, %A_LoopField%`;,
|
||||
View_setActiveWindow(i, A_Index, 0)
|
||||
View_#%i%_#%A_Index%_aWndId := 0
|
||||
}
|
||||
Monitor_moveWindow(1, A_LoopField)
|
||||
}
|
||||
|
@ -898,7 +904,7 @@ Manager_setViewMonitor(i, d = 0) {
|
|||
{
|
||||
Loop, % Config_viewCount {
|
||||
StringReplace, View_#%Manager_aMonitor%_#%A_Index%_wndIds, View_#%Manager_aMonitor%_#%A_Index%_wndIds, %A_LoopField%`;,
|
||||
View_setActiveWindow(Manager_aMonitor, A_Index, 0)
|
||||
View_#%Manager_aMonitor%_#%A_Index%_aWndId := 0
|
||||
}
|
||||
|
||||
Monitor_moveWindow(i, A_LoopField)
|
||||
|
@ -951,8 +957,8 @@ Manager_setWindowMonitor(i, d = 0) {
|
|||
If (Manager_monitorCount > 1 And InStr(Manager_managedWndIds, aWndId ";")) {
|
||||
Loop, % Config_viewCount {
|
||||
StringReplace, View_#%Manager_aMonitor%_#%A_Index%_wndIds, View_#%Manager_aMonitor%_#%A_Index%_wndIds, %aWndId%`;,
|
||||
If (aWndId = View_getActiveWindow(Manager_aMonitor, A_Index))
|
||||
View_setActiveWindow(Manager_aMonitor, A_Index, 0)
|
||||
If (aWndId = View_#%Manager_aMonitor%_#%A_Index%_aWndId)
|
||||
View_#%Manager_aMonitor%_#%A_Index%_aWndId := 0
|
||||
Bar_updateView(Manager_aMonitor, A_Index)
|
||||
}
|
||||
If Config_dynamicTiling
|
||||
|
@ -966,7 +972,7 @@ Manager_setWindowMonitor(i, d = 0) {
|
|||
v := Monitor_#%Manager_aMonitor%_aView_#1
|
||||
Window_#%aWndId%_tags := 1 << v - 1
|
||||
View_#%Manager_aMonitor%_#%v%_wndIds := aWndId ";" View_#%Manager_aMonitor%_#%v%_wndIds
|
||||
View_setActiveWindow(Manager_aMonitor, v, aWndId)
|
||||
View_#%Manager_aMonitor%_#%v%_aWndId := aWndId
|
||||
If Config_dynamicTiling
|
||||
View_arrange(Manager_aMonitor, v)
|
||||
Manager_winActivate(aWndId)
|
||||
|
@ -1031,15 +1037,22 @@ Manager_initial_sync(doRestore) {
|
|||
}
|
||||
|
||||
Manager_unmanage(wndId) {
|
||||
Local a, aView, aWndId
|
||||
Local a, aView, wndId0, wndIds
|
||||
|
||||
;; 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
|
||||
a := Window_#%wndId%_tags & 1 << aView - 1
|
||||
StringTrimRight, wndIds, View_#%Manager_aMonitor%_#%aView%_wndIds, 1
|
||||
StringSplit, wndId, wndIds, `;
|
||||
If (wndId0 >= 2)
|
||||
View_activateWindow(0, +1)
|
||||
Else
|
||||
Manager_winActivate(0)
|
||||
|
||||
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 ";",, All
|
||||
StringReplace, View_#%Manager_aMonitor%_#%A_Index%_aWndIds, View_#%Manager_aMonitor%_#%A_Index%_aWndIds, % wndId ";",, All
|
||||
StringReplace, View_#%Manager_aMonitor%_#%A_Index%_wndIds, View_#%Manager_aMonitor%_#%A_Index%_wndIds, %wndId%`;,
|
||||
Bar_updateView(Manager_aMonitor, A_Index)
|
||||
}
|
||||
}
|
||||
|
@ -1048,12 +1061,9 @@ Manager_unmanage(wndId) {
|
|||
Window_#%wndId%_isDecorated :=
|
||||
Window_#%wndId%_isFloating :=
|
||||
Window_#%wndId%_area :=
|
||||
StringReplace, Bar_hideTitleWndIds, Bar_hideTitleWndIds, % wndId ";",, All
|
||||
StringReplace, Manager_allWndIds, Manager_allWndIds, % wndId ";",, All
|
||||
StringReplace, Manager_managedWndIds, Manager_managedWndIds, % wndId ";",, All
|
||||
|
||||
aWndId := View_getActiveWindow(Manager_aMonitor, aView)
|
||||
Manager_winActivate(aWndId)
|
||||
StringReplace, Bar_hideTitleWndIds, Bar_hideTitleWndIds, %wndId%`;,
|
||||
StringReplace, Manager_allWndIds, Manager_allWndIds, %wndId%`;,
|
||||
StringReplace, Manager_managedWndIds, Manager_managedWndIds, %wndId%`;, , All
|
||||
|
||||
Return, a
|
||||
}
|
||||
|
|
|
@ -51,9 +51,9 @@ Monitor_activateView(i, d = 0) {
|
|||
}
|
||||
|
||||
aView := Monitor_#%Manager_aMonitor%_aView_#1
|
||||
WinGet, aWndId, ID, A
|
||||
If WinExist("ahk_id" aWndId) And InStr(View_#%Manager_aMonitor%_#%aView%_wndIds, aWndId ";") And Window_isProg(aWndId)
|
||||
View_setActiveWindow(Manager_aMonitor, aView, aWndId)
|
||||
aWndId := View_getActiveWindow(Manager_aMonitor, aView)
|
||||
If aWndId
|
||||
View_#%Manager_aMonitor%_#%aView%_aWndId := aWndId
|
||||
|
||||
n := Config_syncMonitorViews
|
||||
If (n = 1)
|
||||
|
@ -93,7 +93,14 @@ Monitor_activateView(i, d = 0) {
|
|||
Bar_updateView(m, i)
|
||||
}
|
||||
|
||||
wndId := View_getActiveWindow(Manager_aMonitor, i)
|
||||
wndId := View_#%Manager_aMonitor%_#%i%_aWndId
|
||||
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_#%Manager_aMonitor%_#%i%_aWndId := wndId
|
||||
} Else
|
||||
wndId := 0
|
||||
}
|
||||
Manager_winActivate(wndId)
|
||||
}
|
||||
|
||||
|
@ -204,7 +211,7 @@ Monitor_setWindowTag(i, d = 0) {
|
|||
Loop, % Config_viewCount {
|
||||
If Not (Window_#%aWndId%_tags & (1 << A_Index - 1)) {
|
||||
View_#%Manager_aMonitor%_#%A_Index%_wndIds := aWndId ";" View_#%Manager_aMonitor%_#%A_Index%_wndIds
|
||||
View_setActiveWindow(Manager_aMonitor, A_Index, aWndId)
|
||||
View_#%Manager_aMonitor%_#%A_Index%_aWndId := aWndId
|
||||
Bar_updateView(Manager_aMonitor, A_Index)
|
||||
Window_#%aWndId%_tags += 1 << A_Index - 1
|
||||
}
|
||||
|
@ -213,14 +220,14 @@ Monitor_setWindowTag(i, d = 0) {
|
|||
Loop, % Config_viewCount {
|
||||
If Not (A_index = i) {
|
||||
StringReplace, View_#%Manager_aMonitor%_#%A_Index%_wndIds, View_#%Manager_aMonitor%_#%A_Index%_wndIds, %aWndId%`;,
|
||||
View_setActiveWindow(Manager_aMonitor, A_Index, 0)
|
||||
View_#%Manager_aMonitor%_#%A_Index%_aWndId := 0
|
||||
Bar_updateView(Manager_aMonitor, A_Index)
|
||||
}
|
||||
}
|
||||
|
||||
If Not (Window_#%aWndId%_tags & (1 << i - 1))
|
||||
View_#%Manager_aMonitor%_#%i%_wndIds := aWndId ";" View_#%Manager_aMonitor%_#%i%_wndIds
|
||||
View_setActiveWindow(Manager_aMonitor, i, aWndId)
|
||||
View_#%Manager_aMonitor%_#%i%_aWndId := aWndId
|
||||
Window_#%aWndId%_tags := 1 << i - 1
|
||||
|
||||
aView := Monitor_#%Manager_aMonitor%_aView_#1
|
||||
|
@ -317,7 +324,7 @@ Monitor_toggleWindowTag(i, d = 0) {
|
|||
}
|
||||
} Else {
|
||||
View_#%Manager_aMonitor%_#%i%_wndIds := aWndId ";" View_#%Manager_aMonitor%_#%i%_wndIds
|
||||
View_setActiveWindow(Manager_aMonitor, i, aWndId)
|
||||
View_#%Manager_aMonitor%_#%i%_aWndId := aWndId
|
||||
Bar_updateView(Manager_aMonitor, i)
|
||||
Window_#%aWndId%_tags += 1 << i - 1
|
||||
}
|
||||
|
|
35
src/View.ahk
35
src/View.ahk
|
@ -18,7 +18,7 @@ View_init(m, v)
|
|||
Global
|
||||
|
||||
View_#%m%_#%v%_area_#0 := 0
|
||||
View_#%m%_#%v%_aWndIds := "0;"
|
||||
View_#%m%_#%v%_aWndId := 0
|
||||
View_#%m%_#%v%_layout_#1 := 1
|
||||
View_#%m%_#%v%_layout_#2 := 1
|
||||
View_#%m%_#%v%_layoutAxis_#1 := Config_layoutAxis_#1
|
||||
|
@ -144,25 +144,13 @@ View_arrange(m, v, setLayout = False) {
|
|||
}
|
||||
|
||||
View_getActiveWindow(m, v) {
|
||||
Local wndId
|
||||
Local 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
|
||||
WinGet, aWndId, ID, A
|
||||
If WinExist("ahk_id" aWndId) And InStr(View_#%m%_#%v%_wndIds, aWndId ";") And Window_isProg(aWndId)
|
||||
Return, aWndId
|
||||
Else
|
||||
Return, 0
|
||||
}
|
||||
|
||||
View_getTiledWndIds(m, v)
|
||||
|
@ -209,15 +197,6 @@ View_moveWindow(i=0, d=0) {
|
|||
}
|
||||
}
|
||||
|
||||
View_setActiveWindow(m, v, wndId) {
|
||||
Global
|
||||
|
||||
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) {
|
||||
Local v
|
||||
|
||||
|
|
Loading…
Reference in a new issue