Standardized the switching of "DetectHiddenWindows"

This commit is contained in:
joten 2015-03-01 21:28:41 +01:00
parent 365c6b060f
commit 770349754d
4 changed files with 21 additions and 22 deletions

View file

@ -92,13 +92,12 @@ Debug_logViewWindowList()
} }
} }
Debug_logWindowInfo(wndId) Debug_logWindowInfo(wndId) {
{ Local aWndId, detectHidden, text, v
Local aWndId, detectSetting, text, v
Local isBugnActive, isDecorated, isFloating, isGhost, isHidden, isResponsive, isWinFocus Local isBugnActive, isDecorated, isFloating, isGhost, isHidden, isResponsive, isWinFocus
Local wndClass, wndH, wndPId, wndPName, wndStyle, wndTitle, wndW, wndX, wndY Local wndClass, wndH, wndPId, wndPName, wndStyle, wndTitle, wndW, wndX, wndY
detectSetting := A_DetectHiddenWindows detectHidden := A_DetectHiddenWindows
DetectHiddenWindows, On DetectHiddenWindows, On
WinGet, aWndId, ID, A WinGet, aWndId, ID, A
If aWndId = %wndId% If aWndId = %wndId%
@ -132,7 +131,7 @@ Debug_logWindowInfo(wndId)
isGhost := "*" isGhost := "*"
Else Else
isGhost := " " isGhost := " "
DetectHiddenWindows, %detectSetting% DetectHiddenWindows, %detectHidden%
;; Intentionally don't detect hidden windows here to see what Manager_hungTest does ;; Intentionally don't detect hidden windows here to see what Manager_hungTest does
If Window_isHung(wndId) If Window_isHung(wndId)

View file

@ -690,7 +690,7 @@ Manager_restoreWindowBorders()
;; If the state is completely different, this function won't do much. However, if restoring from a crash ;; If the state is completely different, this function won't do much. However, if restoring from a crash
;; or simply restarting bug.n, it should completely recover the window state. ;; or simply restarting bug.n, it should completely recover the window state.
Manager__restoreWindowState(filename) { Manager__restoreWindowState(filename) {
Local vidx, widx, i, j, m, v, candidate_set, view_set, excluded_view_set, view_m0, view_v0, view_list0, wnds0, items0, wndPName, view_var, isManaged, isFloating, isDecorated, hideTitle Local vidx, widx, i, j, m, v, candidate_set, detectHidden, view_set, excluded_view_set, view_m0, view_v0, view_list0, wnds0, items0, wndPName, view_var, isManaged, isFloating, isDecorated, hideTitle
If Not FileExist(filename) If Not FileExist(filename)
Return Return
@ -748,9 +748,10 @@ Manager__restoreWindowState(filename) {
i := items%i% i := items%i%
j := 2 j := 2
detectHidden := A_DetectHiddenWindows
DetectHiddenWindows, On DetectHiddenWindows, On
WinGet, wndPName, ProcessName, ahk_id %i% WinGet, wndPName, ProcessName, ahk_id %i%
DetectHiddenWindows, Off DetectHiddenWindows, %detectHidden%
If Not ( items%j% = wndPName ) { If Not ( items%j% = wndPName ) {
Debug_logMessage("Window ahk_id " . i . " process '" . wndPName . "' doesn't match expected '" . items%j% . "', forgetting this window", 0) Debug_logMessage("Window ahk_id " . i . " process '" . wndPName . "' doesn't match expected '" . items%j% . "', forgetting this window", 0)
Continue Continue
@ -826,7 +827,7 @@ Manager_saveState() {
} }
Manager_saveWindowState(filename, nm, nv) { Manager_saveWindowState(filename, nm, nv) {
Local allWndId0, allWndIds, wndPName, title, text, monitor, wndId, view, isManaged, isTitleHidden Local allWndId0, allWndIds, detectHidden, wndPName, title, text, monitor, wndId, view, isManaged, isTitleHidden
text := "; bug.n - tiling window management`n; @version " VERSION "`n`n" text := "; bug.n - tiling window management`n; @version " VERSION "`n`n"
@ -837,6 +838,7 @@ Manager_saveWindowState(filename, nm, nv) {
; to recover that window. ; to recover that window.
StringTrimRight, allWndIds, Manager_allWndIds, 1 StringTrimRight, allWndIds, Manager_allWndIds, 1
StringSplit, allWndId, allWndIds, `; StringSplit, allWndId, allWndIds, `;
detectHidden := A_DetectHiddenWindows
DetectHiddenWindows, On DetectHiddenWindows, On
Loop, % allWndId0 { Loop, % allWndId0 {
wndId := allWndId%A_Index% wndId := allWndId%A_Index%
@ -851,7 +853,7 @@ Manager_saveWindowState(filename, nm, nv) {
text .= "Window " . wndId . ";" . wndPName . ";" . Window_#%wndId%_monitor . ";" . Window_#%wndId%_tags . ";" . Window_#%wndId%_isFloating . ";" . Window_#%wndId%_isDecorated . ";" . isTitleHidden . ";" . isManaged . ";" . title . "`n" text .= "Window " . wndId . ";" . wndPName . ";" . Window_#%wndId%_monitor . ";" . Window_#%wndId%_tags . ";" . Window_#%wndId%_isFloating . ";" . Window_#%wndId%_isDecorated . ";" . isTitleHidden . ";" . isManaged . ";" . title . "`n"
} }
DetectHiddenWindows, Off DetectHiddenWindows, %detectHidden%
text .= "`n" text .= "`n"

View file

@ -33,7 +33,7 @@ Monitor_init(m, doRestore) {
} }
Monitor_activateView(i, d = 0) { Monitor_activateView(i, d = 0) {
Local aView, aWndId, m, n, wndId, wndIds Local aView, aWndId, detectHidden, m, n, wndId, wndIds
If (i = -1) If (i = -1)
i := Monitor_#%Manager_aMonitor%_aView_#2 i := Monitor_#%Manager_aMonitor%_aView_#2
@ -77,12 +77,13 @@ Monitor_activateView(i, d = 0) {
Window_hide(A_LoopField) Window_hide(A_LoopField)
} }
SetWinDelay, 10 SetWinDelay, 10
detectHidden := A_DetectHiddenWindows
DetectHiddenWindows, On DetectHiddenWindows, On
wndId := View_#%m%_#%i%_aWndId wndId := View_#%m%_#%i%_aWndId
If wndId If wndId
Window_set(wndId, "AlwaysOnTop", "On") Window_set(wndId, "AlwaysOnTop", "On")
View_arrange(m, i) View_arrange(m, i)
DetectHiddenWindows, Off DetectHiddenWindows, %detectHidden%
StringTrimRight, wndIds, View_#%m%_#%i%_wndIds, 1 StringTrimRight, wndIds, View_#%m%_#%i%_wndIds, 1
SetWinDelay, 0 SetWinDelay, 0
Loop, PARSE, wndIds, `; Loop, PARSE, wndIds, `;
@ -266,20 +267,17 @@ Monitor_toggleBar()
Manager_winActivate(Bar_aWndId) Manager_winActivate(Bar_aWndId)
} }
Monitor_toggleNotifyIconOverflowWindow() Monitor_toggleNotifyIconOverflowWindow() {
{
Static wndId Static wndId
If Not WinExist("ahk_class NotifyIconOverflowWindow") If Not WinExist("ahk_class NotifyIconOverflowWindow") {
{
WinGet, wndId, ID, A WinGet, wndId, ID, A
detectHidden := A_DetectHiddenWindows
DetectHiddenWindows, On DetectHiddenWindows, On
WinShow, ahk_class NotifyIconOverflowWindow WinShow, ahk_class NotifyIconOverflowWindow
WinActivate, ahk_class NotifyIconOverflowWindow WinActivate, ahk_class NotifyIconOverflowWindow
DetectHiddenWindows, Off DetectHiddenWindows, %detectHidden%
} } Else {
Else
{
WinHide, ahk_class NotifyIconOverflowWindow WinHide, ahk_class NotifyIconOverflowWindow
WinActivate, ahk_id %wndId% WinActivate, ahk_id %wndId%
} }

View file

@ -96,14 +96,14 @@ Window_isGhost(wndId) {
;; 0 - Not hung ;; 0 - Not hung
;; 1 - Hung ;; 1 - Hung
Window_isHung(wndId) { Window_isHung(wndId) {
Local detectSetting, result, WM_NULL Local detectHidden, result, WM_NULL
WM_NULL = 0 WM_NULL = 0
detectSetting := A_DetectHiddenWindows detectHidden := A_DetectHiddenWindows
DetectHiddenWindows, On DetectHiddenWindows, On
SendMessage, WM_NULL, , , , ahk_id %wndId% SendMessage, WM_NULL, , , , ahk_id %wndId%
result := ErrorLevel result := ErrorLevel
DetectHiddenWindows, %detectSetting% DetectHiddenWindows, %detectHidden%
If result If result
Return, 1 Return, 1