2012-11-27 03:13:38 +00:00
|
|
|
/*
|
2016-03-09 18:34:57 +00:00
|
|
|
bug.n -- tiling window management
|
|
|
|
Copyright (c) 2010-2015 Joshua Fuhs, joten
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2016-03-09 18:34:57 +00:00
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
@license GNU General Public License version 3
|
|
|
|
../LICENSE.md or <http://www.gnu.org/licenses/>
|
|
|
|
|
|
|
|
@version 9.0.0
|
2012-11-27 03:13:38 +00:00
|
|
|
*/
|
|
|
|
|
2012-12-05 12:39:51 +00:00
|
|
|
Debug_initLog(filename, level = 0, truncateFile = True)
|
2012-11-27 03:13:38 +00:00
|
|
|
{
|
|
|
|
Global Debug_logFilename, Debug_logLevel
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-11-27 03:13:38 +00:00
|
|
|
Debug_logFilename := filename
|
|
|
|
Debug_logLevel := level
|
|
|
|
If truncateFile
|
|
|
|
If FileExist(Debug_logFilename)
|
|
|
|
FileDelete, %Debug_logFilename%
|
|
|
|
}
|
|
|
|
|
2012-12-05 12:39:51 +00:00
|
|
|
Debug_logHelp()
|
2012-11-27 03:13:38 +00:00
|
|
|
{
|
|
|
|
Debug_logMessage("Help Display", 0)
|
|
|
|
Debug_logMessage("Window list columns", 0, False)
|
|
|
|
Debug_logMessage(" ID - Windows ID. Unique, OS-assigned ID", 0, False)
|
|
|
|
Debug_logMessage(" H - Hidden. Whether bug.n thinks this window is hidden.", 0, False)
|
|
|
|
Debug_logMessage(" W - Windows active. This window is active according to Windows.", 0, False)
|
|
|
|
Debug_logMessage(" A - View active. This window is active according to bug.n.", 0, False)
|
|
|
|
Debug_logMessage(" F - Floating. This window should not be positioned and resized by the layout.", 0, False)
|
|
|
|
Debug_logMessage(" D - Decorated. Does the window have a title bar?", 0, False)
|
|
|
|
Debug_logMessage(" R - Responsive. Is responding to messages?", 0, False)
|
|
|
|
Debug_logMessage(" G - Ghost. Is this window a ghost of another hung window?", 0, False)
|
|
|
|
Debug_logMessage(" M - Monitor number.", 0, False)
|
|
|
|
Debug_logMessage(" Tags - Bit-mask of the views in which the window is active.", 0, False)
|
|
|
|
Debug_logMessage(" X - Windows X position.", 0, False)
|
|
|
|
Debug_logMessage(" Y - Windows Y position.", 0, False)
|
|
|
|
Debug_logMessage(" W - Windows width.", 0, False)
|
|
|
|
Debug_logMessage(" H - Windows height.", 0, False)
|
|
|
|
Debug_logMessage(" Style - Windows style.", 0, False)
|
|
|
|
Debug_logMessage(" Proc / Class / Title - Process/Class/Title of the window.", 0, False)
|
|
|
|
}
|
|
|
|
|
2012-12-05 12:39:51 +00:00
|
|
|
Debug_logManagedWindowList()
|
2012-11-27 03:13:38 +00:00
|
|
|
{
|
|
|
|
Local wndIds
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-11-27 03:13:38 +00:00
|
|
|
Debug_logMessage("Window dump for manager")
|
2015-02-27 20:57:10 +00:00
|
|
|
Debug_logMessage("ID`t`tH W A F D R G M`tTags`tX`tY`tW`tH`tStyle`t`tProc / Class / Title", 0, False)
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-11-27 03:13:38 +00:00
|
|
|
StringTrimRight, wndIds, Manager_managedWndIds, 1
|
|
|
|
Loop, PARSE, wndIds, `;
|
|
|
|
{
|
|
|
|
Debug_logWindowInfo(A_LoopField)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-05 12:39:51 +00:00
|
|
|
Debug_logMessage(text, level = 1, includeTimestamp = True)
|
2012-11-27 03:13:38 +00:00
|
|
|
{
|
|
|
|
Global Debug_logFilename, Debug_logLevel
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-11-27 03:13:38 +00:00
|
|
|
If (Debug_logLevel >= level)
|
|
|
|
{
|
2012-12-05 12:39:51 +00:00
|
|
|
If includeTimestamp
|
2012-11-27 03:13:38 +00:00
|
|
|
{
|
|
|
|
FormatTime, time, , yyyy-MM-dd HH:mm:ss
|
|
|
|
text := time " " text
|
|
|
|
}
|
|
|
|
Else
|
|
|
|
text := " " text
|
|
|
|
FileAppend, %text%`r`n, %Debug_logFilename%
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-27 20:57:10 +00:00
|
|
|
Debug_logViewWindowList()
|
|
|
|
{
|
2012-11-27 03:13:38 +00:00
|
|
|
Local v, wndIds
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-11-27 03:13:38 +00:00
|
|
|
v := Monitor_#%Manager_aMonitor%_aView_#1
|
|
|
|
Debug_logMessage("Window dump for active view (" . Manager_aMonitor . ", " . v . ")")
|
2015-02-27 20:57:10 +00:00
|
|
|
Debug_logMessage("ID`t`tH W A F D R G M`tTags`tX`tY`tW`tH`tStyle`t`tProc / Class / Title", 0, False)
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-11-27 03:13:38 +00:00
|
|
|
StringTrimRight, wndIds, View_#%Manager_aMonitor%_#%v%_wndIds, 1
|
2015-02-27 20:57:10 +00:00
|
|
|
Loop, PARSE, wndIds, `;
|
2012-11-27 03:13:38 +00:00
|
|
|
{
|
|
|
|
Debug_logWindowInfo(A_LoopField)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-01 20:28:41 +00:00
|
|
|
Debug_logWindowInfo(wndId) {
|
|
|
|
Local aWndId, detectHidden, text, v
|
2012-11-27 03:13:38 +00:00
|
|
|
Local isBugnActive, isDecorated, isFloating, isGhost, isHidden, isResponsive, isWinFocus
|
2015-02-14 12:52:49 +00:00
|
|
|
Local wndClass, wndH, wndPId, wndPName, wndStyle, wndTitle, wndW, wndX, wndY
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2015-03-01 20:28:41 +00:00
|
|
|
detectHidden := A_DetectHiddenWindows
|
2012-11-27 03:13:38 +00:00
|
|
|
DetectHiddenWindows, On
|
|
|
|
WinGet, aWndId, ID, A
|
|
|
|
If aWndId = %wndId%
|
|
|
|
isWinFocus := "*"
|
|
|
|
Else
|
|
|
|
isWinFocus := " "
|
|
|
|
v := Monitor_#%Manager_aMonitor%_aView_#1
|
2015-03-06 20:28:09 +00:00
|
|
|
If (View_getActiveWindow(Manager_aMonitor, v) = wndId)
|
2012-11-27 03:13:38 +00:00
|
|
|
isBugnActive := "*"
|
|
|
|
Else
|
|
|
|
isBugnActive := " "
|
|
|
|
WinGetTitle, wndTitle, ahk_id %wndId%
|
|
|
|
WinGetClass, wndClass, ahk_id %wndId%
|
2015-02-14 12:52:49 +00:00
|
|
|
WinGet, wndPName, ProcessName, ahk_id %wndId%
|
|
|
|
WinGet, wndPId, PID, ahk_id %wndId%
|
2016-02-12 17:58:58 +00:00
|
|
|
If InStr(Bar_hideTitleWndIds, wndId . ";")
|
2012-11-27 03:13:38 +00:00
|
|
|
isHidden := "*"
|
2012-12-05 12:39:51 +00:00
|
|
|
Else
|
2012-11-27 03:13:38 +00:00
|
|
|
isHidden := " "
|
2016-06-11 20:59:46 +00:00
|
|
|
If InStr(Manager_managedWndIds, wndId . ";") Or Window_#%wndId%_isFloating
|
2012-11-27 03:13:38 +00:00
|
|
|
isFloating := "*"
|
|
|
|
Else
|
|
|
|
isFloating := " "
|
2015-01-25 18:38:10 +00:00
|
|
|
If Window_#%wndId%_isDecorated
|
2012-11-27 03:13:38 +00:00
|
|
|
isDecorated := "*"
|
|
|
|
Else
|
|
|
|
isDecorated := " "
|
|
|
|
WinGet, wndStyle, Style, ahk_id %wndId%
|
|
|
|
WinGetPos, wndX, wndY, wndW, wndH, ahk_id %wndId%
|
2015-01-25 18:16:30 +00:00
|
|
|
If Window_isGhost(wndId)
|
2012-11-27 03:13:38 +00:00
|
|
|
isGhost := "*"
|
|
|
|
Else
|
|
|
|
isGhost := " "
|
2015-03-01 20:28:41 +00:00
|
|
|
DetectHiddenWindows, %detectHidden%
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-11-27 03:13:38 +00:00
|
|
|
;; Intentionally don't detect hidden windows here to see what Manager_hungTest does
|
2015-01-25 18:16:30 +00:00
|
|
|
If Window_isHung(wndId)
|
2012-11-27 03:13:38 +00:00
|
|
|
isResponsive := " "
|
|
|
|
Else
|
|
|
|
isResponsive := "*"
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-11-27 03:13:38 +00:00
|
|
|
text := wndId "`t"
|
|
|
|
text .= isHidden " " isWinFocus " " isBugnActive " " isFloating " " isDecorated " " isResponsive " " isGhost " "
|
2015-02-27 20:57:10 +00:00
|
|
|
text .= Window_#%wndId%_monitor "`t" Window_#%wndId%_tags "`t"
|
2015-02-14 12:52:49 +00:00
|
|
|
text .= wndX "`t" wndY "`t" wndW "`t" wndH "`t" wndStyle "`t" wndPName " [" wndPId "] / " wndClass " / " wndTitle
|
2012-11-27 03:13:38 +00:00
|
|
|
Debug_logMessage(text , 0, False)
|
|
|
|
}
|
|
|
|
|
2015-01-27 21:33:13 +00:00
|
|
|
Debug_setLogLevel(i, d) {
|
2012-11-27 03:13:38 +00:00
|
|
|
Global Debug_logLevel
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2015-01-27 21:33:13 +00:00
|
|
|
If (i = 0)
|
|
|
|
i := Debug_logLevel
|
|
|
|
i += d
|
|
|
|
If (i >= 0) And (i != Debug_logLevel) {
|
2012-11-27 03:13:38 +00:00
|
|
|
Debug_logLevel := i
|
|
|
|
If (i = 0)
|
|
|
|
Debug_logMessage("Logging disabled.", 0)
|
|
|
|
Else
|
|
|
|
Debug_logMessage("Log level set to " i ".")
|
|
|
|
}
|
|
|
|
}
|