Cycle through windows correctly when there are hung windows

This commit is contained in:
Joshua Fuhs 2012-06-27 22:35:52 -04:00
parent 034c9c007e
commit 937fed87b9
2 changed files with 47 additions and 12 deletions

View file

@ -491,6 +491,7 @@ Manager_onShellMessage(wParam, lParam) {
wndId := SubStr(wndIds, 1, InStr(wndIds, ";") - 1) wndId := SubStr(wndIds, 1, InStr(wndIds, ";") - 1)
Loop, % Config_viewCount Loop, % Config_viewCount
If (Manager_#%wndId%_tags & 1 << A_Index - 1) { If (Manager_#%wndId%_tags & 1 << A_Index - 1) {
Log_dbg_msg(3, "Switching views because " . wndId . " is considered hidden and active")
Manager_aMonitor := Manager_#%wndId%_monitor Manager_aMonitor := Manager_#%wndId%_monitor
Monitor_activateView(A_Index) Monitor_activateView(A_Index)
Break Break
@ -719,6 +720,10 @@ Manager_winActivate(wndId) {
} Else } Else
DllCall("SetCursorPos", "Int", Round(Monitor_#%Manager_aMonitor%_x + Monitor_#%Manager_aMonitor%_width / 2), "Int", Round(Monitor_#%Manager_aMonitor%_y + Monitor_#%Manager_aMonitor%_height / 2)) DllCall("SetCursorPos", "Int", Round(Monitor_#%Manager_aMonitor%_x + Monitor_#%Manager_aMonitor%_width / 2), "Int", Round(Monitor_#%Manager_aMonitor%_y + Monitor_#%Manager_aMonitor%_height / 2))
} }
SendMessage, 0, , , , ahk_id %wndId%
If ErrorLevel
Log_msg("Manager_winActivate: Potentially hung window " . wndId)
Else
WinActivate, ahk_id %wndId% WinActivate, ahk_id %wndId%
Bar_updateTitle() Bar_updateTitle()
} }
@ -726,16 +731,20 @@ Manager_winActivate(wndId) {
Manager_winMove(wndId, x, y, width, height) { Manager_winMove(wndId, x, y, width, height) {
WM_NULL := 0 WM_NULL := 0
SendMessage, WM_NULL, , , , ahk_id %wndId% SendMessage, WM_NULL, , , , ahk_id %wndId%
If ErrorLevel If ErrorLevel {
Log_msg("Manager_winMove: Potentially hung window " . wndId) Log_msg("Manager_winMove: Potentially hung window " . wndId)
Return 1
}
Else Else
WinRestore, ahk_id %wndId% WinRestore, ahk_id %wndId%
WM_ENTERSIZEMOVE = 0x0231 WM_ENTERSIZEMOVE = 0x0231
WM_EXITSIZEMOVE = 0x0232 WM_EXITSIZEMOVE = 0x0232
SendMessage, WM_ENTERSIZEMOVE, , , , ahk_id %wndId% SendMessage, WM_ENTERSIZEMOVE, , , , ahk_id %wndId%
tmp_errorlevel := ErrorLevel tmp_errorlevel := ErrorLevel
If ErrorLevel If ErrorLevel {
Log_msg("Manager_winMove: Potentially hung window " . wndId) Log_msg("Manager_winMove: Potentially hung window " . wndId)
Return 1
}
Else { Else {
WinMove, ahk_id %wndId%, , %x%, %y%, %width%, %height% WinMove, ahk_id %wndId%, , %x%, %y%, %width%, %height%
SendMessage, WM_EXITSIZEMOVE, , , , ahk_id %wndId% SendMessage, WM_EXITSIZEMOVE, , , , ahk_id %wndId%
@ -745,39 +754,51 @@ Manager_winMove(wndId, x, y, width, height) {
Manager_winHide(wndId) { Manager_winHide(wndId) {
WM_NULL := 0 WM_NULL := 0
SendMessage, WM_NULL, , , , ahk_id %wndId% SendMessage, WM_NULL, , , , ahk_id %wndId%
If ErrorLevel If ErrorLevel {
Log_msg("Manager_winHide: Potentially hung window " . wndId) Log_msg("Manager_winHide: Potentially hung window " . wndId)
Return 1
}
Else { Else {
WinHide, ahk_id %wndId% WinHide, ahk_id %wndId%
Return 0
} }
} }
Manager_winShow(wndId) { Manager_winShow(wndId) {
WM_NULL := 0 WM_NULL := 0
SendMessage, WM_NULL, , , , ahk_id %wndId% SendMessage, WM_NULL, , , , ahk_id %wndId%
If ErrorLevel If ErrorLevel {
Log_msg("Manager_winShow: Potentially hung window " . wndId) Log_msg("Manager_winShow: Potentially hung window " . wndId)
Return 1
}
Else { Else {
WinShow, ahk_id %wndId% WinShow, ahk_id %wndId%
Return 0
} }
} }
Manager_winClose(wndId) { Manager_winClose(wndId) {
WM_NULL := 0 WM_NULL := 0
SendMessage, WM_NULL, , , , ahk_id %wndId% SendMessage, WM_NULL, , , , ahk_id %wndId%
If ErrorLevel If ErrorLevel {
Log_msg("Manager_winClose: Potentially hung window " . wndId) Log_msg("Manager_winClose: Potentially hung window " . wndId)
Return 1
}
Else { Else {
WinClose, ahk_id %wndId% WinClose, ahk_id %wndId%
Return 0
} }
} }
Manager_winSet(type, value, wndId) { Manager_winSet(type, value, wndId) {
WM_NULL := 0 WM_NULL := 0
SendMessage, WM_NULL, , , , ahk_id %wndId% SendMessage, WM_NULL, , , , ahk_id %wndId%
If ErrorLevel If ErrorLevel {
Log_msg("Manager_winSet: Potentially hung window " . wndId) Log_msg("Manager_winSet: Potentially hung window " . wndId)
Return 1
}
Else { Else {
WinSet, %type%, %value%, ahk_id %wndId% WinSet, %type%, %value%, ahk_id %wndId%
Return 0
} }
} }

View file

@ -36,8 +36,13 @@ View_init(m, v) {
} }
View_activateWindow(d) { View_activateWindow(d) {
Local aWndId, i, j, v, wndId, wndId0, wndIds Local aWndId, i, j, v, wndId, wndId0, wndIds, success, direction
Log_dbg_msg(1, "View_activateWindow(" . d . ")") Log_dbg_msg(1, "View_activateWindow(" . d . ")")
If (d = 0)
Return
WinGet, aWndId, ID, A WinGet, aWndId, ID, A
Log_dbg_bare(2, "Active Windows ID: " . aWndId) Log_dbg_bare(2, "Active Windows ID: " . aWndId)
v := Monitor_#%Manager_aMonitor%_aView_#1 v := Monitor_#%Manager_aMonitor%_aView_#1
@ -51,12 +56,21 @@ View_activateWindow(d) {
i := A_Index i := A_Index
Break Break
} }
If (d > 0)
direction = 1
Else
direction = -1
Log_dbg_bare(2, "Current wndId index: " . i) Log_dbg_bare(2, "Current wndId index: " . i)
j := Manager_loop(i, d, 1, wndId0) j := Manager_loop(i, d, 1, wndId0)
Loop, % wndId0 {
Log_dbg_bare(2, "Next wndId index: " . j) Log_dbg_bare(2, "Next wndId index: " . j)
wndId := wndId%j% wndId := wndId%j%
Manager_winSet("AlwaysOnTop", "On", wndId) Manager_winSet("AlwaysOnTop", "On", wndId)
Manager_winSet("AlwaysOnTop", "Off", wndId) success := Manager_winSet("AlwaysOnTop", "Off", wndId)
If (success = 0)
Break
j := Manager_loop(j, direction, 1, wndId0)
}
If Manager_#%aWndId%_isFloating If Manager_#%aWndId%_isFloating
Manager_winSet("Bottom", "", aWndId) Manager_winSet("Bottom", "", aWndId)
Manager_winActivate(wndId) Manager_winActivate(wndId)