enabled warnings, corrected detected errors

This commit is contained in:
joten 2016-02-12 18:58:58 +01:00
parent 52126dd8cc
commit 5982f0e209
8 changed files with 67 additions and 37 deletions

View file

@ -133,6 +133,7 @@ Bar_init(m) {
Gui, Show, NoActivate Hide x%x1% y%y1% w%wndWidth% h%Bar_height%, %wndTitle%
WinSet, Transparent, %Config_barTransparency%, %wndTitle%
wndId := WinExist(wndTitle)
Bar_appBarData := ""
If (Config_verticalBarPos = "tray" And Monitor_#%m%_taskBarClass) {
trayWndId := WinExist("ahk_class " Monitor_#%m%_taskBarClass)
DllCall("SetParent", "UInt", wndId, "UInt", trayWndId)
@ -160,8 +161,10 @@ Bar_init(m) {
Bar_initCmdGui()
{
Global Bar_#0_#0, Bar_#0_#0H, Bar_#0_#0W, Bar_#0_#1, Bar_cmdGuiIsVisible, Config_backColor_#1_#3, Config_barCommands, Config_fontName, Config_fontSize, Config_foreColor_#1_#3
Global Bar_#0_#0, Bar_#0_#0H, Bar_#0_#0W, Bar_#0_#1, Bar_cmdGuiIsVisible, Config_barCommands, Config_fontName, Config_fontSize
Global Config_backColor_#1_#3, Config_fontColor_#1_#3, Config_foreColor_#1_#3
Bar_#0_#0 := ""
Bar_cmdGuiIsVisible := False
wndTitle := "bug.n_BAR_0"
Gui, 99: Default
@ -454,7 +457,7 @@ Bar_updateTitle() {
WinGetTitle, aWndTitle, ahk_id %aWndId%
If InStr(Bar_hideTitleWndIds, aWndId ";") Or (aWndTitle = "bug.n_BAR_0")
aWndTitle := ""
If Window_#%aWndId%_isFloating
If aWndId And InStr(Manager_managedWndIds, aWndId . ";") And Window_#%aWndId%_isFloating
aWndTitle := "~ " aWndTitle
If (Manager_monitorCount > 1)
aWndTitle := "[" Manager_aMonitor "] " aWndTitle

View file

@ -100,6 +100,7 @@ Config_init() {
Config_autoSaveSession := "auto" ;; "off" | "auto" | "ask"
Config_maintenanceInterval := 5000
Config_hotkeyCount := 0
Config_restoreConfig(Config_filePath)
Config_getSystemSettings()
Config_initColors()
@ -147,6 +148,13 @@ Config_convertSystemColor(systemColor)
Return, rr gg bb
}
Config_edit() {
Global Config_filePath
If FileExist(Config_filePath)
Run, edit %Config_filePath%
}
Config_getSystemSettings() {
Global Config_backColor_#1, Config_foreColor_#1, Config_fontColor_#1
Global Config_backColor_#2, Config_foreColor_#2, Config_fontColor_#2
@ -154,7 +162,7 @@ Config_getSystemSettings() {
Global Config_fontName, Config_fontSize, Config_scalingFactor
If Not Config_fontName {
ncmSize := VarSetCapacity(ncm, 4 * (A_OSVersion = WIN_VISTA ? 11 : 10) + 5 * (28 + 32 * (A_IsUnicode ? 2 : 1)), 0)
ncmSize := VarSetCapacity(ncm, 4 * (A_OSVersion = "WIN_VISTA" ? 11 : 10) + 5 * (28 + 32 * (A_IsUnicode ? 2 : 1)), 0)
NumPut(ncmSize, ncm, 0, "UInt")
DllCall("SystemParametersInfo", "UInt", 0x0029, "UInt", ncmSize, "UInt", &ncm, "UInt", 0)
@ -165,7 +173,7 @@ Config_getSystemSettings() {
;; maestrith: Script Writer (http://www.autohotkey.net/~maestrith/Script Writer/)
}
If Not Config_fontSize {
ncmSize := VarSetCapacity(ncm, 4 * (A_OSVersion = WIN_VISTA ? 11 : 10) + 5 * (28 + 32 * (A_IsUnicode ? 2 : 1)), 0)
ncmSize := VarSetCapacity(ncm, 4 * (A_OSVersion = "WIN_VISTA" ? 11 : 10) + 5 * (28 + 32 * (A_IsUnicode ? 2 : 1)), 0)
NumPut(ncmSize, ncm, 0, "UInt")
DllCall("SystemParametersInfo", "UInt", 0x0029, "UInt", ncmSize, "UInt", &ncm, "UInt", 0)
@ -494,7 +502,7 @@ Config_UI_saveSession() {
!+y::View_traceAreas()
;; Administration
#^e::Run, edit %Config_filePath%
#^e::Config_edit()
#^s::Config_UI_saveSession()
#^r::Reload
#^q::ExitApp

View file

@ -109,7 +109,7 @@ Debug_logWindowInfo(wndId) {
WinGetClass, wndClass, ahk_id %wndId%
WinGet, wndPName, ProcessName, ahk_id %wndId%
WinGet, wndPId, PID, ahk_id %wndId%
If InStr(Bar_hiddenWndIds, wndId)
If InStr(Bar_hideTitleWndIds, wndId . ";")
isHidden := "*"
Else
isHidden := " "

View file

@ -21,10 +21,11 @@ SetTitleMatchMode, fast
SetWinDelay, 10
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance force
;#Warn ; Enable warnings to assist with detecting common errors.
#Warn ; Enable warnings to assist with detecting common errors.
#WinActivateForce
;; Pseudo main function
Main_appDir := ""
If 0 = 1
Main_appDir = %1%

View file

@ -201,9 +201,13 @@ Manager_getWindowInfo() {
text := "ID: " aWndId "`nclass:`t" aWndClass "`ntitle:`t" aWndTitle
If InStr(Bar_hideTitleWndIds, aWndId ";")
text .= " [hidden]"
text .= "`nprocess:`t" aWndPName " [" aWndPId "]`nstyle:`t" aWndStyle "`nmetrics:`tx: " aWndX ", y: " aWndY ", width: " aWndWidth ", height: " aWndHeight "`ntags:`t" Window_#%aWndId%_tags
If Window_#%aWndId%_isFloating
text .= " [floating]"
text .= "`nprocess:`t" aWndPName " [" aWndPId "]`nstyle:`t" aWndStyle "`nmetrics:`tx: " aWndX ", y: " aWndY ", width: " aWndWidth ", height: " aWndHeight
If InStr(Manager_managedWndIds, aWndId ";") {
text .= "`ntags:`t" Window_#%aWndId%_tags
If Window_#%aWndId%_isFloating
text .= " [floating]"
} Else
text .= "`ntags:`t--"
text .= "`n`nConfig_rule=" aWndClass ";" aWndTitle ";;" Manager_getWindowRule(aWndId)
MsgBox, 260, bug.n: Window Information, % text "`n`nCopy text to clipboard?"
IfMsgBox Yes
@ -212,7 +216,7 @@ Manager_getWindowInfo() {
Manager_getWindowList()
{
Local text, v, aWndId, wndIds, aWndTitle
Local text, v, aWndId, aWndTitle, wndIds, wndTitle
v := Monitor_#%Manager_aMonitor%_aView_#1
aWndId := View_getActiveWindow(Manager_aMonitor, v)
@ -237,26 +241,26 @@ Manager_getWindowRule(wndId) {
rule := ""
WinGet, wndMinMax, MinMax, ahk_id %wndId%
If InStr(Manager_managedWndIds, wndId ";")
If InStr(Manager_managedWndIds, wndId ";") {
rule .= "1;"
Else
rule .= "0;"
If (Window_#%wndId%_monitor = "")
rule .= "0;"
Else
rule .= Window_#%wndId%_monitor ";"
If (Window_#%wndId%_tags = "")
rule .= "0;"
Else
rule .= Window_#%wndId%_tags ";"
If Window_#%wndId%_isFloating
rule .= "1;"
Else
rule .= "0;"
If Window_#%wndId%_isDecorated
rule .= "1;"
Else
rule .= "0;"
If (Window_#%wndId%_monitor = "")
rule .= "0;"
Else
rule .= Window_#%wndId%_monitor ";"
If (Window_#%wndId%_tags = "")
rule .= "0;"
Else
rule .= Window_#%wndId%_tags ";"
If Window_#%wndId%_isFloating
rule .= "1;"
Else
rule .= "0;"
If Window_#%wndId%_isDecorated
rule .= "1;"
Else
rule .= "0;"
} Else
rule .= "0;;;;;"
If InStr(Bar_hideTitleWndIds, wndId ";")
rule .= "1;"
Else
@ -293,7 +297,7 @@ Manager_loop(index, increment, lowerBound, upperBound) {
}
Manager__setWinProperties(wndId, isManaged, m, tags, isDecorated, isFloating, hideTitle, action = "") {
Local a
Local a := False
If Not InStr(Manager_allWndIds, wndId ";")
Manager_allWndIds .= wndId ";"
@ -308,6 +312,7 @@ Manager__setWinProperties(wndId, isManaged, m, tags, isDecorated, isFloating, hi
Window_#%wndId%_tags := tags
Window_#%wndId%_isDecorated := isDecorated
Window_#%wndId%_isFloating := isFloating
Window_#%wndId%_isMinimized := False
Window_#%wndId%_area := 0
If Not Config_showBorder
@ -530,6 +535,7 @@ Manager_onShellMessage(wParam, lParam) {
;; Look into the use of AHK synchronization primitives.
If (wParam = 1 Or wParam = 2 Or wParam = 4 Or wParam = 6 Or wParam = 32772) And lParam And Not Manager_hideShow
{
wndIds := ""
isChanged := Manager_sync(wndIds)
If wndIds
isChanged := False
@ -905,7 +911,12 @@ Manager_saveWindowState(filename, nm, nv) {
isManaged := InStr(Manager_managedWndIds, wndId . ";")
isTitleHidden := InStr(Bar_hideTitleWndIds, wndId . ";")
text .= "Window " . wndId . ";" . wndPName . ";" . Window_#%wndId%_monitor . ";" . Window_#%wndId%_tags . ";" . Window_#%wndId%_isFloating . ";" . Window_#%wndId%_isDecorated . ";" . isTitleHidden . ";" . isManaged . ";" . title . "`n"
text .= "Window " . wndId . ";" . wndPName . ";"
If isManaged
text .= Window_#%wndId%_monitor . ";" . Window_#%wndId%_tags . ";" . Window_#%wndId%_isFloating . ";" . Window_#%wndId%_isDecorated . ";"
Else
text .= ";;;;"
text .= isTitleHidden . ";" . isManaged . ";" . title . "`n"
}
DetectHiddenWindows, %detectHidden%
@ -1100,13 +1111,16 @@ Manager_initial_sync(doRestore) {
Manager_sync(ByRef wndIds = "")
{
Local a, flag, shownWndIds, v, visibleWndIds, wndId
a := False
shownWndIds := ""
Loop, % Manager_monitorCount
{
v := Monitor_#%A_Index%_aView_#1
shownWndIds .= View_#%A_Index%_#%v%_wndIds
}
;; Check all visible windows against the known windows
visibleWndIds := ""
WinGet, wndId, List, , ,
Loop, % wndId
{

View file

@ -67,8 +67,8 @@ Tiler_getLayoutSymbol(m, v, n) {
}
Tiler_getMFactorD(m, v, d, dFact) {
Local callD, minD
Static lastCall, mFactD
Local callD, mFactD, minD
Static lastCall := 0
callD := A_TickCount - lastCall
lastCall := A_TickCount
@ -79,6 +79,7 @@ Tiler_getMFactorD(m, v, d, dFact) {
Else
minD := d / dFact**5
mFactD := 0
If (callD < Config_mFactCallInterval And d * mFactD > 0) {
;; Accelerate mFactD, if the last call is inside the time frame and went in the same direction.
mFactD *= dFact

View file

@ -146,6 +146,7 @@ View_getActiveWindow(m, v) {
Local listId, listIds, wndId
listIds := "aWndIds;wndIds"
wndId := 0
Loop, Parse, listIds, `;
{
listId := A_LoopField
@ -174,6 +175,8 @@ View_getTiledWndIds(m, v)
{
Local n, tiledWndIds, wndIds
n := 0
tiledWndIds := ""
StringTrimRight, wndIds, View_#%m%_#%v%_wndIds, 1
Loop, PARSE, wndIds, `;
{
@ -234,7 +237,7 @@ View_moveWindow(i=0, d=0) {
WinGet, aWndId, ID, A
m := Manager_aMonitor
v := Monitor_#%m%_aView_#1
If Tiler_isActive(Manager_aMonitor, v) And InStr(Manager_managedWndIds, aWndId ";") And Not (i = 0 And d = 0) And (i <= View_#%m%_#%v%_area_#0) {
If Tiler_isActive(Manager_aMonitor, v) And InStr(Manager_managedWndIds, aWndId ";") And Not (i = 0 And d = 0) And View_#%m%_#%v%_area_#0 And (i <= View_#%m%_#%v%_area_#0) {
If (i = 0)
i := Manager_loop(Window_#%aWndId%_area, d, 1, View_#%m%_#%v%_area_#0)
Window_move(aWndId, View_#%m%_#%v%_area_#%i%_x, View_#%m%_#%v%_area_#%i%_y, View_#%m%_#%v%_area_#%i%_width, View_#%m%_#%v%_area_#%i%_height)
@ -363,11 +366,11 @@ View_toggleMargins()
{
Local v
Debug_logMessage("DEBUG[3] View_toggleMargins(" . View_#%Manager_aMonitor%_#%v%_margin1 . ", " . View_#%Manager_aMonitor%_#%v%_margin2 . ", " . View_#%Manager_aMonitor%_#%v%_margin3 . ", " . View_#%Manager_aMonitor%_#%v%_margin4 . ")", 3)
If Not (Config_viewMargins = "0;0;0;0")
{
v := Monitor_#%Manager_aMonitor%_aView_#1
Debug_logMessage("DEBUG[3] View_toggleMargins(" . View_#%Manager_aMonitor%_#%v%_margin1 . ", " . View_#%Manager_aMonitor%_#%v%_margin2 . ", " . View_#%Manager_aMonitor%_#%v%_margin3 . ", " . View_#%Manager_aMonitor%_#%v%_margin4 . ")", 3)
If (View_#%Manager_aMonitor%_#%v%_margins = "0;0;0;0")
View_#%Manager_aMonitor%_#%v%_margins := Config_viewMargins
Else

View file

@ -240,7 +240,7 @@ Window_move(wndId, x, y, width, height) {
Local wndMinMax, WM_ENTERSIZEMOVE, WM_EXITSIZEMOVE
Local wndH, wndW, wndX, wndY
If Window_getPosEx(wndId, wndX, wndY, wndW, wndH) And (Abs(wndX - x) < 2 And Abs(wndY - y) < 2 And Abs(wndW - width) < 2 And Abs(wndH - height) < 2)
If Not wndId Window_getPosEx(wndId, wndX, wndY, wndW, wndH) And (Abs(wndX - x) < 2 And Abs(wndY - y) < 2 And Abs(wndW - width) < 2 And Abs(wndH - height) < 2)
Return, 0
If Window_isHung(wndId) {