BID 018641: Prevent a hang of bug.n due to a hang of an underlying window. The layout gets messed up because of the ghost windows, and cycling through the windows doesn't yet work right.

This commit is contained in:
Joshua Fuhs 2012-06-27 22:00:32 -04:00
parent c76742b25d
commit 034c9c007e
3 changed files with 75 additions and 25 deletions

View file

@ -156,10 +156,10 @@ Manager_cleanup() {
Manager_hideShow := True Manager_hideShow := True
Loop, PARSE, wndIds, `; Loop, PARSE, wndIds, `;
{ {
WinShow, ahk_id %A_LoopField% Manager_winShow(A_LoopField)
If Not Config_showBorder If Not Config_showBorder
WinSet, Style, +0x40000, ahk_id %A_LoopField% Manager_winSet("Style", "+0x40000", A_LoopField)
WinSet, Style, +0xC00000, ahk_id %A_LoopField% Manager_winSet("Style", "+0xC00000", A_LoopField)
} }
; Show the task bar. ; Show the task bar.
@ -176,8 +176,8 @@ Manager_cleanup() {
Loop, % Config_viewCount Loop, % Config_viewCount
View_arrange(m, A_Index) View_arrange(m, A_Index)
} }
WinSet, AlwaysOnTop, On, ahk_id %aWndId% Manager_winSet("AlwaysOnTop", "On", aWndId)
WinSet, AlwaysOnTop, Off, ahk_id %aWndId% Manager_winSet("AlwaysOnTop", "Off", aWndId)
DllCall("Shell32.dll\SHAppBarMessage", "UInt", (ABM_REMOVE := 0x1), "UInt", &Bar_appBarData) DllCall("Shell32.dll\SHAppBarMessage", "UInt", (ABM_REMOVE := 0x1), "UInt", &Bar_appBarData)
; SKAN: Crazy Scripting : Quick Launcher for Portable Apps (http://www.autohotkey.com/forum/topic22398.html) ; SKAN: Crazy Scripting : Quick Launcher for Portable Apps (http://www.autohotkey.com/forum/topic22398.html)
@ -188,7 +188,7 @@ Manager_closeWindow() {
WinGetClass, aWndClass, ahk_id %aWndId% WinGetClass, aWndClass, ahk_id %aWndId%
WinGetTitle, aWndTitle, ahk_id %aWndId% WinGetTitle, aWndTitle, ahk_id %aWndId%
If Not (aWndClass = "AutoHotkeyGUI" And RegExMatch(aWndTitle, "bug.n_BAR_[0-9]+")) If Not (aWndClass = "AutoHotkeyGUI" And RegExMatch(aWndTitle, "bug.n_BAR_[0-9]+"))
WinClose, ahk_id %aWndId% Manager_winClose(aWndId)
} }
Manager_getWindowInfo() { Manager_getWindowInfo() {
@ -372,9 +372,9 @@ Manager_manage(pm, pv, wndId) {
} }
If Not Config_showBorder If Not Config_showBorder
WinSet, Style, -0x40000, ahk_id %wndId% Manager_winSet("Style", "-0x40000", wndId)
If Not Manager_#%wndId%_isDecorated If Not Manager_#%wndId%_isDecorated
WinSet, Style, -0xC00000, ahk_id %wndId% Manager_winSet("Style", "-0xC00000", wndId)
a := Manager_#%wndId%_tags & 1 << Monitor_#%m%_aView_#1 - 1 a := Manager_#%wndId%_tags & 1 << Monitor_#%m%_aView_#1 - 1
If a { If a {
@ -382,7 +382,7 @@ Manager_manage(pm, pv, wndId) {
Manager_winActivate(wndId) Manager_winActivate(wndId)
} Else { } Else {
Manager_hideShow := True Manager_hideShow := True
WinHide, ahk_id %wndId% Manager_winHide(wndId)
Manager_hideShow := False Manager_hideShow := False
} }
} }
@ -403,7 +403,7 @@ Manager_maximizeWindow() {
l := View_#%Manager_aMonitor%_#%v%_layout_#1 l := View_#%Manager_aMonitor%_#%v%_layout_#1
If Not Manager_#%aWndId%_isFloating And Not (Config_layoutFunction_#%l% = "") If Not Manager_#%aWndId%_isFloating And Not (Config_layoutFunction_#%l% = "")
View_toggleFloating() View_toggleFloating()
WinSet, Top,, ahk_id %aWndId% Manager_winSet("Top", "", aWndId)
Manager_winMove(aWndId, Monitor_#%Manager_aMonitor%_x, Monitor_#%Manager_aMonitor%_y, Monitor_#%Manager_aMonitor%_width, Monitor_#%Manager_aMonitor%_height) Manager_winMove(aWndId, Monitor_#%Manager_aMonitor%_x, Monitor_#%Manager_aMonitor%_y, Monitor_#%Manager_aMonitor%_width, Monitor_#%Manager_aMonitor%_height)
} }
@ -416,7 +416,7 @@ Manager_moveWindow() {
l := View_#%Manager_aMonitor%_#%v%_layout_#1 l := View_#%Manager_aMonitor%_#%v%_layout_#1
If Not Manager_#%aWndId%_isFloating And Not (Config_layoutFunction_#%l% = "") If Not Manager_#%aWndId%_isFloating And Not (Config_layoutFunction_#%l% = "")
View_toggleFloating() View_toggleFloating()
WinSet, Top,, ahk_id %aWndId% Manager_winSet("Top", "", aWndId)
WM_SYSCOMMAND = 0x112 WM_SYSCOMMAND = 0x112
SC_MOVE = 0xF010 SC_MOVE = 0xF010
@ -501,7 +501,7 @@ Manager_onShellMessage(wParam, lParam) {
; Otherwise re-hide them. ; Otherwise re-hide them.
If (Config_onActiveHiddenWnds = "hide") { If (Config_onActiveHiddenWnds = "hide") {
Loop, % wndId0 Loop, % wndId0
WinHide, % "ahk_id " wndId%A_Index% Manager_winHide(wndId%A_Index%)
} Else If (Config_onActiveHiddenWnds = "tag") { } Else If (Config_onActiveHiddenWnds = "tag") {
; Or tag all of them for the current view. ; Or tag all of them for the current view.
t := Monitor_#%Manager_aMonitor%_aView_#1 t := Monitor_#%Manager_aMonitor%_aView_#1
@ -596,7 +596,7 @@ Manager_sizeWindow() {
l := View_#%Manager_aMonitor%_#%v%_layout_#1 l := View_#%Manager_aMonitor%_#%v%_layout_#1
If Not Manager_#%aWndId%_isFloating And Not (Config_layoutFunction_#%l% = "") If Not Manager_#%aWndId%_isFloating And Not (Config_layoutFunction_#%l% = "")
View_toggleFloating() View_toggleFloating()
WinSet, Top,, ahk_id %aWndId% Manager_winSet("Top", "", aWndId)
WM_SYSCOMMAND = 0x112 WM_SYSCOMMAND = 0x112
SC_SIZE = 0xF000 SC_SIZE = 0xF000
@ -684,9 +684,9 @@ Manager_toggleDecor() {
WinGet, aWndId, ID, A WinGet, aWndId, ID, A
Manager_#%aWndId%_isDecorated := Not Manager_#%aWndId%_isDecorated Manager_#%aWndId%_isDecorated := Not Manager_#%aWndId%_isDecorated
If Manager_#%aWndId%_isDecorated If Manager_#%aWndId%_isDecorated
WinSet, Style, +0xC00000, ahk_id %aWndId% Manager_winSet("Style", "+0xC00000", aWndId)
Else Else
WinSet, Style, -0xC00000, ahk_id %aWndId% Manager_winSet("Style", "-0xC00000", aWndId)
} }
Manager_unmanage(wndId) { Manager_unmanage(wndId) {
@ -724,10 +724,60 @@ Manager_winActivate(wndId) {
} }
Manager_winMove(wndId, x, y, width, height) { Manager_winMove(wndId, x, y, width, height) {
WinRestore, ahk_id %wndId% WM_NULL := 0
SendMessage, WM_NULL, , , , ahk_id %wndId%
If ErrorLevel
Log_msg("Manager_winMove: Potentially hung window " . wndId)
Else
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%
WinMove, ahk_id %wndId%, , %x%, %y%, %width%, %height% tmp_errorlevel := ErrorLevel
SendMessage, WM_EXITSIZEMOVE, , , , ahk_id %wndId% If ErrorLevel
Log_msg("Manager_winMove: Potentially hung window " . wndId)
Else {
WinMove, ahk_id %wndId%, , %x%, %y%, %width%, %height%
SendMessage, WM_EXITSIZEMOVE, , , , ahk_id %wndId%
}
} }
Manager_winHide(wndId) {
WM_NULL := 0
SendMessage, WM_NULL, , , , ahk_id %wndId%
If ErrorLevel
Log_msg("Manager_winHide: Potentially hung window " . wndId)
Else {
WinHide, ahk_id %wndId%
}
}
Manager_winShow(wndId) {
WM_NULL := 0
SendMessage, WM_NULL, , , , ahk_id %wndId%
If ErrorLevel
Log_msg("Manager_winShow: Potentially hung window " . wndId)
Else {
WinShow, ahk_id %wndId%
}
}
Manager_winClose(wndId) {
WM_NULL := 0
SendMessage, WM_NULL, , , , ahk_id %wndId%
If ErrorLevel
Log_msg("Manager_winClose: Potentially hung window " . wndId)
Else {
WinClose, ahk_id %wndId%
}
}
Manager_winSet(type, value, wndId) {
WM_NULL := 0
SendMessage, WM_NULL, , , , ahk_id %wndId%
If ErrorLevel
Log_msg("Manager_winSet: Potentially hung window " . wndId)
Else {
WinSet, %type%, %value%, ahk_id %wndId%
}
}

View file

@ -80,7 +80,7 @@ Monitor_activateView(v) {
StringTrimRight, wndIds, View_#%m%_#%aView%_wndIds, 1 StringTrimRight, wndIds, View_#%m%_#%aView%_wndIds, 1
Loop, PARSE, wndIds, `; Loop, PARSE, wndIds, `;
If Not (Manager_#%A_LoopField%_tags & (1 << v - 1)) If Not (Manager_#%A_LoopField%_tags & (1 << v - 1))
WinHide, ahk_id %A_LoopField% Manager_winHide(A_LoopField)
SetWinDelay, 10 SetWinDelay, 10
DetectHiddenWindows, On DetectHiddenWindows, On
View_arrange(m, v) View_arrange(m, v)
@ -88,7 +88,7 @@ Monitor_activateView(v) {
StringTrimRight, wndIds, View_#%m%_#%v%_wndIds, 1 StringTrimRight, wndIds, View_#%m%_#%v%_wndIds, 1
SetWinDelay, 0 SetWinDelay, 0
Loop, PARSE, wndIds, `; Loop, PARSE, wndIds, `;
WinShow, ahk_id %A_LoopField% Manager_winShow(A_LoopField)
SetWinDelay, 10 SetWinDelay, 10
Manager_hideShow := False Manager_hideShow := False
@ -225,7 +225,7 @@ Monitor_setWindowTag(t) {
Monitor_activateView(t) Monitor_activateView(t)
Else { Else {
Manager_hideShow := True Manager_hideShow := True
WinHide, ahk_id %aWndId% Manager_winHide(aWndId)
Manager_hideShow := False Manager_hideShow := False
View_arrange(Manager_aMonitor, aView) View_arrange(Manager_aMonitor, aView)
Bar_updateView(Manager_aMonitor, t) Bar_updateView(Manager_aMonitor, t)
@ -278,7 +278,7 @@ Monitor_toggleWindowTag(t) {
Bar_updateView(Manager_aMonitor, t) Bar_updateView(Manager_aMonitor, t)
If (t = Monitor_#%Manager_aMonitor%_aView_#1) { If (t = Monitor_#%Manager_aMonitor%_aView_#1) {
Manager_hideShow := True Manager_hideShow := True
WinHide, ahk_id %aWndId% Manager_winHide(aWndId)
Manager_hideShow := False Manager_hideShow := False
wndId := SubStr(View_#%Manager_aMonitor%_#%t%_wndIds, 1, InStr(View_#%Manager_aMonitor%_#%t%_wndIds, ";")-1) wndId := SubStr(View_#%Manager_aMonitor%_#%t%_wndIds, 1, InStr(View_#%Manager_aMonitor%_#%t%_wndIds, ";")-1)
Manager_winActivate(wndId) Manager_winActivate(wndId)

View file

@ -55,10 +55,10 @@ View_activateWindow(d) {
j := Manager_loop(i, d, 1, wndId0) j := Manager_loop(i, d, 1, wndId0)
Log_dbg_bare(2, "Next wndId index: " . j) Log_dbg_bare(2, "Next wndId index: " . j)
wndId := wndId%j% wndId := wndId%j%
WinSet, AlwaysOnTop, On, ahk_id %wndId% Manager_winSet("AlwaysOnTop", "On", wndId)
WinSet, AlwaysOnTop, Off, ahk_id %wndId% Manager_winSet("AlwaysOnTop", "Off", wndId)
If Manager_#%aWndId%_isFloating If Manager_#%aWndId%_isFloating
WinSet, Bottom, , ahk_id %aWndId% Manager_winSet("Bottom", "", aWndId)
Manager_winActivate(wndId) Manager_winActivate(wndId)
} }
} }