Merge all changes from the depot

This commit is contained in:
Joshua Fuhs 2012-12-05 19:03:27 -05:00
commit 321112bcff
11 changed files with 766 additions and 752 deletions

View file

@ -4,3 +4,4 @@ src/log.txt
syntax: regexp syntax: regexp
.*[cC]onfig.*\.ini .*[cC]onfig.*\.ini
.+\.\w{3}~ .+\.\w{3}~
src/data/_.*.ini

View file

@ -1,32 +1,32 @@
/* /*
bug.n -- tiling window management bug.n -- tiling window management
Copyright (c) 2010-2012 Joshua Fuhs, joten Copyright (c) 2010-2012 Joshua Fuhs, joten
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
@version 8.3.0 @version 8.4.0
*/ */
Bar_init(m) Bar_init(m)
{ {
Local appBarMsg, GuiN, h1, h2, i, text, titleWidth, trayWndId, w, wndId, wndTitle, wndWidth, x1, x2, y1, y2 Local appBarMsg, GuiN, h1, h2, i, text, titleWidth, trayWndId, w, wndId, wndTitle, wndWidth, x1, x2, y1, y2
If (SubStr(Config_barWidth, 0) = "%") If (SubStr(Config_barWidth, 0) = "%")
{ {
StringTrimRight, wndWidth, Config_barWidth, 1 StringTrimRight, wndWidth, Config_barWidth, 1
wndWidth := Round(Monitor_#%m%_width * wndWidth / 100) wndWidth := Round(Monitor_#%m%_width * wndWidth / 100)
} }
Else Else
wndWidth := Config_barWidth wndWidth := Config_barWidth
Monitor_#%m%_barWidth := wndWidth Monitor_#%m%_barWidth := wndWidth
@ -37,7 +37,7 @@ Bar_init(m)
y1 := 0 y1 := 0
y2 := (Bar_ctrlHeight - Bar_textHeight) / 2 y2 := (Bar_ctrlHeight - Bar_textHeight) / 2
h2 := Bar_ctrlHeight - 2 * y2 h2 := Bar_ctrlHeight - 2 * y2
;; Create the GUI window ;; Create the GUI window
wndTitle := "bug.n_BAR_" m wndTitle := "bug.n_BAR_" m
GuiN := (m - 1) + 1 GuiN := (m - 1) + 1
@ -47,14 +47,14 @@ Bar_init(m)
Gui, +AlwaysOnTop -Caption +LabelBar_Gui +LastFound +ToolWindow Gui, +AlwaysOnTop -Caption +LabelBar_Gui +LastFound +ToolWindow
Gui, Color, %Config_normBgColor1% Gui, Color, %Config_normBgColor1%
Gui, Font, c%Config_normFgColor1% s%Config_fontSize%, %Config_fontName% Gui, Font, c%Config_normFgColor1% s%Config_fontSize%, %Config_fontName%
;; Tags ;; Tags
Loop, % Config_viewCount Loop, % Config_viewCount
{ {
i := A_Index i := A_Index
text := " " Config_viewNames_#%i% " " text := " " Config_viewNames_#%i% " "
w := Bar_getTextWidth(text) w := Bar_getTextWidth(text)
Gui, Add, Text, x%x1% y%y1% w%w% h%h1% BackgroundTrans vBar_#%m%_#%i%_view gBar_GuiClick, Gui, Add, Text, x%x1% y%y1% w%w% h%h1% BackgroundTrans vBar_#%m%_#%i%_view gBar_GuiClick,
If (w <= h1) If (w <= h1)
Gui, Add, Progress, x%x1% y%y1% w%w% h%h1% Background%Config_normBgColor1% Vertical vBar_#%m%_#%i%_tagged Gui, Add, Progress, x%x1% y%y1% w%w% h%h1% Background%Config_normBgColor1% Vertical vBar_#%m%_#%i%_tagged
Else Else
@ -67,41 +67,41 @@ Bar_init(m)
i := Config_viewCount + 1 i := Config_viewCount + 1
text := " ?????? " text := " ?????? "
w := Bar_getTextWidth(text) w := Bar_getTextWidth(text)
Gui, Add, Text, x%x1% y%y1% w%w% h%h1% BackgroundTrans vBar_#%m%_#%i%_layout gBar_GuiClick, Gui, Add, Text, x%x1% y%y1% w%w% h%h1% BackgroundTrans vBar_#%m%_#%i%_layout gBar_GuiClick,
Gui, Add, Progress, x%x1% y%y1% w%w% h%h1% Background%Config_normBgColor2% Gui, Add, Progress, x%x1% y%y1% w%w% h%h1% Background%Config_normBgColor2%
Gui, Font, c%Config_normFgColor2% Gui, Font, c%Config_normFgColor2%
Gui, Add, Text, x%x1% y%y2% w%w% h%h2% -Wrap Center BackgroundTrans vBar_#%m%_#%i%, %text% Gui, Add, Text, x%x1% y%y2% w%w% h%h2% -Wrap Center BackgroundTrans vBar_#%m%_#%i%, %text%
titleWidth -= w titleWidth -= w
x1 += w x1 += w
;; The x-position and width of the sub-windows right of the window title are set from the right. ;; The x-position and width of the sub-windows right of the window title are set from the right.
Loop, 4 Loop, 4
{ {
i := Config_viewCount + 7 - A_Index i := Config_viewCount + 7 - A_Index
w := 0 w := 0
If (i = Config_viewCount + 6) If (i = Config_viewCount + 6)
{ ;; Command gui { ;; Command gui
Gui, -Disabled Gui, -Disabled
w := Bar_getTextWidth(" ?? ") w := Bar_getTextWidth(" ?? ")
x2 -= w x2 -= w
titleWidth -= w titleWidth -= w
Gui, Add, Text, x%x2% y%y1% w%w% h%h1% BackgroundTrans vBar_#%m%_#%i% gBar_toggleCommandGui, Gui, Add, Text, x%x2% y%y1% w%w% h%h1% BackgroundTrans vBar_#%m%_#%i% gBar_toggleCommandGui,
Gui, Add, Progress, x%x2% y%y1% w%w% h%h1% Background%Config_normBgColor2% Gui, Add, Progress, x%x2% y%y1% w%w% h%h1% Background%Config_normBgColor2%
Gui, Add, Text, x%x2% y%y2% w%w% h%h2% Center BackgroundTrans, #! Gui, Add, Text, x%x2% y%y2% w%w% h%h2% Center BackgroundTrans, #!
} }
Else If (i = Config_viewCount + 5) And Config_readinTime Else If (i = Config_viewCount + 5) And Config_readinTime
{ ;; Time { ;; Time
w := Bar_getTextWidth(" ??:?? ") w := Bar_getTextWidth(" ??:?? ")
x2 -= w x2 -= w
titleWidth -= w titleWidth -= w
If Config_readinAny() Or Config_readinBat If Config_readinAny() Or Config_readinBat
{ {
Gui, Font, c%Config_normFgColor1% Gui, Font, c%Config_normFgColor1%
Gui, Add, Text, x%x2% y%y1% w%w% h%h1%, Gui, Add, Text, x%x2% y%y1% w%w% h%h1%,
} }
Gui, Add, Text, x%x2% y%y2% w%w% h%h2% BackgroundTrans Center vBar_#%m%_#%i%, ??:?? Gui, Add, Text, x%x2% y%y2% w%w% h%h2% BackgroundTrans Center vBar_#%m%_#%i%, ??:??
} }
Else If (i = Config_viewCount + 4) And Config_readinAny() Else If (i = Config_viewCount + 4) And Config_readinAny()
{ ;; Any { ;; Any
text := Config_readinAny() text := Config_readinAny()
w := Bar_getTextWidth(text) w := Bar_getTextWidth(text)
@ -110,8 +110,8 @@ Bar_init(m)
Gui, Add, Progress, x%x2% y%y1% w%w% h%h1% Background%Config_normBgColor2% Gui, Add, Progress, x%x2% y%y1% w%w% h%h1% Background%Config_normBgColor2%
Gui, Font, c%Config_normFgColor2% Gui, Font, c%Config_normFgColor2%
Gui, Add, Text, x%x2% y%y2% w%w% h%h2% Center BackgroundTrans vBar_#%m%_#%i%, %text% Gui, Add, Text, x%x2% y%y2% w%w% h%h2% Center BackgroundTrans vBar_#%m%_#%i%, %text%
} }
Else If (i = Config_viewCount + 3) And Config_readinBat Else If (i = Config_viewCount + 3) And Config_readinBat
{ ;; Battery level { ;; Battery level
w := Bar_getTextWidth(" BAT: ???% ") w := Bar_getTextWidth(" BAT: ???% ")
x2 -= w x2 -= w
@ -121,10 +121,10 @@ Bar_init(m)
Gui, Add, Text, x%x2% y%y2% w%w% h%h2% BackgroundTrans Center vBar_#%m%_#%i%, BAT: ???`% Gui, Add, Text, x%x2% y%y2% w%w% h%h2% BackgroundTrans Center vBar_#%m%_#%i%, BAT: ???`%
} }
} }
;; Window title (remaining space) ;; Window title (remaining space)
Gui, Add, Text, x%x1% y%y1% w%titleWidth% h%h1%, Gui, Add, Text, x%x1% y%y1% w%titleWidth% h%h1%,
If Not Config_singleRowBar If Not Config_singleRowBar
{ {
titleWidth := wndWidth titleWidth := wndWidth
x1 := 0 x1 := 0
@ -133,9 +133,9 @@ Bar_init(m)
} }
i := Config_viewCount + 2 i := Config_viewCount + 2
Gui, Font, c%Config_normFgColor1% Gui, Font, c%Config_normFgColor1%
Gui, Add, Text, x%x1% y%y1% w%titleWidth% h%h1%, Gui, Add, Text, x%x1% y%y1% w%titleWidth% h%h1%,
Gui, Add, Text, x%x1% y%y2% w%titleWidth% h%h2% BackgroundTrans Center vBar_#%m%_#%i%, Gui, Add, Text, x%x1% y%y2% w%titleWidth% h%h2% BackgroundTrans Center vBar_#%m%_#%i%,
If (Config_horizontalBarPos = "left") If (Config_horizontalBarPos = "left")
x1 := 0 x1 := 0
Else If (Config_horizontalBarPos = "right") Else If (Config_horizontalBarPos = "right")
@ -148,25 +148,25 @@ Bar_init(m)
x1 := Monitor_#%m%_width - wndWidth + Config_horizontalBarPos x1 := Monitor_#%m%_width - wndWidth + Config_horizontalBarPos
If Not (Config_verticalBarPos = "tray" And m = Manager_taskBarMonitor) If Not (Config_verticalBarPos = "tray" And m = Manager_taskBarMonitor)
x1 += Monitor_#%m%_x x1 += Monitor_#%m%_x
Bar_#%m%_titleWidth := titleWidth Bar_#%m%_titleWidth := titleWidth
Monitor_#%m%_barX := x1 Monitor_#%m%_barX := x1
y1 := Monitor_#%m%_barY y1 := Monitor_#%m%_barY
If Monitor_#%m%_showBar If Monitor_#%m%_showBar
Gui, Show, NoActivate x%x1% y%y1% w%wndWidth% h%Bar_height%, %wndTitle% Gui, Show, NoActivate x%x1% y%y1% w%wndWidth% h%Bar_height%, %wndTitle%
Else Else
Gui, Show, NoActivate Hide x%x1% y%y1% w%wndWidth% h%Bar_height%, %wndTitle% Gui, Show, NoActivate Hide x%x1% y%y1% w%wndWidth% h%Bar_height%, %wndTitle%
wndId := WinExist(wndTitle) wndId := WinExist(wndTitle)
If (Config_verticalBarPos = "tray" And m = Manager_taskBarMonitor) If (Config_verticalBarPos = "tray" And m = Manager_taskBarMonitor)
{ {
trayWndId := WinExist("ahk_class Shell_TrayWnd") trayWndId := WinExist("ahk_class Shell_TrayWnd")
DllCall("SetParent", "UInt", wndId, "UInt", trayWndId) DllCall("SetParent", "UInt", wndId, "UInt", trayWndId)
} }
Else Else
{ {
appBarMsg := DllCall("RegisterWindowMessage", Str, "AppBarMsg") appBarMsg := DllCall("RegisterWindowMessage", Str, "AppBarMsg")
;; appBarData: http://msdn2.microsoft.com/en-us/library/ms538008.aspx ;; appBarData: http://msdn2.microsoft.com/en-us/library/ms538008.aspx
VarSetCapacity(Bar_appBarData, 36, 0) VarSetCapacity(Bar_appBarData, 36, 0)
offset := NumPut( 36, Bar_appBarData) offset := NumPut( 36, Bar_appBarData)
@ -178,7 +178,7 @@ Bar_init(m)
offset := NumPut( wndWidth, offset+0) offset := NumPut( wndWidth, offset+0)
offset := NumPut(Bar_height, offset+0) offset := NumPut(Bar_height, offset+0)
offset := NumPut( 1, offset+0) offset := NumPut( 1, offset+0)
DllCall("Shell32.dll\SHAppBarMessage", "UInt", (ABM_NEW := 0x0) , "UInt", &Bar_appBarData) DllCall("Shell32.dll\SHAppBarMessage", "UInt", (ABM_NEW := 0x0) , "UInt", &Bar_appBarData)
DllCall("Shell32.dll\SHAppBarMessage", "UInt", (ABM_QUERYPOS := 0x2), "UInt", &Bar_appBarData) DllCall("Shell32.dll\SHAppBarMessage", "UInt", (ABM_QUERYPOS := 0x2), "UInt", &Bar_appBarData)
DllCall("Shell32.dll\SHAppBarMessage", "UInt", (ABM_SETPOS := 0x3) , "UInt", &Bar_appBarData) DllCall("Shell32.dll\SHAppBarMessage", "UInt", (ABM_SETPOS := 0x3) , "UInt", &Bar_appBarData)
@ -186,10 +186,10 @@ Bar_init(m)
} }
} }
Bar_initCmdGui() Bar_initCmdGui()
{ {
Global Bar_#0_#0, Bar_#0_#0H, Bar_#0_#0W, Bar_cmdGuiIsVisible, Config_barCommands, Config_fontName, Config_fontSize, Config_normBgColor1, Config_normFgColor1 Global Bar_#0_#0, Bar_#0_#0H, Bar_#0_#0W, Bar_cmdGuiIsVisible, Config_barCommands, Config_fontName, Config_fontSize, Config_normBgColor1, Config_normFgColor1
Bar_cmdGuiIsVisible := False Bar_cmdGuiIsVisible := False
wndTitle := "bug.n_BAR_0" wndTitle := "bug.n_BAR_0"
Gui, 99: Default Gui, 99: Default
@ -214,7 +214,7 @@ Bar_cmdGuiEscape:
Return Return
Bar_cmdGuiEnter: Bar_cmdGuiEnter:
If (A_GuiControl = "OK") Or (A_GuiControl = "Bar_#0_#0" And A_GuiControlEvent = "DoubleClick") If (A_GuiControl = "OK") Or (A_GuiControl = "Bar_#0_#0" And A_GuiControlEvent = "DoubleClick")
{ {
Gui, Submit, NoHide Gui, Submit, NoHide
Bar_cmdGuiIsVisible := False Bar_cmdGuiIsVisible := False
@ -225,11 +225,11 @@ Bar_cmdGuiEnter:
} }
Return Return
Bar_getBatteryStatus(ByRef batteryLifePercent, ByRef acLineStatus) Bar_getBatteryStatus(ByRef batteryLifePercent, ByRef acLineStatus)
{ {
VarSetCapacity(powerStatus, (1 + 1 + 1 + 1 + 4 + 4)) VarSetCapacity(powerStatus, (1 + 1 + 1 + 1 + 4 + 4))
success := DllCall("GetSystemPowerStatus", "UInt", &powerStatus) success := DllCall("GetSystemPowerStatus", "UInt", &powerStatus)
If (ErrorLevel != 0 Or success = 0) If (ErrorLevel != 0 Or success = 0)
{ {
MsgBox 16, Power Status, Can't get the power status... MsgBox 16, Power Status, Can't get the power status...
Return Return
@ -249,31 +249,31 @@ Bar_getBatteryStatus(ByRef batteryLifePercent, ByRef acLineStatus)
} }
;; PhiLho: AC/Battery status (http://www.autohotkey.com/forum/topic7633.html) ;; PhiLho: AC/Battery status (http://www.autohotkey.com/forum/topic7633.html)
Bar_getHeight() Bar_getHeight()
{ {
Global Bar_#0_#1, Bar_#0_#1H, Bar_#0_#2, Bar_#0_#2H, Bar_ctrlHeight, Bar_height, Bar_textHeight Global Bar_#0_#1, Bar_#0_#1H, Bar_#0_#2, Bar_#0_#2H, Bar_ctrlHeight, Bar_height, Bar_textHeight
Global Config_fontName, Config_fontSize, Config_singleRowBar, Config_spaciousBar, Config_verticalBarPos Global Config_fontName, Config_fontSize, Config_singleRowBar, Config_spaciousBar, Config_verticalBarPos
wndTitle := "bug.n_BAR_0" wndTitle := "bug.n_BAR_0"
Gui, 99: Default Gui, 99: Default
Gui, Font, s%Config_fontSize%, %Config_fontName% Gui, Font, s%Config_fontSize%, %Config_fontName%
Gui, Add, Text, x0 y0 vBar_#0_#1, | Gui, Add, Text, x0 y0 vBar_#0_#1, |
GuiControlGet, Bar_#0_#1, Pos GuiControlGet, Bar_#0_#1, Pos
Bar_textHeight := Bar_#0_#1H Bar_textHeight := Bar_#0_#1H
If Config_spaciousBar If Config_spaciousBar
{ {
Gui, Add, ComboBox, r9 x0 y0 vBar_#0_#2, | Gui, Add, ComboBox, r9 x0 y0 vBar_#0_#2, |
GuiControlGet, Bar_#0_#2, Pos GuiControlGet, Bar_#0_#2, Pos
Bar_ctrlHeight := Bar_#0_#2H Bar_ctrlHeight := Bar_#0_#2H
} }
Else Else
Bar_ctrlHeight := Bar_textHeight Bar_ctrlHeight := Bar_textHeight
Gui, Destroy Gui, Destroy
Bar_height := Bar_ctrlHeight Bar_height := Bar_ctrlHeight
If Not Config_singleRowBar If Not Config_singleRowBar
Bar_height *= 2 Bar_height *= 2
If (Config_verticalBarPos = "tray") If (Config_verticalBarPos = "tray")
{ {
WinGetPos, , , , buttonH, Start ahk_class Button WinGetPos, , , , buttonH, Start ahk_class Button
WinGetPos, , , , barH, ahk_class Shell_TrayWnd WinGetPos, , , , barH, ahk_class Shell_TrayWnd
@ -287,11 +287,11 @@ Bar_getHeight()
} }
} }
Bar_getTextWidth(x, reverse=False) Bar_getTextWidth(x, reverse=False)
{ {
Global Config_fontSize Global Config_fontSize
If reverse If reverse
{ ;; 'reverse' calculates the number of characters to a given width. { ;; 'reverse' calculates the number of characters to a given width.
w := x w := x
i := w / (Config_fontSize - 1) i := w / (Config_fontSize - 1)
@ -302,8 +302,8 @@ Bar_getTextWidth(x, reverse=False)
Else If (Config_fontSize > 17) Else If (Config_fontSize > 17)
i := w / (Config_fontSize - 4) i := w / (Config_fontSize - 4)
textWidth := i textWidth := i
} }
Else Else
{ ;; 'else' calculates the width to a given string. { ;; 'else' calculates the width to a given string.
textWidth := StrLen(x) * (Config_fontSize - 1) textWidth := StrLen(x) * (Config_fontSize - 1)
If (Config_fontSize = 7 Or (Config_fontSize > 8 And Config_fontSize < 13)) If (Config_fontSize = 7 Or (Config_fontSize > 8 And Config_fontSize < 13))
@ -313,13 +313,13 @@ Bar_getTextWidth(x, reverse=False)
Else If (Config_fontSize > 17) Else If (Config_fontSize > 17)
textWidth := StrLen(x) * (Config_fontSize - 4) textWidth := StrLen(x) * (Config_fontSize - 4)
} }
Return, textWidth Return, textWidth
} }
Bar_GuiClick: Bar_GuiClick:
Manager_winActivate(Bar_aWndId) Manager_winActivate(Bar_aWndId)
If (A_GuiEvent = "Normal") If (A_GuiEvent = "Normal")
{ {
If Not (SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6) = Manager_aMonitor) If Not (SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6) = Manager_aMonitor)
Manager_activateMonitor(SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6) - Manager_aMonitor) Manager_activateMonitor(SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6) - Manager_aMonitor)
@ -332,15 +332,15 @@ Return
Bar_GuiContextMenu: Bar_GuiContextMenu:
Manager_winActivate(Bar_aWndId) Manager_winActivate(Bar_aWndId)
If (A_GuiEvent = "RightClick") If (A_GuiEvent = "RightClick")
{ {
If (SubStr(A_GuiControl, -6) = "_layout") If (SubStr(A_GuiControl, -6) = "_layout")
{ {
If Not (SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6) = Manager_aMonitor) If Not (SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6) = Manager_aMonitor)
Manager_activateMonitor(SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6) - Manager_aMonitor) Manager_activateMonitor(SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6) - Manager_aMonitor)
View_setLayout(">") View_setLayout(">")
} }
Else If (SubStr(A_GuiControl, -4) = "_view") Else If (SubStr(A_GuiControl, -4) = "_view")
{ {
If Not (SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6) = Manager_aMonitor) If Not (SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6) = Manager_aMonitor)
Manager_setWindowMonitor(SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6) - Manager_aMonitor) Manager_setWindowMonitor(SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6) - Manager_aMonitor)
@ -353,13 +353,13 @@ Bar_loop:
Bar_updateStatus() Bar_updateStatus()
Return Return
Bar_move(m) Bar_move(m)
{ {
Local wndTitle, x, y Local wndTitle, x, y
x := Monitor_#%m%_barX x := Monitor_#%m%_barX
y := Monitor_#%m%_barY y := Monitor_#%m%_barY
wndTitle := "bug.n_BAR_" m wndTitle := "bug.n_BAR_" m
WinMove, %wndTitle%, , %x%, %y% WinMove, %wndTitle%, , %x%, %y%
} }
@ -371,18 +371,18 @@ Bar_toggleCommandGui:
Bar_toggleCommandGui() Bar_toggleCommandGui()
Return Return
Bar_toggleCommandGui() Bar_toggleCommandGui()
{ {
Local wndId, x, y Local wndId, x, y
Gui, 99: Default Gui, 99: Default
If Bar_cmdGuiIsVisible If Bar_cmdGuiIsVisible
{ {
Bar_cmdGuiIsVisible := False Bar_cmdGuiIsVisible := False
Gui, Cancel Gui, Cancel
Manager_winActivate(Bar_aWndId) Manager_winActivate(Bar_aWndId)
} }
Else Else
{ {
Bar_cmdGuiIsVisible := True Bar_cmdGuiIsVisible := True
x := Monitor_#%Manager_aMonitor%_barX + Monitor_#%Manager_aMonitor%_barWidth - Bar_#0_#0W x := Monitor_#%Manager_aMonitor%_barX + Monitor_#%Manager_aMonitor%_barWidth - Bar_#0_#0W
@ -396,56 +396,56 @@ Bar_toggleCommandGui()
} }
} }
Bar_toggleVisibility(m) Bar_toggleVisibility(m)
{ {
Local GuiN Local GuiN
GuiN := (m - 1) + 1 GuiN := (m - 1) + 1
If Monitor_#%m%_showBar If Monitor_#%m%_showBar
{ {
If Not (GuiN = 99) Or Bar_cmdGuiIsVisible If Not (GuiN = 99) Or Bar_cmdGuiIsVisible
Gui, %GuiN%: Show Gui, %GuiN%: Show
} }
Else Else
Gui, %GuiN%: Cancel Gui, %GuiN%: Cancel
} }
Bar_updateLayout(m) Bar_updateLayout(m)
{ {
Local aView, GuiN, i Local aView, GuiN, i
aView := Monitor_#%m%_aView_#1 aView := Monitor_#%m%_aView_#1
i := Config_viewCount + 1 i := Config_viewCount + 1
GuiN := (m - 1) + 1 GuiN := (m - 1) + 1
GuiControl, %GuiN%: , Bar_#%m%_#%i%, % View_#%m%_#%aView%_layoutSymbol GuiControl, %GuiN%: , Bar_#%m%_#%i%, % View_#%m%_#%aView%_layoutSymbol
} }
Bar_updateStatus() Bar_updateStatus()
{ {
Local anyContent, anyText, b1, b2, b3, GuiN, i, m Local anyContent, anyText, b1, b2, b3, GuiN, i, m
Loop, % Manager_monitorCount Loop, % Manager_monitorCount
{ {
m := A_Index m := A_Index
GuiN := (m - 1) + 1 GuiN := (m - 1) + 1
Debug_logMessage("DEBUG[6] Bar_updateStatus(): Gui, " . GuiN . ": Default", 6) Debug_logMessage("DEBUG[6] Bar_updateStatus(): Gui, " . GuiN . ": Default", 6)
Gui, %GuiN%: Default Gui, %GuiN%: Default
If Config_readinBat If Config_readinBat
{ {
Bar_getBatteryStatus(b1, b2) Bar_getBatteryStatus(b1, b2)
b3 := SubStr(" " b1, -2) b3 := SubStr(" " b1, -2)
i := Config_viewCount + 3 i := Config_viewCount + 3
If (b1 < 10) And (b2 = "off") If (b1 < 10) And (b2 = "off")
{ ;; Change the color, if the battery level is below 10% { ;; Change the color, if the battery level is below 10%
GuiControl, +Background%Config_normBgColor4% +c%Config_normBgColor2%, Bar_#%m%_#%i%_tagged GuiControl, +Background%Config_normBgColor4% +c%Config_normBgColor2%, Bar_#%m%_#%i%_tagged
GuiControl, +c%Config_selFgColor6%, Bar_#%m%_#%i% GuiControl, +c%Config_selFgColor6%, Bar_#%m%_#%i%
} }
Else If (b2 = "off") Else If (b2 = "off")
{ ;; Change the color, if the pc is not plugged in { ;; Change the color, if the pc is not plugged in
GuiControl, +Background%Config_normBgColor2% +c%Config_normFgColor5%, Bar_#%m%_#%i%_tagged GuiControl, +Background%Config_normBgColor2% +c%Config_normFgColor5%, Bar_#%m%_#%i%_tagged
GuiControl, +c%Config_normFgColor4%, Bar_#%m%_#%i% GuiControl, +c%Config_normFgColor4%, Bar_#%m%_#%i%
} }
Else Else
{ {
GuiControl, +Background%Config_normBgColor3% +c%Config_normFgColor3%, Bar_#%m%_#%i%_tagged GuiControl, +Background%Config_normBgColor3% +c%Config_normFgColor3%, Bar_#%m%_#%i%_tagged
GuiControl, +c%Config_normFgColor2%, Bar_#%m%_#%i% GuiControl, +c%Config_normFgColor2%, Bar_#%m%_#%i%
@ -454,14 +454,14 @@ Bar_updateStatus()
GuiControl, , Bar_#%m%_#%i%, % " BAT: " b3 "% " GuiControl, , Bar_#%m%_#%i%, % " BAT: " b3 "% "
} }
anyText := Config_readinAny() anyText := Config_readinAny()
If anyText If anyText
{ {
i := Config_viewCount + 4 i := Config_viewCount + 4
GuiControlGet, anyContent, , Bar_#%m%_#%i% GuiControlGet, anyContent, , Bar_#%m%_#%i%
If Not (anyText = anyContent) If Not (anyText = anyContent)
GuiControl, , Bar_#%m%_#%i%, % anyText GuiControl, , Bar_#%m%_#%i%, % anyText
} }
If Config_readinTime If Config_readinTime
{ {
i := Config_viewCount + 5 i := Config_viewCount + 5
GuiControl, , Bar_#%m%_#%i%, % " " A_Hour ":" A_Min " " GuiControl, , Bar_#%m%_#%i%, % " " A_Hour ":" A_Min " "
@ -469,13 +469,13 @@ Bar_updateStatus()
} }
} }
Bar_updateTitle(debugMsg = "") Bar_updateTitle(debugMsg = "")
{ {
Local aWndId, aWndTitle, content, GuiN, i, title Local aWndId, aWndTitle, content, GuiN, i, title
If debugMsg If debugMsg
aWndTitle := debugMsg aWndTitle := debugMsg
Else Else
{ {
WinGet, aWndId, ID, A WinGet, aWndId, ID, A
WinGetTitle, aWndTitle, ahk_id %aWndId% WinGetTitle, aWndTitle, ahk_id %aWndId%
@ -487,59 +487,59 @@ Bar_updateTitle(debugMsg = "")
aWndTitle := "[" Manager_aMonitor "] " aWndTitle aWndTitle := "[" Manager_aMonitor "] " aWndTitle
} }
title := " " . aWndTitle . " " title := " " . aWndTitle . " "
If (Bar_getTextWidth(title) > Bar_#%Manager_aMonitor%_titleWidth) If (Bar_getTextWidth(title) > Bar_#%Manager_aMonitor%_titleWidth)
{ ;; Shorten the window title if its length exceeds the width of the bar { ;; Shorten the window title if its length exceeds the width of the bar
i := Bar_getTextWidth(Bar_#%Manager_aMonitor%_titleWidth, True) - 6 i := Bar_getTextWidth(Bar_#%Manager_aMonitor%_titleWidth, True) - 6
StringLeft, title, aWndTitle, i StringLeft, title, aWndTitle, i
title := " " . title . " ... " title := " " . title . " ... "
} }
i := Config_viewCount + 2 i := Config_viewCount + 2
Loop, % Manager_monitorCount Loop, % Manager_monitorCount
{ {
GuiN := (A_Index - 1) + 1 GuiN := (A_Index - 1) + 1
Debug_logMessage("DEBUG[6] Bar_updateTitle(): Gui, " . GuiN . ": Default", 6) Debug_logMessage("DEBUG[6] Bar_updateTitle(): Gui, " . GuiN . ": Default", 6)
Gui, %GuiN%: Default Gui, %GuiN%: Default
GuiControlGet, content, , Bar_#%A_Index%_#%i% GuiControlGet, content, , Bar_#%A_Index%_#%i%
If (A_Index = Manager_aMonitor) If (A_Index = Manager_aMonitor)
{ {
If Not (content = title) If Not (content = title)
GuiControl, , Bar_#%A_Index%_#%i%, % title GuiControl, , Bar_#%A_Index%_#%i%, % title
} Else If Not (content = "") } Else If Not (content = "")
GuiControl, , Bar_#%A_Index%_#%i%, GuiControl, , Bar_#%A_Index%_#%i%,
} }
Bar_aWndId := aWndId Bar_aWndId := aWndId
} }
Bar_updateView(m, v) Bar_updateView(m, v)
{ {
Local managedWndId0, wndId0, wndIds Local managedWndId0, wndId0, wndIds
GuiN := (m - 1) + 1 GuiN := (m - 1) + 1
Gui, %GuiN%: Default Gui, %GuiN%: Default
Debug_logMessage("DEBUG[6] Bar_updateView(): m: " . m . "; Gui, " . GuiN . ": Default", 6) Debug_logMessage("DEBUG[6] Bar_updateView(): m: " . m . "; Gui, " . GuiN . ": Default", 6)
StringTrimRight, wndIds, Manager_managedWndIds, 1 StringTrimRight, wndIds, Manager_managedWndIds, 1
StringSplit, managedWndId, wndIds, `; StringSplit, managedWndId, wndIds, `;
If (v = Monitor_#%m%_aView_#1) If (v = Monitor_#%m%_aView_#1)
{ ;; Set foreground/background colors if the view is the current view. { ;; Set foreground/background colors if the view is the current view.
GuiControl, +Background%Config_selBgColor1% +c%Config_selFgColor2%, Bar_#%m%_#%v%_tagged GuiControl, +Background%Config_selBgColor1% +c%Config_selFgColor2%, Bar_#%m%_#%v%_tagged
GuiControl, +c%Config_selFgColor1%, Bar_#%m%_#%v% GuiControl, +c%Config_selFgColor1%, Bar_#%m%_#%v%
} }
Else If wndId0 Else If wndId0
{ ;; Set foreground/background colors if the view contains windows. { ;; Set foreground/background colors if the view contains windows.
GuiControl, +Background%Config_normBgColor5% +c%Config_normFgColor8%, Bar_#%m%_#%v%_tagged GuiControl, +Background%Config_normBgColor5% +c%Config_normFgColor8%, Bar_#%m%_#%v%_tagged
GuiControl, +c%Config_normFgColor7%, Bar_#%m%_#%v% GuiControl, +c%Config_normFgColor7%, Bar_#%m%_#%v%
} }
Else Else
{ ;; Set foreground/background colors if the view is empty. { ;; Set foreground/background colors if the view is empty.
GuiControl, +Background%Config_normBgColor1% +c%Config_normFgColor8%, Bar_#%m%_#%v%_tagged GuiControl, +Background%Config_normBgColor1% +c%Config_normFgColor8%, Bar_#%m%_#%v%_tagged
GuiControl, +c%Config_normFgColor1%, Bar_#%m%_#%v% GuiControl, +c%Config_normFgColor1%, Bar_#%m%_#%v%
} }
Loop, %Config_viewCount% Loop, %Config_viewCount%
{ {
StringTrimRight, wndIds, View_#%m%_#%A_Index%_wndIds, 1 StringTrimRight, wndIds, View_#%m%_#%A_Index%_wndIds, 1
StringSplit, wndId, wndIds, `; StringSplit, wndId, wndIds, `;

View file

@ -1,27 +1,27 @@
/* /*
bug.n -- tiling window management bug.n -- tiling window management
Copyright (c) 2010-2012 Joshua Fuhs, joten Copyright (c) 2010-2012 Joshua Fuhs, joten
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
@version 8.3.0 @version 8.4.0
*/ */
Config_init() Config_init()
{ {
Local i, key, layout0, layout1, layout2, vNames0, vNames1, vNames2, vNames3, vNames4, vNames5, vNames6, vNames7, vNames8, vNames9 Local i, key, layout0, layout1, layout2, vNames0, vNames1, vNames2, vNames3, vNames4, vNames5, vNames6, vNames7, vNames8, vNames9
;; Status bar ;; Status bar
Config_showBar := True Config_showBar := True
Config_horizontalBarPos := "left" Config_horizontalBarPos := "left"
@ -30,11 +30,11 @@ Config_init()
Config_singleRowBar := True Config_singleRowBar := True
Config_spaciousBar := False Config_spaciousBar := False
Config_fontName := "Lucida Console" Config_fontName := "Lucida Console"
Config_fontSize := Config_fontSize :=
Config_normBgColor := Config_normBgColor :=
Config_normFgColor := Config_normFgColor :=
Config_selBgColor := Config_selBgColor :=
Config_selFgColor := Config_selFgColor :=
Config_barCommands := "Run, explore doc;Monitor_toggleBar();Main_reload();Reload;ExitApp" Config_barCommands := "Run, explore doc;Monitor_toggleBar();Main_reload();Reload;ExitApp"
Config_readinBat := False Config_readinBat := False
Config_readinCpu := False Config_readinCpu := False
@ -44,7 +44,7 @@ Config_init()
Config_readinNetworkLoad := False Config_readinNetworkLoad := False
Config_readinTime := True Config_readinTime := True
Config_readinInterval := 30000 Config_readinInterval := 30000
;; Windows ui elements ;; Windows ui elements
Config_bbCompatibility := False Config_bbCompatibility := False
Config_borderWidth := 0 Config_borderWidth := 0
@ -52,7 +52,7 @@ Config_init()
Config_showTaskBar := False Config_showTaskBar := False
Config_showBorder := True Config_showBorder := True
Config_selBorderColor := "" Config_selBorderColor := ""
;; Window arrangement ;; Window arrangement
Config_viewNames := "1;2;3;4;5;6;7;8;9" Config_viewNames := "1;2;3;4;5;6;7;8;9"
Config_layout_#1 := "[]=;tile" Config_layout_#1 := "[]=;tile"
@ -72,7 +72,7 @@ Config_init()
Config_shellMsgDelay := 350 Config_shellMsgDelay := 350
Config_syncMonitorViews := 0 Config_syncMonitorViews := 0
Config_viewFollowsTagged := False Config_viewFollowsTagged := False
;; Config_rule_#<i> := '<class>;<title>;<style>;<is managed>;<m>;<tags>;<is floating>;<is decorated>;<hide title>;<action>' ;; Config_rule_#<i> := '<class>;<title>;<style>;<is managed>;<m>;<tags>;<is floating>;<is decorated>;<hide title>;<action>'
Config_rule_#1 := ".*;.*;;1;0;0;0;0;0;" ;; default rule Config_rule_#1 := ".*;.*;;1;0;0;0;0;0;" ;; default rule
Config_rule_#2 := ".*;.*;0x80000000;0;0;0;1;1;1;" ;; Pop-up windows (style WS_POPUP=0x80000000) will not be managed, are floating and the titles are hidden. Config_rule_#2 := ".*;.*;0x80000000;0;0;0;1;1;1;" ;; Pop-up windows (style WS_POPUP=0x80000000) will not be managed, are floating and the titles are hidden.
@ -87,18 +87,18 @@ Config_init()
Config_rule_#11 := "MozillaWindowClass;.* - Mozilla Firefox;;1;0;0;0;1;0;Maximize" Config_rule_#11 := "MozillaWindowClass;.* - Mozilla Firefox;;1;0;0;0;1;0;Maximize"
Config_rule_#12 := "Chrome_WidgetWin_1;.*;;1;0;0;0;1;0;Maximize" Config_rule_#12 := "Chrome_WidgetWin_1;.*;;1;0;0;0;1;0;Maximize"
Config_ruleCount := 12 ;; This variable has to be set to the total number of active rules above. Config_ruleCount := 12 ;; This variable has to be set to the total number of active rules above.
;; Configuration management ;; Configuration management
Config_autoSaveSession := "auto" ;; "off" | "auto" | "ask" Config_autoSaveSession := "auto" ;; "off" | "auto" | "ask"
; @todo: To be removed? ; @todo: To be removed?
If Not Config_filePath ; The file path, to which the configuration and session is saved. This target directory must be writable by the user (%A_ScriptDir% is the diretory, in which "Main.ahk" or the executable of bug.n is saved). If Not Config_filePath ; The file path, to which the configuration and session is saved. This target directory must be writable by the user (%A_ScriptDir% is the diretory, in which "Main.ahk" or the executable of bug.n is saved).
Config_filePath := A_ScriptDir "\Config.ini" Config_filePath := A_ScriptDir "\Config.ini"
Config_maintenanceInterval := 5000 Config_maintenanceInterval := 5000
Config_restoreConfig(Config_filePath) Config_restoreConfig(Config_filePath)
Config_getSystemSettings() Config_getSystemSettings()
Config_initColors() Config_initColors()
Loop, % Config_layoutCount Loop, % Config_layoutCount
{ {
StringSplit, layout, Config_layout_#%A_Index%, `; StringSplit, layout, Config_layout_#%A_Index%, `;
Config_layoutFunction_#%A_Index% := layout2 Config_layoutFunction_#%A_Index% := layout2
@ -115,76 +115,76 @@ Config_init()
} }
} }
Config_initColors() Config_initColors()
{ {
Global Global
StringReplace, Config_normBgColor, Config_normBgColor, `;0`;, `;000000`;, All StringReplace, Config_normBgColor, Config_normBgColor, `;0`;, `;000000`;, All
Config_normBgColor := RegExReplace(Config_normBgColor, "^0;", "000000;") Config_normBgColor := RegExReplace(Config_normBgColor, "^0;", "000000;")
Config_normBgColor := RegExReplace(Config_normBgColor, ";0$", ";000000") Config_normBgColor := RegExReplace(Config_normBgColor, ";0$", ";000000")
StringSplit, Config_normBgColor, Config_normBgColor, `; StringSplit, Config_normBgColor, Config_normBgColor, `;
StringReplace, Config_normFgColor, Config_normFgColor, `;0`;, `;000000`;, All StringReplace, Config_normFgColor, Config_normFgColor, `;0`;, `;000000`;, All
Config_normFgColor := RegExReplace(Config_normFgColor, "^0;", "000000;") Config_normFgColor := RegExReplace(Config_normFgColor, "^0;", "000000;")
Config_normFgColor := RegExReplace(Config_normFgColor, ";0$", ";000000") Config_normFgColor := RegExReplace(Config_normFgColor, ";0$", ";000000")
StringSplit, Config_normFgColor, Config_normFgColor, `; StringSplit, Config_normFgColor, Config_normFgColor, `;
StringReplace, Config_selBgColor, Config_selBgColor, `;0`;, `;000000`;, All StringReplace, Config_selBgColor, Config_selBgColor, `;0`;, `;000000`;, All
Config_selBgColor := RegExReplace(Config_selBgColor, "^0;", "000000;") Config_selBgColor := RegExReplace(Config_selBgColor, "^0;", "000000;")
Config_selBgColor := RegExReplace(Config_selBgColor, ";0$", ";000000") Config_selBgColor := RegExReplace(Config_selBgColor, ";0$", ";000000")
StringSplit, Config_selBgColor, Config_selBgColor, `; StringSplit, Config_selBgColor, Config_selBgColor, `;
StringReplace, Config_selFgColor, Config_selFgColor, `;0`;, `;000000`;, All StringReplace, Config_selFgColor, Config_selFgColor, `;0`;, `;000000`;, All
Config_selFgColor := RegExReplace(Config_selFgColor, "^0;", "000000;") Config_selFgColor := RegExReplace(Config_selFgColor, "^0;", "000000;")
Config_selFgColor := RegExReplace(Config_selFgColor, ";0$", ";000000") Config_selFgColor := RegExReplace(Config_selFgColor, ";0$", ";000000")
StringSplit, Config_selFgColor, Config_selFgColor, `; StringSplit, Config_selFgColor, Config_selFgColor, `;
} }
Config_convertSystemColor(systemColor) Config_convertSystemColor(systemColor)
{ ;; systemColor format: 0xBBGGRR { ;; systemColor format: 0xBBGGRR
rr := SubStr(systemColor, 7, 2) rr := SubStr(systemColor, 7, 2)
gg := SubStr(systemColor, 5, 2) gg := SubStr(systemColor, 5, 2)
bb := SubStr(systemColor, 3, 2) bb := SubStr(systemColor, 3, 2)
Return, rr gg bb Return, rr gg bb
} }
Config_getSystemSettings() Config_getSystemSettings()
{ {
Global Config_fontName, Config_fontSize, Config_normBgColor, Config_normFgColor, Config_selBgColor, Config_selFgColor Global Config_fontName, Config_fontSize, Config_normBgColor, Config_normFgColor, Config_selBgColor, Config_selFgColor
If Not Config_fontName 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") NumPut(ncmSize, ncm, 0, "UInt")
DllCall("SystemParametersInfo", "UInt", 0x0029, "UInt", ncmSize, "UInt", &ncm, "UInt", 0) DllCall("SystemParametersInfo", "UInt", 0x0029, "UInt", ncmSize, "UInt", &ncm, "UInt", 0)
VarSetCapacity(lf, 28 + 32 * (A_IsUnicode ? 2 : 1), 0) VarSetCapacity(lf, 28 + 32 * (A_IsUnicode ? 2 : 1), 0)
DllCall("RtlMoveMemory", "Str", lf, "UInt", &ncm + 24, "UInt", 28 + 32 * (A_IsUnicode ? 2 : 1)) DllCall("RtlMoveMemory", "Str", lf, "UInt", &ncm + 24, "UInt", 28 + 32 * (A_IsUnicode ? 2 : 1))
VarSetCapacity(Config_fontName, 32 * (A_IsUnicode ? 2 : 1), 0) VarSetCapacity(Config_fontName, 32 * (A_IsUnicode ? 2 : 1), 0)
DllCall("RtlMoveMemory", "Str", Config_fontName, "UInt", &lf + 28, "UInt", 32 * (A_IsUnicode ? 2 : 1)) DllCall("RtlMoveMemory", "Str", Config_fontName, "UInt", &lf + 28, "UInt", 32 * (A_IsUnicode ? 2 : 1))
;; maestrith: Script Writer (http://www.autohotkey.net/~maestrith/Script Writer/) ;; maestrith: Script Writer (http://www.autohotkey.net/~maestrith/Script Writer/)
} }
If Not Config_fontSize 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") NumPut(ncmSize, ncm, 0, "UInt")
DllCall("SystemParametersInfo", "UInt", 0x0029, "UInt", ncmSize, "UInt", &ncm, "UInt", 0) DllCall("SystemParametersInfo", "UInt", 0x0029, "UInt", ncmSize, "UInt", &ncm, "UInt", 0)
lfSize := VarSetCapacity(lf, 28 + 32 * (A_IsUnicode ? 2 : 1), 0) lfSize := VarSetCapacity(lf, 28 + 32 * (A_IsUnicode ? 2 : 1), 0)
NumPut(lfSize, lf, 0, "UInt") NumPut(lfSize, lf, 0, "UInt")
DllCall("RtlMoveMemory", "Str", lf, "UInt", &ncm + 24, "UInt", 28 + 32 * (A_IsUnicode ? 2 : 1)) DllCall("RtlMoveMemory", "Str", lf, "UInt", &ncm + 24, "UInt", 28 + 32 * (A_IsUnicode ? 2 : 1))
lfHeightSize := VarSetCapacity(lfHeight, 4, 0) lfHeightSize := VarSetCapacity(lfHeight, 4, 0)
NumPut(lfHeightSize, lfHeight, 0, "Int") NumPut(lfHeightSize, lfHeight, 0, "Int")
lfHeight := NumGet(lf, 0, "Int") lfHeight := NumGet(lf, 0, "Int")
lfPixelsY := DllCall("GetDeviceCaps", "UInt", DllCall("GetDC", "UInt", 0), "UInt", 90) ;; LOGPIXELSY lfPixelsY := DllCall("GetDeviceCaps", "UInt", DllCall("GetDC", "UInt", 0), "UInt", 90) ;; LOGPIXELSY
Config_fontSize := -DllCall("MulDiv", "Int", lfHeight, "Int", 72, "Int", lfPixelsY) Config_fontSize := -DllCall("MulDiv", "Int", lfHeight, "Int", 72, "Int", lfPixelsY)
;; maestrith: Script Writer (http://www.autohotkey.net/~maestrith/Script Writer/) ;; maestrith: Script Writer (http://www.autohotkey.net/~maestrith/Script Writer/)
} }
SetFormat, Integer, hex SetFormat, Integer, hex
If Not Config_normBgColor If Not Config_normBgColor
{ {
Config_normBgColor := Config_convertSystemColor(DllCall("GetSysColor", "Int", 4)) ;; COLOR_MENU Config_normBgColor := Config_convertSystemColor(DllCall("GetSysColor", "Int", 4)) ;; COLOR_MENU
Config_normBgColor .= ";" Config_convertSystemColor(DllCall("GetSysColor", "Int", 3)) ;; COLOR_INACTIVECAPTION Config_normBgColor .= ";" Config_convertSystemColor(DllCall("GetSysColor", "Int", 3)) ;; COLOR_INACTIVECAPTION
@ -192,7 +192,7 @@ Config_getSystemSettings()
Config_normBgColor .= ";Red" Config_normBgColor .= ";Red"
Config_normBgColor .= ";" Config_convertSystemColor(DllCall("GetSysColor", "Int", 28)) ;; COLOR_GRADIENTINACTIVECAPTION Config_normBgColor .= ";" Config_convertSystemColor(DllCall("GetSysColor", "Int", 28)) ;; COLOR_GRADIENTINACTIVECAPTION
} }
If Not Config_normFgColor If Not Config_normFgColor
{ {
Config_normFgColor := Config_convertSystemColor(DllCall("GetSysColor", "Int", 7)) ;; COLOR_MENUTEXT Config_normFgColor := Config_convertSystemColor(DllCall("GetSysColor", "Int", 7)) ;; COLOR_MENUTEXT
Config_normFgColor .= ";Default" Config_normFgColor .= ";Default"
@ -203,11 +203,11 @@ Config_getSystemSettings()
Config_normFgColor .= ";Default" Config_normFgColor .= ";Default"
Config_normFgColor .= ";" Config_convertSystemColor(DllCall("GetSysColor", "Int", 3)) ;; COLOR_INACTIVECAPTION Config_normFgColor .= ";" Config_convertSystemColor(DllCall("GetSysColor", "Int", 3)) ;; COLOR_INACTIVECAPTION
} }
If Not Config_selBgColor If Not Config_selBgColor
{ {
Config_selBgColor := Config_convertSystemColor(DllCall("GetSysColor", "Int", 27)) ;; COLOR_GRADIENTACTIVECAPTION Config_selBgColor := Config_convertSystemColor(DllCall("GetSysColor", "Int", 27)) ;; COLOR_GRADIENTACTIVECAPTION
} }
If Not Config_selFgColor If Not Config_selFgColor
{ {
Config_selFgColor := Config_convertSystemColor(DllCall("GetSysColor", "Int", 9)) ;; COLOR_CAPTIONTEXT Config_selFgColor := Config_convertSystemColor(DllCall("GetSysColor", "Int", 9)) ;; COLOR_CAPTIONTEXT
Config_selFgColor .= ";" Config_convertSystemColor(DllCall("GetSysColor", "Int", 2)) ;; COLOR_ACTIVECAPTION Config_selFgColor .= ";" Config_convertSystemColor(DllCall("GetSysColor", "Int", 2)) ;; COLOR_ACTIVECAPTION
@ -219,25 +219,25 @@ Config_hotkeyLabel:
Config_redirectHotkey(A_ThisHotkey) Config_redirectHotkey(A_ThisHotkey)
Return Return
Config_readinAny() Config_readinAny()
{ ;; Add information to the variable 'text' in this function to display it in the status bar. { ;; Add information to the variable 'text' in this function to display it in the status bar.
Global Config_readinDate Global Config_readinDate
text := "" text := ""
text .= ResourceMonitor_getText() text .= ResourceMonitor_getText()
If Config_readinDate If Config_readinDate
text .= " " A_DDD ", " A_DD ". " A_MMM ". " A_YYYY " " text .= " " A_DDD ", " A_DD ". " A_MMM ". " A_YYYY " "
Return, text Return, text
} }
Config_redirectHotkey(key) Config_redirectHotkey(key)
{ {
Global Global
Loop, % Config_hotkeyCount Loop, % Config_hotkeyCount
{ {
If (key = Config_hotkey_#%A_index%_key) If (key = Config_hotkey_#%A_index%_key)
{ {
Main_evalCommand(Config_hotkey_#%A_index%_command) Main_evalCommand(Config_hotkey_#%A_index%_command)
Break Break
@ -245,13 +245,13 @@ Config_redirectHotkey(key)
} }
} }
Config_restoreLayout(filename, m) Config_restoreLayout(filename, m)
{ {
Local i, var, val Local i, var, val
If Not FileExist(filename) If Not FileExist(filename)
Return Return
Loop, READ, %filename% Loop, READ, %filename%
If (SubStr(A_LoopReadLine, 1, 10 + StrLen(m)) = "Monitor_#" m "_" Or SubStr(A_LoopReadLine, 1, 8 + StrLen(m)) = "View_#" m "_#") { If (SubStr(A_LoopReadLine, 1, 10 + StrLen(m)) = "Monitor_#" m "_" Or SubStr(A_LoopReadLine, 1, 8 + StrLen(m)) = "View_#" m "_#") {
i := InStr(A_LoopReadLine, "=") i := InStr(A_LoopReadLine, "=")
@ -261,22 +261,22 @@ Config_restoreLayout(filename, m)
} }
} }
Config_restoreConfig(filename) Config_restoreConfig(filename)
{ {
Local cmd, i, key, type, val, var Local cmd, i, key, type, val, var
If Not FileExist(filename) If Not FileExist(filename)
Return Return
Loop, READ, %filename% Loop, READ, %filename%
If (SubStr(A_LoopReadLine, 1, 7) = "Config_") If (SubStr(A_LoopReadLine, 1, 7) = "Config_")
{ {
;Log_msg("Processing line: " . A_LoopReadLine) ;Log_msg("Processing line: " . A_LoopReadLine)
i := InStr(A_LoopReadLine, "=") i := InStr(A_LoopReadLine, "=")
var := SubStr(A_LoopReadLine, 1, i - 1) var := SubStr(A_LoopReadLine, 1, i - 1)
val := SubStr(A_LoopReadLine, i + 1) val := SubStr(A_LoopReadLine, i + 1)
type := SubStr(var, 1, 13) type := SubStr(var, 1, 13)
If (type = "Config_hotkey") If (type = "Config_hotkey")
{ {
Debug_logMessage("Processing configured hotkey: " . A_LoopReadLine, 0) Debug_logMessage("Processing configured hotkey: " . A_LoopReadLine, 0)
i := InStr(val, "::") i := InStr(val, "::")
@ -284,7 +284,7 @@ Config_restoreConfig(filename)
cmd := SubStr(val, i + 2) cmd := SubStr(val, i + 2)
If Not cmd If Not cmd
Hotkey, %key%, Off Hotkey, %key%, Off
Else Else
{ {
Debug_logMessage(" Hotkey: " . key . " -> " . cmd, 0) Debug_logMessage(" Hotkey: " . key . " -> " . cmd, 0)
Config_hotkeyCount += 1 Config_hotkeyCount += 1
@ -293,12 +293,12 @@ Config_restoreConfig(filename)
Hotkey, %key%, Config_hotkeyLabel Hotkey, %key%, Config_hotkeyLabel
} }
} }
Else If (type = "Config_rule") Else If (type = "Config_rule")
{ {
i := 0 i := 0
If InStr(var, "Config_rule_#") If InStr(var, "Config_rule_#")
i := SubStr(var, 14) i := SubStr(var, 14)
If (i = 0 Or i > Config_ruleCount) If (i = 0 Or i > Config_ruleCount)
{ {
Config_ruleCount += 1 Config_ruleCount += 1
i := Config_ruleCount i := Config_ruleCount
@ -309,20 +309,20 @@ Config_restoreConfig(filename)
} }
} }
Config_UI_saveSession() Config_UI_saveSession()
{ {
Config_saveSession(Config_filePath, Config_filePath) Config_saveSession(Config_filePath, Config_filePath)
} }
Config_saveSession(original, target) Config_saveSession(original, target)
{ {
Local m, text, tmpfilename Local m, text, tmpfilename
tmpfilename := target . ".tmp" tmpfilename := target . ".tmp"
FileDelete, %tmpfilename% FileDelete, %tmpfilename%
text := "; bug.n - tiling window management`n; @version " VERSION "`n`n" text := "; bug.n - tiling window management`n; @version " VERSION "`n`n"
If FileExist(original) If FileExist(original)
{ {
Loop, READ, %original% Loop, READ, %original%
{ {
@ -331,8 +331,8 @@ Config_saveSession(original, target)
} }
text .= "`n" text .= "`n"
} }
Loop, % Manager_monitorCount Loop, % Manager_monitorCount
{ {
m := A_Index m := A_Index
If Not (Monitor_#%m%_aView_#1 = 1) If Not (Monitor_#%m%_aView_#1 = 1)
@ -341,7 +341,7 @@ Config_saveSession(original, target)
text .= "Monitor_#" m "_aView_#2=" Monitor_#%m%_aView_#2 "`n" text .= "Monitor_#" m "_aView_#2=" Monitor_#%m%_aView_#2 "`n"
If Not (Monitor_#%m%_showBar = Config_showBar) If Not (Monitor_#%m%_showBar = Config_showBar)
text .= "Monitor_#" m "_showBar=" Monitor_#%m%_showBar "`n" text .= "Monitor_#" m "_showBar=" Monitor_#%m%_showBar "`n"
Loop, % Config_viewCount Loop, % Config_viewCount
{ {
If Not (View_#%m%_#%A_Index%_layout_#1 = 1) If Not (View_#%m%_#%A_Index%_layout_#1 = 1)
text .= "View_#" m "_#" A_Index "_layout_#1=" View_#%m%_#%A_Index%_layout_#1 "`n" text .= "View_#" m "_#" A_Index "_layout_#1=" View_#%m%_#%A_Index%_layout_#1 "`n"
@ -363,11 +363,11 @@ Config_saveSession(original, target)
text .= "View_#" m "_#" A_Index "_layoutMY=" View_#%m%_#%A_Index%_layoutMY "`n" text .= "View_#" m "_#" A_Index "_layoutMY=" View_#%m%_#%A_Index%_layoutMY "`n"
} }
} }
;; The FileMove below is an all-or-nothing replacement of the file. ;; The FileMove below is an all-or-nothing replacement of the file.
;; We don't want to leave this half-finished. ;; We don't want to leave this half-finished.
FileAppend, %text%, %tmpfilename% FileAppend, %text%, %tmpfilename%
If ErrorLevel If ErrorLevel
{ {
If FileExist(tmpfilename) If FileExist(tmpfilename)
FileDelete, %tmpfilename% FileDelete, %tmpfilename%

View file

@ -1,27 +1,27 @@
/* /*
bug.n -- tiling window management bug.n -- tiling window management
Copyright (c) 2010-2012 Joshua Fuhs, joten Copyright (c) 2010-2012 Joshua Fuhs, joten
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
@version 8.3.0 @version 8.4.0
*/ */
Debug_initLog(filename, level = 0, truncateFile = True) Debug_initLog(filename, level = 0, truncateFile = True)
{ {
Global Debug_logFilename, Debug_logLevel Global Debug_logFilename, Debug_logLevel
Debug_logFilename := filename Debug_logFilename := filename
Debug_logLevel := level Debug_logLevel := level
If truncateFile If truncateFile
@ -29,7 +29,7 @@ Debug_initLog(filename, level = 0, truncateFile = True)
FileDelete, %Debug_logFilename% FileDelete, %Debug_logFilename%
} }
Debug_logHelp() Debug_logHelp()
{ {
Debug_logMessage("Help Display", 0) Debug_logMessage("Help Display", 0)
Debug_logMessage("Window list columns", 0, False) Debug_logMessage("Window list columns", 0, False)
@ -51,13 +51,13 @@ Debug_logHelp()
Debug_logMessage(" Proc / Class / Title - Process/Class/Title of the window.", 0, False) Debug_logMessage(" Proc / Class / Title - Process/Class/Title of the window.", 0, False)
} }
Debug_logManagedWindowList() Debug_logManagedWindowList()
{ {
Local wndIds Local wndIds
Debug_logMessage("Window dump for manager") Debug_logMessage("Window dump for manager")
Debug_logMessage("ID`t`tH W A F D R G M`tTags`tX`tY`tW`tH`tStyle`t`tProc / Class / Title", 0, False) Debug_logMessage("ID`t`tH W A F D R G M`tTags`tX`tY`tW`tH`tStyle`t`tProc / Class / Title", 0, False)
StringTrimRight, wndIds, Manager_managedWndIds, 1 StringTrimRight, wndIds, Manager_managedWndIds, 1
Loop, PARSE, wndIds, `; Loop, PARSE, wndIds, `;
{ {
@ -65,13 +65,13 @@ Debug_logManagedWindowList()
} }
} }
Debug_logMessage(text, level = 1, includeTimestamp = True) Debug_logMessage(text, level = 1, includeTimestamp = True)
{ {
Global Debug_logFilename, Debug_logLevel Global Debug_logFilename, Debug_logLevel
If (Debug_logLevel >= level) If (Debug_logLevel >= level)
{ {
If includeTimestamp If includeTimestamp
{ {
FormatTime, time, , yyyy-MM-dd HH:mm:ss FormatTime, time, , yyyy-MM-dd HH:mm:ss
text := time " " text text := time " " text
@ -82,14 +82,14 @@ Debug_logMessage(text, level = 1, includeTimestamp = True)
} }
} }
Debug_logViewWindowList() Debug_logViewWindowList()
{ {
Local v, wndIds Local v, wndIds
v := Monitor_#%Manager_aMonitor%_aView_#1 v := Monitor_#%Manager_aMonitor%_aView_#1
Debug_logMessage("Window dump for active view (" . Manager_aMonitor . ", " . v . ")") Debug_logMessage("Window dump for active view (" . Manager_aMonitor . ", " . v . ")")
Debug_logMessage("ID`t`tH W A F D R G M`tTags`tX`tY`tW`tH`tStyle`t`tProc / Class / Title", 0, False) Debug_logMessage("ID`t`tH W A F D R G M`tTags`tX`tY`tW`tH`tStyle`t`tProc / Class / Title", 0, False)
StringTrimRight, wndIds, View_#%Manager_aMonitor%_#%v%_wndIds, 1 StringTrimRight, wndIds, View_#%Manager_aMonitor%_#%v%_wndIds, 1
Loop, PARSE, wndIds, `; Loop, PARSE, wndIds, `;
{ {
@ -97,12 +97,12 @@ Debug_logViewWindowList()
} }
} }
Debug_logWindowInfo(wndId) Debug_logWindowInfo(wndId)
{ {
Local aWndId, detect_state, text, v Local aWndId, detect_state, text, v
Local isBugnActive, isDecorated, isFloating, isGhost, isHidden, isResponsive, isWinFocus Local isBugnActive, isDecorated, isFloating, isGhost, isHidden, isResponsive, isWinFocus
Local wndClass, wndH, wndProc, wndStyle, wndTitle, wndW, wndX, wndY Local wndClass, wndH, wndProc, wndStyle, wndTitle, wndW, wndX, wndY
detect_state := A_DetectHiddenWindows detect_state := A_DetectHiddenWindows
DetectHiddenWindows, On DetectHiddenWindows, On
WinGet, aWndId, ID, A WinGet, aWndId, ID, A
@ -120,7 +120,7 @@ Debug_logWindowInfo(wndId)
WinGet, wndProc, ProcessName, ahk_id %wndId% WinGet, wndProc, ProcessName, ahk_id %wndId%
If InStr(Bar_hiddenWndIds, wndId) If InStr(Bar_hiddenWndIds, wndId)
isHidden := "*" isHidden := "*"
Else Else
isHidden := " " isHidden := " "
If Manager_#%wndId%_isFloating If Manager_#%wndId%_isFloating
isFloating := "*" isFloating := "*"
@ -137,13 +137,13 @@ Debug_logWindowInfo(wndId)
Else Else
isGhost := " " isGhost := " "
DetectHiddenWindows, %detect_state% DetectHiddenWindows, %detect_state%
;; 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 Manager_isHung(wndId) If Manager_isHung(wndId)
isResponsive := " " isResponsive := " "
Else Else
isResponsive := "*" isResponsive := "*"
text := wndId "`t" text := wndId "`t"
text .= isHidden " " isWinFocus " " isBugnActive " " isFloating " " isDecorated " " isResponsive " " isGhost " " text .= isHidden " " isWinFocus " " isBugnActive " " isFloating " " isDecorated " " isResponsive " " isGhost " "
text .= Manager_#%wndId%_monitor "`t" Manager_#%wndId%_tags "`t" text .= Manager_#%wndId%_monitor "`t" Manager_#%wndId%_tags "`t"
@ -151,10 +151,10 @@ Debug_logWindowInfo(wndId)
Debug_logMessage(text , 0, False) Debug_logMessage(text , 0, False)
} }
Debug_setLogLevel(d) Debug_setLogLevel(d)
{ {
Global Debug_logLevel Global Debug_logLevel
i := Debug_logLevel + d i := Debug_logLevel + d
If (i >= 0) If (i >= 0)
{ {

View file

@ -1,25 +1,25 @@
/* /*
bug.n -- tiling window management bug.n -- tiling window management
Copyright (c) 2010-2012 Joshua Fuhs, joten Copyright (c) 2010-2012 Joshua Fuhs, joten
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
@version 8.3.0 @version 8.4.0
*/ */
NAME := "bug.n" NAME := "bug.n"
VERSION := "8.3.0" VERSION := "8.4.0"
;; Script settings ;; Script settings
OnExit, Main_cleanup OnExit, Main_cleanup
@ -33,27 +33,25 @@ SetWinDelay, 10
;; Pseudo main function ;; Pseudo main function
If 0 = 1 If 0 = 1
Main_dataDir = %1% Main_appDir = %1%
Else
Main_dataDir = %A_ScriptDir%
Main_setup() Main_setup()
Debug_initLog(Main_appDir "\log.txt", 0, False) Debug_initLog(Main_appDir "\log.txt", 0, False)
Debug_logMessage("====== Initializing ======") Debug_logMessage("====== Initializing ======")
Config_filePath := Main_appDir "\Config.ini" Config_filePath := Main_appDir "\Config.ini"
Config_init() Config_init()
Menu, Tray, Tip, %NAME% %VERSION% Menu, Tray, Tip, %NAME% %VERSION%
IfExist %A_ScriptDir%\images\kfm.ico IfExist %A_ScriptDir%\logo.ico
Menu, Tray, Icon, %A_ScriptDir%\images\kfm.ico Menu, Tray, Icon, %A_ScriptDir%\logo.ico
Menu, Tray, NoStandard Menu, Tray, NoStandard
Menu, Tray, Add, Toggle bar, Main_toggleBar Menu, Tray, Add, Toggle bar, Main_toggleBar
Menu, Tray, Add, Help, Main_help Menu, Tray, Add, Help, Main_help
Menu, Tray, Add, Menu, Tray, Add,
Menu, Tray, Add, Exit, Main_quit Menu, Tray, Add, Exit, Main_quit
ResourceMonitor_init() ResourceMonitor_init()
Manager_init() Manager_init()
Debug_logMessage("====== Running ======", 0) Debug_logMessage("====== Running ======", 0)
@ -69,49 +67,49 @@ Main_cleanup:
ResourceMonitor_cleanup() ResourceMonitor_cleanup()
Debug_logMessage("====== Exiting bug.n ======", 0) Debug_logMessage("====== Exiting bug.n ======", 0)
ExitApp ExitApp
Main_evalCommand(command) Main_evalCommand(command)
{ {
type := SubStr(command, 1, 5) type := SubStr(command, 1, 5)
If (type = "Run, ") If (type = "Run, ")
{ {
parameters := SubStr(command, 6) parameters := SubStr(command, 6)
If InStr(parameters, ", ") If InStr(parameters, ", ")
{ {
StringSplit, parameter, parameters, `, StringSplit, parameter, parameters, `,
If (parameter0 = 2) If (parameter0 = 2)
{ {
StringTrimLeft, parameter2, parameter2, 1 StringTrimLeft, parameter2, parameter2, 1
Run, %parameter1%, %parameter2% Run, %parameter1%, %parameter2%
} }
Else If (parameter0 > 2) Else If (parameter0 > 2)
{ {
StringTrimLeft, parameter2, parameter2, 1 StringTrimLeft, parameter2, parameter2, 1
StringTrimLeft, parameter3, parameter3, 1 StringTrimLeft, parameter3, parameter3, 1
Run, %parameter1%, %parameter2%, %parameter3% Run, %parameter1%, %parameter2%, %parameter3%
} }
} }
Else Else
Run, %parameters% Run, %parameters%
} }
Else If (type = "Send ") Else If (type = "Send ")
Send % SubStr(command, 6) Send % SubStr(command, 6)
Else If (command = "Reload") Else If (command = "Reload")
Reload Reload
Else If (command = "ExitApp") Else If (command = "ExitApp")
ExitApp ExitApp
Else Else
{ {
i := InStr(command, "(") i := InStr(command, "(")
j := InStr(command, ")", False, i) j := InStr(command, ")", False, i)
If i And j If i And j
{ {
functionName := SubStr(command, 1, i - 1) functionName := SubStr(command, 1, i - 1)
functionArguments := SubStr(command, i + 1, j - (i + 1)) functionArguments := SubStr(command, i + 1, j - (i + 1))
StringSplit, functionArgument, functionArguments, `, StringSplit, functionArgument, functionArguments, `,
If (functionArgument0 < 2) If (functionArgument0 < 2)
%functionName%(functionArguments) %functionName%(functionArguments)
Else If (functionArgument0 = 2) Else If (functionArgument0 = 2)
{ {
StringTrimLeft, functionArgument2, functionArgument2, 1 StringTrimLeft, functionArgument2, functionArgument2, 1
%functionName%(functionArgument1, functionArgument2) %functionName%(functionArgument1, functionArgument2)
@ -133,16 +131,16 @@ Main_makeDir(dirName) {
IfNotExist, %dirName% IfNotExist, %dirName%
{ {
FileCreateDir, %dirName% FileCreateDir, %dirName%
If ErrorLevel If ErrorLevel
{ {
MsgBox, Error (%ErrorLevel%) when creating '%dirName%'. Aborting. MsgBox, Error (%ErrorLevel%) when creating '%dirName%'. Aborting.
ExitApp ExitApp
} }
} }
Else Else
{ {
FileGetAttrib, attrib, %dirName% FileGetAttrib, attrib, %dirName%
IfNotInString, attrib, D IfNotInString, attrib, D
{ {
MsgBox, The file path '%dirName%' already exists and is not a directory. Aborting. MsgBox, The file path '%dirName%' already exists and is not a directory. Aborting.
ExitApp ExitApp
@ -154,7 +152,6 @@ Main_makeDir(dirName) {
Main_setup() { Main_setup() {
Local winAppDir Local winAppDir
Main_appDir := ""
Main_logFile := "" Main_logFile := ""
Main_dataDir := "" Main_dataDir := ""
Main_autoLayout := "" Main_autoLayout := ""
@ -162,25 +159,26 @@ Main_setup() {
EnvGet, winAppDir, APPDATA EnvGet, winAppDir, APPDATA
Main_appDir := winAppDir . "\bug.n" If (Main_appDir = "")
Main_appDir := winAppDir . "\bug.n"
Main_logFile := Main_appDir . "\bugn_log.txt" Main_logFile := Main_appDir . "\bugn_log.txt"
Main_dataDir := Main_appDir . "\data" Main_dataDir := Main_appDir . "\data"
Main_autoLayout := Main_dataDir . "\_Layout.ini" Main_autoLayout := Main_dataDir . "\_Layout.ini"
Main_autoWindowState := Main_dataDir . "\_WindowState.ini" Main_autoWindowState := Main_dataDir . "\_WindowState.ini"
Main_makeDir(Main_appDir) Main_makeDir(Main_appDir)
Main_makeDir(Main_dataDir) Main_makeDir(Main_dataDir)
} }
Main_reload() Main_reload()
{ {
Local i, ncm, ncmSize Local i, ncm, ncmSize
;; Reset border color, padding and witdh. ;; Reset border color, padding and witdh.
If Config_selBorderColor If Config_selBorderColor
DllCall("SetSysColors", "Int", 1, "Int*", 10, "UInt*", Manager_normBorderColor) DllCall("SetSysColors", "Int", 1, "Int*", 10, "UInt*", Manager_normBorderColor)
If (Config_borderWidth > 0) Or (Config_borderPadding >= 0 And A_OSVersion = WIN_VISTA) If (Config_borderWidth > 0) Or (Config_borderPadding >= 0 And A_OSVersion = WIN_VISTA)
{ {
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") NumPut(ncmSize, ncm, 0, "UInt")
@ -193,7 +191,7 @@ Main_reload()
} }
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)
Config_init() Config_init()
; Windows UI ; Windows UI
If Config_selBorderColor { If Config_selBorderColor {
@ -215,7 +213,7 @@ Main_reload()
DllCall("SystemParametersInfo", "UInt", 0x002a, "UInt", ncmSize, "UInt", &ncm, "UInt", 0) DllCall("SystemParametersInfo", "UInt", 0x002a, "UInt", ncmSize, "UInt", &ncm, "UInt", 0)
} }
Bar_getHeight() Bar_getHeight()
Loop, % Manager_monitorCount Loop, % Manager_monitorCount
{ {
Monitor_getWorkArea(A_Index) Monitor_getWorkArea(A_Index)
Bar_init(A_Index) Bar_init(A_Index)
@ -225,10 +223,10 @@ Main_reload()
Monitor_toggleTaskBar() Monitor_toggleTaskBar()
Bar_updateStatus() Bar_updateStatus()
Bar_updateTitle() Bar_updateTitle()
Loop, % Manager_monitorCount Loop, % Manager_monitorCount
{ {
i := A_Index i := A_Index
Loop, % Config_viewCount Loop, % Config_viewCount
{ {
Bar_updateView(i, A_Index) Bar_updateView(i, A_Index)
} }

File diff suppressed because it is too large Load diff

View file

@ -1,31 +1,32 @@
/* /*
bug.n -- tiling window management bug.n -- tiling window management
Copyright (c) 2010-2012 Joshua Fuhs, joten Copyright (c) 2010-2012 Joshua Fuhs, joten
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
@version 8.3.0 @version 8.4.0
*/ */
Monitor_init(m, doRestore) Monitor_init(m, doRestore)
{ {
Global Global
Monitor_#%m%_aView_#1 := 1 Monitor_#%m%_aView_#1 := 1
Monitor_#%m%_aView_#2 := 1 Monitor_#%m%_aView_#2 := 1
Monitor_#%m%_showBar := Config_showBar Monitor_#%m%_showBar := Config_showBar
Loop, % Config_viewCount Loop, % Config_viewCount
{ {
View_init(m, A_Index) View_init(m, A_Index)
} }
@ -37,50 +38,50 @@ Monitor_init(m, doRestore)
Bar_init(m) Bar_init(m)
} }
Monitor_activateView(v) Monitor_activateView(v)
{ {
Local aView, aWndId, m, n, wndId, wndIds Local aView, aWndId, m, n, wndId, wndIds
If (v = -1) If (v = -1)
v := Monitor_#%Manager_aMonitor%_aView_#2 v := Monitor_#%Manager_aMonitor%_aView_#2
Else If (v = ">") Else If (v = ">")
v := Manager_loop(Monitor_#%Manager_aMonitor%_aView_#1, +1, 1, Config_viewCount) v := Manager_loop(Monitor_#%Manager_aMonitor%_aView_#1, +1, 1, Config_viewCount)
Else If (v = "<") Else If (v = "<")
v := Manager_loop(Monitor_#%Manager_aMonitor%_aView_#1, -1, 1, Config_viewCount) v := Manager_loop(Monitor_#%Manager_aMonitor%_aView_#1, -1, 1, Config_viewCount)
Debug_logMessage("DEBUG[1] Monitor_activateView(" . v . ") Manager_aMonitor: " . Manager_aMonitor . "; wndIds: " . View_#%Manager_aMonitor%_#%v%_wndIds, 1) Debug_logMessage("DEBUG[1] Monitor_activateView(" . v . ") Manager_aMonitor: " . Manager_aMonitor . "; wndIds: " . View_#%Manager_aMonitor%_#%v%_wndIds, 1)
If (v <= 0) Or (v > Config_viewCount) Or Manager_hideShow If (v <= 0) Or (v > Config_viewCount) Or Manager_hideShow
Return Return
;; Re-arrange the windows on the active view. ;; Re-arrange the windows on the active view.
If (v = Monitor_#%Manager_aMonitor%_aView_#1) If (v = Monitor_#%Manager_aMonitor%_aView_#1)
{ {
View_arrange(Manager_aMonitor, v) View_arrange(Manager_aMonitor, v)
Return Return
} }
aView := Monitor_#%Manager_aMonitor%_aView_#1 aView := Monitor_#%Manager_aMonitor%_aView_#1
aWndId := View_getActiveWindow(Manager_aMonitor, aView) aWndId := View_getActiveWindow(Manager_aMonitor, aView)
If aWndId If aWndId
View_#%Manager_aMonitor%_#%aView%_aWndId := aWndId View_#%Manager_aMonitor%_#%aView%_aWndId := aWndId
n := Config_syncMonitorViews n := Config_syncMonitorViews
If (n = 1) If (n = 1)
n := Manager_monitorCount n := Manager_monitorCount
Else If (n < 1) Else If (n < 1)
n := 1 n := 1
Loop, % n Loop, % n
{ {
If (n = 1) If (n = 1)
m := Manager_aMonitor m := Manager_aMonitor
Else Else
m := A_Index m := A_Index
Monitor_#%m%_aView_#2 := aView Monitor_#%m%_aView_#2 := aView
Monitor_#%m%_aView_#1 := v Monitor_#%m%_aView_#1 := v
Manager_hideShow := True Manager_hideShow := True
SetWinDelay, 0 SetWinDelay, 0
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))
Manager_winHide(A_LoopField) Manager_winHide(A_LoopField)
@ -91,95 +92,95 @@ Monitor_activateView(v)
DetectHiddenWindows, Off DetectHiddenWindows, Off
StringTrimRight, wndIds, View_#%m%_#%v%_wndIds, 1 StringTrimRight, wndIds, View_#%m%_#%v%_wndIds, 1
SetWinDelay, 0 SetWinDelay, 0
Loop, PARSE, wndIds, `; Loop, PARSE, wndIds, `;
{ {
Manager_winShow(A_LoopField) Manager_winShow(A_LoopField)
} }
SetWinDelay, 10 SetWinDelay, 10
Manager_hideShow := False Manager_hideShow := False
Bar_updateView(m, aView) Bar_updateView(m, aView)
Bar_updateView(m, v) Bar_updateView(m, v)
} }
wndId := View_#%Manager_aMonitor%_#%v%_aWndId wndId := View_#%Manager_aMonitor%_#%v%_aWndId
If Not (wndId And WinExist("ahk_id" wndId)) If Not (wndId And WinExist("ahk_id" wndId))
{ {
If View_#%Manager_aMonitor%_#%v%_wndIds If View_#%Manager_aMonitor%_#%v%_wndIds
{ {
wndId := SubStr(View_#%Manager_aMonitor%_#%v%_wndIds, 1, InStr(View_#%Manager_aMonitor%_#%v%_wndIds, ";")-1) wndId := SubStr(View_#%Manager_aMonitor%_#%v%_wndIds, 1, InStr(View_#%Manager_aMonitor%_#%v%_wndIds, ";")-1)
View_#%Manager_aMonitor%_#%v%_aWndId := wndId View_#%Manager_aMonitor%_#%v%_aWndId := wndId
} }
Else Else
wndId := 0 wndId := 0
} }
Manager_winActivate(wndId) Manager_winActivate(wndId)
} }
Monitor_get(x, y) Monitor_get(x, y)
{ {
Local m Local m
m := 0 m := 0
Loop, % Manager_monitorCount Loop, % Manager_monitorCount
{ ;; Check if the window is on this monitor. { ;; Check if the window is on this monitor.
If (x >= Monitor_#%A_Index%_x && x <= Monitor_#%A_Index%_x+Monitor_#%A_Index%_width && y >= Monitor_#%A_Index%_y && y <= Monitor_#%A_Index%_y+Monitor_#%A_Index%_height) If (x >= Monitor_#%A_Index%_x && x <= Monitor_#%A_Index%_x+Monitor_#%A_Index%_width && y >= Monitor_#%A_Index%_y && y <= Monitor_#%A_Index%_y+Monitor_#%A_Index%_height)
{ {
m := A_Index m := A_Index
Break Break
} }
} }
Return, m Return, m
} }
Monitor_getWorkArea(m) Monitor_getWorkArea(m)
{ {
Local bTop, x, y Local bTop, x, y
Local monitor, monitorBottom, monitorLeft, monitorRight, monitorTop Local monitor, monitorBottom, monitorLeft, monitorRight, monitorTop
Local wndClasses, wndHeight, wndId, wndWidth, wndX, wndY Local wndClasses, wndHeight, wndId, wndWidth, wndX, wndY
SysGet, monitor, Monitor, %m% SysGet, monitor, Monitor, %m%
wndClasses := "Shell_TrayWnd" wndClasses := "Shell_TrayWnd"
If Config_bbCompatibility If Config_bbCompatibility
wndClasses .= ";bbLeanBar;bbSlit;BBToolbar;SystemBarEx" wndClasses .= ";bbLeanBar;bbSlit;BBToolbar;SystemBarEx"
Loop, PARSE, wndClasses, `; Loop, PARSE, wndClasses, `;
{ {
wndId := WinExist("ahk_class " A_LoopField) wndId := WinExist("ahk_class " A_LoopField)
If wndId If wndId
{ {
WinGetPos, wndX, wndY, wndWidth, wndHeight, ahk_id %wndId% WinGetPos, wndX, wndY, wndWidth, wndHeight, ahk_id %wndId%
x := wndX + wndWidth / 2 x := wndX + wndWidth / 2
y := wndY + wndHeight / 2 y := wndY + wndHeight / 2
If (x >= monitorLeft && x <= monitorRight && y >= monitorTop && y <= monitorBottom) If (x >= monitorLeft && x <= monitorRight && y >= monitorTop && y <= monitorBottom)
{ {
If (A_LoopField = "Shell_TrayWnd") If (A_LoopField = "Shell_TrayWnd")
Manager_taskBarMonitor := m Manager_taskBarMonitor := m
If (wndHeight < wndWidth) If (wndHeight < wndWidth)
{ ;; Horizontal { ;; Horizontal
If (wndY <= monitorTop) If (wndY <= monitorTop)
{ ;; Top { ;; Top
wndHeight += wndY - monitorTop wndHeight += wndY - monitorTop
monitorTop += wndHeight monitorTop += wndHeight
If (A_LoopField = "Shell_TrayWnd") If (A_LoopField = "Shell_TrayWnd")
Manager_taskBarPos := "top" Manager_taskBarPos := "top"
} }
Else Else
{ ;; Bottom { ;; Bottom
wndHeight := monitorBottom - wndY wndHeight := monitorBottom - wndY
monitorBottom -= wndHeight monitorBottom -= wndHeight
} }
} }
Else Else
{ ;; Vertical { ;; Vertical
If (wndX <= monitorLeft) If (wndX <= monitorLeft)
{ ;; Left { ;; Left
wndWidth += wndX wndWidth += wndX
monitorLeft += wndWidth monitorLeft += wndWidth
} }
Else Else
{ ;; Right { ;; Right
wndWidth := monitorRight - wndX wndWidth := monitorRight - wndX
monitorRight -= wndWidth monitorRight -= wndWidth
@ -189,20 +190,20 @@ Monitor_getWorkArea(m)
} }
} }
bTop := 0 bTop := 0
If Monitor_#%m%_showBar If Monitor_#%m%_showBar
{ {
If (Config_verticalBarPos = "top" Or (Config_verticalBarPos = "tray" And Not m = Manager_taskBarMonitor)) If (Config_verticalBarPos = "top" Or (Config_verticalBarPos = "tray" And Not m = Manager_taskBarMonitor))
{ {
bTop := monitorTop bTop := monitorTop
monitorTop += Bar_height monitorTop += Bar_height
} }
Else If (Config_verticalBarPos = "bottom") Else If (Config_verticalBarPos = "bottom")
{ {
bTop := monitorBottom - Bar_height bTop := monitorBottom - Bar_height
monitorBottom -= Bar_height monitorBottom -= Bar_height
} }
} }
Monitor_#%m%_height := monitorBottom - monitorTop Monitor_#%m%_height := monitorBottom - monitorTop
Monitor_#%m%_width := monitorRight - monitorLeft Monitor_#%m%_width := monitorRight - monitorLeft
Monitor_#%m%_x := monitorLeft Monitor_#%m%_x := monitorLeft
@ -210,30 +211,30 @@ Monitor_getWorkArea(m)
Monitor_#%m%_barY := bTop Monitor_#%m%_barY := bTop
} }
Monitor_moveWindow(m, wndId) Monitor_moveWindow(m, wndId)
{ {
Global Global
Manager_#%wndId%_monitor := m Manager_#%wndId%_monitor := m
} }
Monitor_setWindowTag(t) Monitor_setWindowTag(t)
{ {
Local aView, aWndId, wndId Local aView, aWndId, wndId
If (t = ">") If (t = ">")
t := Manager_loop(Monitor_#%Manager_aMonitor%_aView_#1, +1, 1, Config_viewCount) t := Manager_loop(Monitor_#%Manager_aMonitor%_aView_#1, +1, 1, Config_viewCount)
Else If (t = "<") Else If (t = "<")
t := Manager_loop(Monitor_#%Manager_aMonitor%_aView_#1, -1, 1, Config_viewCount) t := Manager_loop(Monitor_#%Manager_aMonitor%_aView_#1, -1, 1, Config_viewCount)
WinGet, aWndId, ID, A WinGet, aWndId, ID, A
If (InStr(Manager_managedWndIds, aWndId ";") And t >= 0 And t <= Config_viewCount) If (InStr(Manager_managedWndIds, aWndId ";") And t >= 0 And t <= Config_viewCount)
{ {
If (t = 0) If (t = 0)
{ {
Loop, % Config_viewCount Loop, % Config_viewCount
{ {
If Not (Manager_#%aWndId%_tags & (1 << A_Index - 1)) If Not (Manager_#%aWndId%_tags & (1 << A_Index - 1))
{ {
View_#%Manager_aMonitor%_#%A_Index%_wndIds := aWndId ";" View_#%Manager_aMonitor%_#%A_Index%_wndIds View_#%Manager_aMonitor%_#%A_Index%_wndIds := aWndId ";" View_#%Manager_aMonitor%_#%A_Index%_wndIds
View_#%Manager_aMonitor%_#%A_Index%_aWndId := aWndId View_#%Manager_aMonitor%_#%A_Index%_aWndId := aWndId
@ -241,26 +242,26 @@ Monitor_setWindowTag(t)
Manager_#%aWndId%_tags += 1 << A_Index - 1 Manager_#%aWndId%_tags += 1 << A_Index - 1
} }
} }
} }
Else Else
{ {
Loop, % Config_viewCount Loop, % Config_viewCount
{ {
If Not (A_index = t) If Not (A_index = t)
{ {
StringReplace, View_#%Manager_aMonitor%_#%A_Index%_wndIds, View_#%Manager_aMonitor%_#%A_Index%_wndIds, %aWndId%`;, StringReplace, View_#%Manager_aMonitor%_#%A_Index%_wndIds, View_#%Manager_aMonitor%_#%A_Index%_wndIds, %aWndId%`;,
View_#%Manager_aMonitor%_#%A_Index%_aWndId := 0 View_#%Manager_aMonitor%_#%A_Index%_aWndId := 0
Bar_updateView(Manager_aMonitor, A_Index) Bar_updateView(Manager_aMonitor, A_Index)
} }
} }
If Not (Manager_#%aWndId%_tags & (1 << t - 1)) If Not (Manager_#%aWndId%_tags & (1 << t - 1))
View_#%Manager_aMonitor%_#%t%_wndIds := aWndId ";" View_#%Manager_aMonitor%_#%t%_wndIds View_#%Manager_aMonitor%_#%t%_wndIds := aWndId ";" View_#%Manager_aMonitor%_#%t%_wndIds
View_#%Manager_aMonitor%_#%t%_aWndId := aWndId View_#%Manager_aMonitor%_#%t%_aWndId := aWndId
Manager_#%aWndId%_tags := 1 << t - 1 Manager_#%aWndId%_tags := 1 << t - 1
aView := Monitor_#%Manager_aMonitor%_aView_#1 aView := Monitor_#%Manager_aMonitor%_aView_#1
If Not (t = aView) If Not (t = aView)
{ {
Manager_hideShow := True Manager_hideShow := True
wndId := SubStr(View_#%Manager_aMonitor%_#%aView%_wndIds, 1, InStr(View_#%Manager_aMonitor%_#%aView%_wndIds, ";")-1) wndId := SubStr(View_#%Manager_aMonitor%_#%aView%_wndIds, 1, InStr(View_#%Manager_aMonitor%_#%aView%_wndIds, ";")-1)
@ -268,7 +269,7 @@ Monitor_setWindowTag(t)
Manager_hideShow := False Manager_hideShow := False
If Config_viewFollowsTagged If Config_viewFollowsTagged
Monitor_activateView(t) Monitor_activateView(t)
Else Else
{ {
Manager_hideShow := True Manager_hideShow := True
Manager_winHide(aWndId) Manager_winHide(aWndId)
@ -281,10 +282,10 @@ Monitor_setWindowTag(t)
} }
} }
Monitor_toggleBar() Monitor_toggleBar()
{ {
Global Global
Monitor_#%Manager_aMonitor%_showBar := Not Monitor_#%Manager_aMonitor%_showBar Monitor_#%Manager_aMonitor%_showBar := Not Monitor_#%Manager_aMonitor%_showBar
Bar_toggleVisibility(Manager_aMonitor) Bar_toggleVisibility(Manager_aMonitor)
Monitor_getWorkArea(Manager_aMonitor) Monitor_getWorkArea(Manager_aMonitor)
@ -292,21 +293,21 @@ Monitor_toggleBar()
Manager_winActivate(Bar_aWndId) Manager_winActivate(Bar_aWndId)
} }
Monitor_toggleTaskBar() Monitor_toggleTaskBar()
{ {
Local m Local m
m := Manager_aMonitor m := Manager_aMonitor
If (m = Manager_taskBarMonitor) If (m = Manager_taskBarMonitor)
{ {
Manager_showTaskBar := Not Manager_showTaskBar Manager_showTaskBar := Not Manager_showTaskBar
Manager_hideShow := True Manager_hideShow := True
If Not Manager_showTaskBar If Not Manager_showTaskBar
{ {
WinHide, Start ahk_class Button WinHide, Start ahk_class Button
WinHide, ahk_class Shell_TrayWnd WinHide, ahk_class Shell_TrayWnd
} }
Else Else
{ {
WinShow, Start ahk_class Button WinShow, Start ahk_class Button
WinShow, ahk_class Shell_TrayWnd WinShow, ahk_class Shell_TrayWnd
@ -318,21 +319,21 @@ Monitor_toggleTaskBar()
} }
} }
Monitor_toggleWindowTag(t) Monitor_toggleWindowTag(t)
{ {
Local aWndId, wndId Local aWndId, wndId
WinGet, aWndId, ID, A WinGet, aWndId, ID, A
If (InStr(Manager_managedWndIds, aWndId ";") And t >= 0 And t <= Config_viewCount) If (InStr(Manager_managedWndIds, aWndId ";") And t >= 0 And t <= Config_viewCount)
{ {
If (Manager_#%aWndId%_tags & (1 << t - 1)) If (Manager_#%aWndId%_tags & (1 << t - 1))
{ {
If Not ((Manager_#%aWndId%_tags - (1 << t - 1)) = 0) If Not ((Manager_#%aWndId%_tags - (1 << t - 1)) = 0)
{ {
Manager_#%aWndId%_tags -= 1 << t - 1 Manager_#%aWndId%_tags -= 1 << t - 1
StringReplace, View_#%Manager_aMonitor%_#%t%_wndIds, View_#%Manager_aMonitor%_#%t%_wndIds, %aWndId%`;, StringReplace, View_#%Manager_aMonitor%_#%t%_wndIds, View_#%Manager_aMonitor%_#%t%_wndIds, %aWndId%`;,
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
Manager_winHide(aWndId) Manager_winHide(aWndId)
@ -342,8 +343,8 @@ Monitor_toggleWindowTag(t)
View_arrange(Manager_aMonitor, t) View_arrange(Manager_aMonitor, t)
} }
} }
} }
Else Else
{ {
View_#%Manager_aMonitor%_#%t%_wndIds := aWndId ";" View_#%Manager_aMonitor%_#%t%_wndIds View_#%Manager_aMonitor%_#%t%_wndIds := aWndId ";" View_#%Manager_aMonitor%_#%t%_wndIds
View_#%Manager_aMonitor%_#%t%_aWndId := aWndId View_#%Manager_aMonitor%_#%t%_aWndId := aWndId

View file

@ -1,55 +1,55 @@
/* /*
bug.n -- tiling window management bug.n -- tiling window management
Copyright (c) 2010-2012 Joshua Fuhs, joten Copyright (c) 2010-2012 Joshua Fuhs, joten
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
@version 8.3.0 @version 8.4.0
*/ */
ResourceMonitor_init() ResourceMonitor_init()
{ {
ResourceMonitor_hDrive := DllCall("CreateFile", "Str", "\\.\PhysicalDrive0", "UInt", 0, "UInt", 3, "UInt", 0, "UInt", 3, "UInt", 0, "UInt", 0) ResourceMonitor_hDrive := DllCall("CreateFile", "Str", "\\.\PhysicalDrive0", "UInt", 0, "UInt", 3, "UInt", 0, "UInt", 3, "UInt", 0, "UInt", 0)
ResourceMonitor_getNetworkInterface() ResourceMonitor_getNetworkInterface()
} }
ResourceMonitor_cleanup() ResourceMonitor_cleanup()
{ {
DllCall("CloseHandle", "UInt", ResourceMonitor_hDrive) ;; used in ResourceMonitor_getDiskLoad DllCall("CloseHandle", "UInt", ResourceMonitor_hDrive) ;; used in ResourceMonitor_getDiskLoad
} }
ResourceMonitor_getText() ResourceMonitor_getText()
{ {
Global Config_readinCpu, Config_readinDate, Config_readinDiskLoad, Config_readinMemoryUsage, Config_readinNetworkLoad Global Config_readinCpu, Config_readinDate, Config_readinDiskLoad, Config_readinMemoryUsage, Config_readinNetworkLoad
text := "" text := ""
If Config_readinCpu If Config_readinCpu
text .= " CPU: " ResourceMonitor_getSystemTimes() "% " text .= " CPU: " ResourceMonitor_getSystemTimes() "% "
If Config_readinMemoryUsage If Config_readinMemoryUsage
{ {
If Config_readinCpu If Config_readinCpu
text .= "|" text .= "|"
text .= " RAM: " ResourceMonitor_getMemoryUsage() "% " text .= " RAM: " ResourceMonitor_getMemoryUsage() "% "
} }
If Config_readinDiskLoad If Config_readinDiskLoad
{ {
If (Config_readinCpu Or Config_readinMemoryUsage) If (Config_readinCpu Or Config_readinMemoryUsage)
text .= "|" text .= "|"
ResourceMonitor_getDiskLoad(rLoad, wLoad) ResourceMonitor_getDiskLoad(rLoad, wLoad)
text .= " Dr: " rLoad "% | Dw: " wLoad "% " text .= " Dr: " rLoad "% | Dw: " wLoad "% "
} }
If Config_readinNetworkLoad If Config_readinNetworkLoad
{ {
If (Config_readinCpu Or Config_readinMemoryUsage Or Config_readinDiskLoad) If (Config_readinCpu Or Config_readinMemoryUsage Or Config_readinDiskLoad)
text .= "|" text .= "|"
@ -58,19 +58,19 @@ ResourceMonitor_getText()
} }
If Config_readinDate And (Config_readinCpu Or Config_readinMemoryUsage Or Config_readinDiskLoad Or Config_readinNetworkLoad) If Config_readinDate And (Config_readinCpu Or Config_readinMemoryUsage Or Config_readinDiskLoad Or Config_readinNetworkLoad)
text .= "|" text .= "|"
Return, text Return, text
} }
ResourceMonitor_getDiskLoad(ByRef readLoad, ByRef writeLoad) ResourceMonitor_getDiskLoad(ByRef readLoad, ByRef writeLoad)
{ {
Global ResourceMonitor_hDrive Global ResourceMonitor_hDrive
Static oldReadCount, oldWriteCount Static oldReadCount, oldWriteCount
dpSize := 5 * 8 + 4 + 4 + 4 + 4 + 8 + 4 + 8 * (A_IsUnicode ? 2 : 1) + 12 ;; 88? dpSize := 5 * 8 + 4 + 4 + 4 + 4 + 8 + 4 + 8 * (A_IsUnicode ? 2 : 1) + 12 ;; 88?
VarSetCapacity(dp, dpSize) VarSetCapacity(dp, dpSize)
DllCall("DeviceIoControl", "UInt", ResourceMonitor_hDrive, "UInt", 0x00070020, "UInt", 0, "UInt", 0, "UInt", &dp, "UInt", dpSize, "UIntP", nReturn, "UInt", 0) ;; IOCTL_DISK_PERFORMANCE DllCall("DeviceIoControl", "UInt", ResourceMonitor_hDrive, "UInt", 0x00070020, "UInt", 0, "UInt", 0, "UInt", &dp, "UInt", dpSize, "UIntP", nReturn, "UInt", 0) ;; IOCTL_DISK_PERFORMANCE
newReadCount := NumGet(dp, 40) newReadCount := NumGet(dp, 40)
newWriteCount := NumGet(dp, 44) newWriteCount := NumGet(dp, 44)
readLoad := SubStr(" " Round((1 - 1 / (1 + newReadCount - oldReadCount)) * 100), -2) readLoad := SubStr(" " Round((1 - 1 / (1 + newReadCount - oldReadCount)) * 100), -2)
@ -81,7 +81,7 @@ ResourceMonitor_getDiskLoad(ByRef readLoad, ByRef writeLoad)
;; fures: System + Network monitor - with net history graph (http://www.autohotkey.com/community/viewtopic.php?p=260329) ;; fures: System + Network monitor - with net history graph (http://www.autohotkey.com/community/viewtopic.php?p=260329)
;; SKAN: HDD Activity Monitoring LED (http://www.autohotkey.com/community/viewtopic.php?p=113890&sid=64d9824fdf252697ff4d5026faba91f8#p113890) ;; SKAN: HDD Activity Monitoring LED (http://www.autohotkey.com/community/viewtopic.php?p=113890&sid=64d9824fdf252697ff4d5026faba91f8#p113890)
ResourceMonitor_getMemoryUsage() ResourceMonitor_getMemoryUsage()
{ {
VarSetCapacity(memoryStatus, 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4) VarSetCapacity(memoryStatus, 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4)
DllCall("kernel32.dll\GlobalMemoryStatus", "UInt", &memoryStatus) DllCall("kernel32.dll\GlobalMemoryStatus", "UInt", &memoryStatus)
@ -89,20 +89,20 @@ ResourceMonitor_getMemoryUsage()
} }
;; fures: System + Network monitor - with net history graph (http://www.autohotkey.com/community/viewtopic.php?p=260329) ;; fures: System + Network monitor - with net history graph (http://www.autohotkey.com/community/viewtopic.php?p=260329)
ResourceMonitor_getNetworkInterface() ResourceMonitor_getNetworkInterface()
{ {
Global ResourceMonitor_networkInterface, ResourceMonitor_networkInterfaceTable Global ResourceMonitor_networkInterface, ResourceMonitor_networkInterfaceTable
DllCall("iphlpapi\GetNumberOfInterfaces", "UIntP", n) DllCall("iphlpapi\GetNumberOfInterfaces", "UIntP", n)
nSize := 4 + 860 * n + 8 nSize := 4 + 860 * n + 8
VarSetCapacity(ResourceMonitor_networkInterfaceTable, nSize) VarSetCapacity(ResourceMonitor_networkInterfaceTable, nSize)
If Not DllCall("iphlpapi\GetIfTable", "UInt", &ResourceMonitor_networkInterfaceTable, "UIntP", nSize, "Int", False) If Not DllCall("iphlpapi\GetIfTable", "UInt", &ResourceMonitor_networkInterfaceTable, "UIntP", nSize, "Int", False)
{ {
Loop, 2 Loop, 2
{ {
i := 0 i := 0
j := A_Index j := A_Index
Loop, % NumGet(ResourceMonitor_networkInterfaceTable) Loop, % NumGet(ResourceMonitor_networkInterfaceTable)
{ {
If NumGet(ResourceMonitor_networkInterfaceTable, 4 + 860 * (A_Index - 1) + 544) < 4 If NumGet(ResourceMonitor_networkInterfaceTable, 4 + 860 * (A_Index - 1) + 544) < 4
|| NumGet(ResourceMonitor_networkInterfaceTable, 4 + 860 * (A_Index - 1) + 516) = 24 || NumGet(ResourceMonitor_networkInterfaceTable, 4 + 860 * (A_Index - 1) + 516) = 24
@ -114,10 +114,10 @@ ResourceMonitor_getNetworkInterface()
If (A_Index < 2) If (A_Index < 2)
RunWait, %Comspec% /c ping -n 1 127.0.0.1, , hide RunWait, %Comspec% /c ping -n 1 127.0.0.1, , hide
} }
Loop, % i Loop, % i
{ {
If (dn_#%i%_#2 > dn_#%i%_1) If (dn_#%i%_#2 > dn_#%i%_1)
{ {
ResourceMonitor_networkInterface := i ResourceMonitor_networkInterface := i
Break Break
@ -127,27 +127,27 @@ ResourceMonitor_getNetworkInterface()
} }
;; fures: System + Network monitor - with net history graph (http://www.autohotkey.com/community/viewtopic.php?p=260329) ;; fures: System + Network monitor - with net history graph (http://www.autohotkey.com/community/viewtopic.php?p=260329)
ResourceMonitor_getNetworkLoad(ByRef upLoad, ByRef dnLoad) ResourceMonitor_getNetworkLoad(ByRef upLoad, ByRef dnLoad)
{ {
Global ResourceMonitor_networkInterface, ResourceMonitor_networkInterfaceTable Global ResourceMonitor_networkInterface, ResourceMonitor_networkInterfaceTable
Static dn_#0, t_#0, up_#0 Static dn_#0, t_#0, up_#0
DllCall("iphlpapi\GetIfEntry", "UInt", &ResourceMonitor_networkInterfaceTable + 4 + 860 * (ResourceMonitor_networkInterface - 1)) DllCall("iphlpapi\GetIfEntry", "UInt", &ResourceMonitor_networkInterfaceTable + 4 + 860 * (ResourceMonitor_networkInterface - 1))
dn_#1 := NumGet(ResourceMonitor_networkInterfaceTable, 4 + 860 * (ResourceMonitor_networkInterface - 1) + 552) ;; Total Incoming Bytes dn_#1 := NumGet(ResourceMonitor_networkInterfaceTable, 4 + 860 * (ResourceMonitor_networkInterface - 1) + 552) ;; Total Incoming Bytes
up_#1 := NumGet(ResourceMonitor_networkInterfaceTable, 4 + 860 * (ResourceMonitor_networkInterface - 1) + 576) ;; Total Outgoing Bytes up_#1 := NumGet(ResourceMonitor_networkInterfaceTable, 4 + 860 * (ResourceMonitor_networkInterface - 1) + 576) ;; Total Outgoing Bytes
tDiff := (A_TickCount - t_#0) / 1000 tDiff := (A_TickCount - t_#0) / 1000
t_#0 := A_TickCount t_#0 := A_TickCount
dnLoad := SubStr(" " Round((dn_#1 - dn_#0) / 1024 / tDiff), -3) dnLoad := SubStr(" " Round((dn_#1 - dn_#0) / 1024 / tDiff), -3)
upLoad := SubStr(" " Round((up_#1 - up_#0) / 1024 / tDiff), -3) upLoad := SubStr(" " Round((up_#1 - up_#0) / 1024 / tDiff), -3)
dn_#0 := dn_#1 dn_#0 := dn_#1
up_#0 := up_#1 up_#0 := up_#1
} }
;; fures: System + Network monitor - with net history graph (http://www.autohotkey.com/community/viewtopic.php?p=260329) ;; fures: System + Network monitor - with net history graph (http://www.autohotkey.com/community/viewtopic.php?p=260329)
;; Sean: Network Download/Upload Meter (http://www.autohotkey.com/community/viewtopic.php?t=18033) ;; Sean: Network Download/Upload Meter (http://www.autohotkey.com/community/viewtopic.php?t=18033)
ResourceMonitor_getSystemTimes() ResourceMonitor_getSystemTimes()
{ ;; Total CPU Load { ;; Total CPU Load
Static oldIdleTime, oldKrnlTime, oldUserTime Static oldIdleTime, oldKrnlTime, oldUserTime
Static newIdleTime, newKrnlTime, newUserTime Static newIdleTime, newKrnlTime, newUserTime

View file

@ -1,27 +1,27 @@
/* /*
bug.n -- tiling window management bug.n -- tiling window management
Copyright (c) 2010-2012 Joshua Fuhs, joten Copyright (c) 2010-2012 Joshua Fuhs, joten
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
@version 8.3.0 @version 8.4.0
*/ */
View_init(m, v) View_init(m, v)
{ {
Global Global
View_#%m%_#%v%_aWndId := 0 View_#%m%_#%v%_aWndId := 0
View_#%m%_#%v%_layout_#1 := 1 View_#%m%_#%v%_layout_#1 := 1
View_#%m%_#%v%_layout_#2 := 1 View_#%m%_#%v%_layout_#2 := 1
@ -38,14 +38,14 @@ View_init(m, v)
View_#%m%_#%v%_wndIds := "" View_#%m%_#%v%_wndIds := ""
} }
View_activateWindow(d) View_activateWindow(d)
{ {
Local aWndId, direction, failure, i, j, v, wndId, wndId0, wndIds Local aWndId, direction, failure, i, j, v, wndId, wndId0, wndIds
Debug_logMessage("DEBUG[1] View_activateWindow(" . d . ")", 1) Debug_logMessage("DEBUG[1] View_activateWindow(" . d . ")", 1)
If (d = 0) If (d = 0)
Return Return
WinGet, aWndId, ID, A WinGet, aWndId, ID, A
Debug_logMessage("DEBUG[2] Active Windows ID: " . aWndId, 2, False) Debug_logMessage("DEBUG[2] Active Windows ID: " . aWndId, 2, False)
v := Monitor_#%Manager_aMonitor%_aView_#1 v := Monitor_#%Manager_aMonitor%_aView_#1
@ -53,55 +53,55 @@ View_activateWindow(d)
StringTrimRight, wndIds, View_#%Manager_aMonitor%_#%v%_wndIds, 1 StringTrimRight, wndIds, View_#%Manager_aMonitor%_#%v%_wndIds, 1
StringSplit, wndId, wndIds, `; StringSplit, wndId, wndIds, `;
Debug_logMessage("DEBUG[2] wndId count: " . wndId0, 2, False) Debug_logMessage("DEBUG[2] wndId count: " . wndId0, 2, False)
If (wndId0 > 1) If (wndId0 > 1)
{ {
If Manager_#%aWndId%_isFloating If Manager_#%aWndId%_isFloating
Manager_winSet("Bottom", "", aWndId) Manager_winSet("Bottom", "", aWndId)
Loop, % wndId0 Loop, % wndId0
{ {
If (wndId%A_Index% = aWndId) If (wndId%A_Index% = aWndId)
{ {
i := A_Index i := A_Index
Break Break
} }
} }
Debug_logMessage("DEBUG[2] Current wndId index: " . i, 2, False) Debug_logMessage("DEBUG[2] Current wndId index: " . i, 2, False)
If (d > 0) If (d > 0)
direction = 1 direction = 1
Else Else
direction = -1 direction = -1
j := Manager_loop(i, d, 1, wndId0) j := Manager_loop(i, d, 1, wndId0)
Loop, % wndId0 Loop, % wndId0
{ {
Debug_logMessage("DEBUG[2] Next wndId index: " . j, 2, False) Debug_logMessage("DEBUG[2] Next wndId index: " . j, 2, False)
wndId := wndId%j% wndId := wndId%j%
Manager_winSet("AlwaysOnTop", "On", wndId) Manager_winSet("AlwaysOnTop", "On", wndId)
Manager_winSet("AlwaysOnTop", "Off", wndId) Manager_winSet("AlwaysOnTop", "Off", wndId)
;; If there are hung windows on the screen, we still want to be able to cycle through them. ;; If there are hung windows on the screen, we still want to be able to cycle through them.
failure := Manager_winActivate(wndId) failure := Manager_winActivate(wndId)
If Not failure If Not failure
Break Break
j := Manager_loop(j, direction, 1, wndId0) j := Manager_loop(j, direction, 1, wndId0)
} }
} }
} }
View_addWindow(m, v, wndId) View_addWindow(m, v, wndId)
{ {
Local i, l, mSplit, n, replace, search Local i, l, mSplit, n, replace, search
l := View_#%m%_#%v%_layout_#1 l := View_#%m%_#%v%_layout_#1
If (Config_layoutFunction_#%l% = "tile") And ((Config_newWndPosition = "masterBottom") Or (Config_newWndPosition = "stackTop")) If (Config_layoutFunction_#%l% = "tile") And ((Config_newWndPosition = "masterBottom") Or (Config_newWndPosition = "stackTop"))
{ {
n := View_getTiledWndIds(m, v) n := View_getTiledWndIds(m, v)
mSplit := View_#%m%_#%v%_layoutMX * View_#%m%_#%v%_layoutMY mSplit := View_#%m%_#%v%_layoutMX * View_#%m%_#%v%_layoutMY
If (mSplit = 1 And Config_newWndPosition = "masterBottom") If (mSplit = 1 And Config_newWndPosition = "masterBottom")
View_#%m%_#%v%_wndIds := wndId ";" . View_#%m%_#%v%_wndIds View_#%m%_#%v%_wndIds := wndId ";" . View_#%m%_#%v%_wndIds
Else If ((Config_newWndPosition = "masterBottom" And n < mSplit) Or (Config_newWndPosition = "stackTop" And n <= mSplit)) Else If ((Config_newWndPosition = "masterBottom" And n < mSplit) Or (Config_newWndPosition = "stackTop" And n <= mSplit))
View_#%m%_#%v%_wndIds .= wndId ";" View_#%m%_#%v%_wndIds .= wndId ";"
Else Else
{ {
If (Config_newWndPosition = "masterBottom") If (Config_newWndPosition = "masterBottom")
i := mSplit - 1 i := mSplit - 1
@ -118,21 +118,21 @@ View_addWindow(m, v, wndId)
View_#%m%_#%v%_wndIds := wndId ";" View_#%m%_#%v%_wndIds View_#%m%_#%v%_wndIds := wndId ";" View_#%m%_#%v%_wndIds
} }
View_arrange(m, v) View_arrange(m, v)
{ {
Local fn, h, l, w, x, y Local fn, h, l, w, x, y
Debug_logMessage("DEBUG[1] View_arrange(" . m . ", " . v . ")", 1) Debug_logMessage("DEBUG[1] View_arrange(" . m . ", " . v . ")", 1)
l := View_#%m%_#%v%_layout_#1 l := View_#%m%_#%v%_layout_#1
fn := Config_layoutFunction_#%l% fn := Config_layoutFunction_#%l%
If fn If fn
{ {
x := Monitor_#%m%_x + View_#%m%_#%v%_layoutGapWidth + View_#%m%_#%v%_margin4 x := Monitor_#%m%_x + View_#%m%_#%v%_layoutGapWidth + View_#%m%_#%v%_margin4
y := Monitor_#%m%_y + View_#%m%_#%v%_layoutGapWidth + View_#%m%_#%v%_margin1 y := Monitor_#%m%_y + View_#%m%_#%v%_layoutGapWidth + View_#%m%_#%v%_margin1
w := Monitor_#%m%_width - 2 * View_#%m%_#%v%_layoutGapWidth - View_#%m%_#%v%_margin4 - View_#%m%_#%v%_margin2 w := Monitor_#%m%_width - 2 * View_#%m%_#%v%_layoutGapWidth - View_#%m%_#%v%_margin4 - View_#%m%_#%v%_margin2
h := Monitor_#%m%_height - 2 * View_#%m%_#%v%_layoutGapWidth - View_#%m%_#%v%_margin1 - View_#%m%_#%v%_margin3 h := Monitor_#%m%_height - 2 * View_#%m%_#%v%_layoutGapWidth - View_#%m%_#%v%_margin1 - View_#%m%_#%v%_margin3
;; All window actions are performed on independent windows. A delay won't help. ;; All window actions are performed on independent windows. A delay won't help.
SetWinDelay, 0 SetWinDelay, 0
View_getTiledWndIds(m, v) View_getTiledWndIds(m, v)
@ -141,30 +141,30 @@ View_arrange(m, v)
} }
Else ;; floating layout (no 'View_arrange_', following is 'View_getLayoutSymbol_')' Else ;; floating layout (no 'View_arrange_', following is 'View_getLayoutSymbol_')'
View_#%m%_#%v%_layoutSymbol := Config_layoutSymbol_#%l% View_#%m%_#%v%_layoutSymbol := Config_layoutSymbol_#%l%
Bar_updateLayout(m) Bar_updateLayout(m)
} }
View_arrange_monocle(m, v, x, y, w, h) View_arrange_monocle(m, v, x, y, w, h)
{ {
Global Global
;; 'View_getLayoutSymbol_monocle' ;; 'View_getLayoutSymbol_monocle'
View_#%m%_#%v%_layoutSymbol := "[" View_tiledWndId0 "]" View_#%m%_#%v%_layoutSymbol := "[" View_tiledWndId0 "]"
;; 'View_arrange_monocle' ;; 'View_arrange_monocle'
View_stackWindows("View_tiledWndId", 1, View_tiledWndId0, +1, 3, x, y, w, h, 0) View_stackWindows("View_tiledWndId", 1, View_tiledWndId0, +1, 3, x, y, w, h, 0)
} }
View_arrange_tile(m, v, x, y, w, h) View_arrange_tile(m, v, x, y, w, h)
{ {
Local axis1, axis2, axis3, flipped, gapW, h1, h2, mFact, mSplit, mWndCount, mXSet, mYActual, mYSet, stackLen, subAreaCount, subAreaWndCount, subH1, subW1, subX1, subY1, w1, w2, x1, x2, y1, y2 Local axis1, axis2, axis3, flipped, gapW, h1, h2, mFact, mSplit, mWndCount, mXSet, mYActual, mYSet, stackLen, subAreaCount, subAreaWndCount, subH1, subW1, subX1, subY1, w1, w2, x1, x2, y1, y2
View_#%m%_#%v%_layoutSymbol := View_getLayoutSymbol_tile(m, v, View_tiledWndId0) View_#%m%_#%v%_layoutSymbol := View_getLayoutSymbol_tile(m, v, View_tiledWndId0)
Debug_logMessage("DEBUG[1] View_arrange_tile: (" . View_tiledWndId0 . ") ", 1) Debug_logMessage("DEBUG[1] View_arrange_tile: (" . View_tiledWndId0 . ") ", 1)
If (View_tiledWndId0 = 0) If (View_tiledWndId0 = 0)
Return Return
axis1 := Abs(View_#%m%_#%v%_layoutAxis_#1) axis1 := Abs(View_#%m%_#%v%_layoutAxis_#1)
axis2 := View_#%m%_#%v%_layoutAxis_#2 axis2 := View_#%m%_#%v%_layoutAxis_#2
axis3 := View_#%m%_#%v%_layoutAxis_#3 axis3 := View_#%m%_#%v%_layoutAxis_#3
@ -176,20 +176,20 @@ View_arrange_tile(m, v, x, y, w, h)
mSplit := mXSet * mYSet mSplit := mXSet * mYSet
If (mSplit > View_tiledWndId0) If (mSplit > View_tiledWndId0)
mSplit := View_tiledWndId0 mSplit := View_tiledWndId0
;; Areas (master and stack) ;; Areas (master and stack)
x1 := x x1 := x
y1 := y y1 := y
w1 := w w1 := w
h1 := h h1 := h
If (View_tiledWndId0 > mSplit) If (View_tiledWndId0 > mSplit)
{ ;; There is a stack area. { ;; There is a stack area.
If flipped If flipped
View_splitArea(axis1 - 1, 1 - mFact, x1, y1, w1, h1, gapW, x2, y2, w2, h2, x1, y1, w1, h1) View_splitArea(axis1 - 1, 1 - mFact, x1, y1, w1, h1, gapW, x2, y2, w2, h2, x1, y1, w1, h1)
Else Else
View_splitArea(axis1 - 1, mFact, x1, y1, w1, h1, gapW, x1, y1, w1, h1, x2, y2, w2, h2) View_splitArea(axis1 - 1, mFact, x1, y1, w1, h1, gapW, x1, y1, w1, h1, x2, y2, w2, h2)
} }
;; Master ;; Master
If (axis2 = 3) If (axis2 = 3)
View_stackWindows("View_tiledWndId", 1, mSplit, +1, 3, x1, y1, w1, h1, 0) View_stackWindows("View_tiledWndId", 1, mSplit, +1, 3, x1, y1, w1, h1, 0)
@ -198,7 +198,7 @@ View_arrange_tile(m, v, x, y, w, h)
mYActual := Ceil(mSplit / mXSet) mYActual := Ceil(mSplit / mXSet)
subAreaCount := mYActual subAreaCount := mYActual
mWndCount := mSplit mWndCount := mSplit
Loop, % mYActual Loop, % mYActual
{ {
View_splitArea(Not (axis2 - 1), 1 / subAreaCount, x1, y1, w1, h1, gapW, subX1, subY1, subW1, subH1, x1, y1, w1, h1) View_splitArea(Not (axis2 - 1), 1 / subAreaCount, x1, y1, w1, h1, gapW, subX1, subY1, subW1, subH1, x1, y1, w1, h1)
subAreaWndCount := mXSet subAreaWndCount := mXSet
@ -209,16 +209,16 @@ View_arrange_tile(m, v, x, y, w, h)
subAreaCount -= 1 subAreaCount -= 1
} }
} }
;; Stack ;; Stack
If (View_tiledWndId0 <= mSplit) If (View_tiledWndId0 <= mSplit)
Return Return
stackLen := View_tiledWndId0 - mSplit stackLen := View_tiledWndId0 - mSplit
;; 161 is the minimal width of an Windows-Explorer window, below which it cannot be resized. ;; 161 is the minimal width of an Windows-Explorer window, below which it cannot be resized.
;; The minimal height is 243, but this seems too high for being a limit here; ;; The minimal height is 243, but this seems too high for being a limit here;
;; therefor '2 * Bar_height' is used for the minimal height of a window. ;; therefor '2 * Bar_height' is used for the minimal height of a window.
If (axis3 = 3 Or (axis3 = 1 And (w2 - (stackLen - 1) * gapW) / stackLen < 161) Or (axis3 = 2 And (h2 - (stackLen - 1) * gapW) / stackLen < 2 * Bar_height)) If (axis3 = 3 Or (axis3 = 1 And (w2 - (stackLen - 1) * gapW) / stackLen < 161) Or (axis3 = 2 And (h2 - (stackLen - 1) * gapW) / stackLen < 2 * Bar_height))
View_stackWindows("View_tiledWndId", mSplit + 1, stackLen, +1, 3, x2, y2, w2, h2, 0) View_stackWindows("View_tiledWndId", mSplit + 1, stackLen, +1, 3, x2, y2, w2, h2, 0)
Else Else
View_stackWindows("View_tiledWndId", mSplit + 1, stackLen, +1, axis3, x2, y2, w2, h2, gapW) View_stackWindows("View_tiledWndId", mSplit + 1, stackLen, +1, axis3, x2, y2, w2, h2, gapW)
@ -227,9 +227,9 @@ View_arrange_tile(m, v, x, y, w, h)
View_getActiveWindow(m, v) View_getActiveWindow(m, v)
{ {
Local aWndClass, aWndId, aWndTitle Local aWndClass, aWndId, aWndTitle
WinGet, aWndId, ID, A WinGet, aWndId, ID, A
If WinExist("ahk_id" aWndId) And InStr(View_#%m%_#%v%_wndIds, aWndId ";") If WinExist("ahk_id" aWndId) And InStr(View_#%m%_#%v%_wndIds, aWndId ";")
{ {
WinGetClass, aWndClass, ahk_id %aWndId% WinGetClass, aWndClass, ahk_id %aWndId%
WinGetTitle, aWndTitle, ahk_id %aWndId% WinGetTitle, aWndTitle, ahk_id %aWndId%
@ -239,10 +239,10 @@ View_getActiveWindow(m, v)
Return, 0 Return, 0
} }
View_getLayoutSymbol_tile(m, v, n) View_getLayoutSymbol_tile(m, v, n)
{ {
Local axis1, axis2, axis3, masterDim, masterDiv, mx, my, stackSym Local axis1, axis2, axis3, masterDim, masterDiv, mx, my, stackSym
;; Main axis ;; Main axis
;; 1 - vertical divider, master left ;; 1 - vertical divider, master left
;; 2 - horizontal divider, master top ;; 2 - horizontal divider, master top
@ -261,39 +261,39 @@ View_getLayoutSymbol_tile(m, v, n)
axis3 := View_#%m%_#%v%_layoutAxis_#3 axis3 := View_#%m%_#%v%_layoutAxis_#3
mx := View_#%m%_#%v%_layoutMX mx := View_#%m%_#%v%_layoutMX
my := View_#%m%_#%v%_layoutMY my := View_#%m%_#%v%_layoutMY
If (Abs(axis1) = 1) If (Abs(axis1) = 1)
masterDiv := "|" masterDiv := "|"
Else Else
masterDiv := "-" masterDiv := "-"
If (axis2 = 1) If (axis2 = 1)
masterDim := mx . "x" . my masterDim := mx . "x" . my
Else If (axis2 = 2) Else If (axis2 = 2)
masterDim := mx . "x" . my masterDim := mx . "x" . my
Else Else
masterDim := "[" . (mx * my) . "]" masterDim := "[" . (mx * my) . "]"
If (axis3 = 1) If (axis3 = 1)
stackSym := "|" stackSym := "|"
Else If (axis3 = 2) Else If (axis3 = 2)
stackSym := "=" stackSym := "="
Else Else
stackSym := n - (mx * my) stackSym := n - (mx * my)
If (axis1 > 0) If (axis1 > 0)
Return, masterDim . masterDiv . stackSym Return, masterDim . masterDiv . stackSym
Else Else
Return, stackSym . masterDiv . masterDim Return, stackSym . masterDiv . masterDim
} }
View_getTiledWndIds(m, v) View_getTiledWndIds(m, v)
{ {
Local n, tiledWndIds, wndIds Local n, tiledWndIds, wndIds
StringTrimRight, wndIds, View_#%m%_#%v%_wndIds, 1 StringTrimRight, wndIds, View_#%m%_#%v%_wndIds, 1
Loop, PARSE, wndIds, `; Loop, PARSE, wndIds, `;
{ {
If Not Manager_#%A_LoopField%_isFloating And WinExist("ahk_id " A_LoopField) and Not Manager_isHung(A_LoopField) If Not Manager_#%A_LoopField%_isFloating And WinExist("ahk_id " A_LoopField) and Not Manager_isHung(A_LoopField)
{ {
n += 1 n += 1
tiledWndIds .= A_LoopField ";" tiledWndIds .= A_LoopField ";"
@ -301,44 +301,44 @@ View_getTiledWndIds(m, v)
} }
StringTrimRight, tiledWndIds, tiledWndIds, 1 StringTrimRight, tiledWndIds, tiledWndIds, 1
StringSplit, View_tiledWndId, tiledWndIds, `; StringSplit, View_tiledWndId, tiledWndIds, `;
Return, n Return, n
} }
View_ghostWindow(m, v, bodyWndId, ghostWndId) View_ghostWindow(m, v, bodyWndId, ghostWndId)
{ {
Local search, replace Local search, replace
search := bodyWndId ";" search := bodyWndId ";"
replace := search ghostWndId ";" replace := search ghostWndId ";"
StringReplace, View_#%m%_#%v%_wndIds, View_#%m%_#%v%_wndIds, %search%, %replace% StringReplace, View_#%m%_#%v%_wndIds, View_#%m%_#%v%_wndIds, %search%, %replace%
} }
View_rotateLayoutAxis(i, d) View_rotateLayoutAxis(i, d)
{ {
Local f, l, n, tmp, v Local f, l, n, tmp, v
v := Monitor_#%Manager_aMonitor%_aView_#1 v := Monitor_#%Manager_aMonitor%_aView_#1
l := View_#%Manager_aMonitor%_#%v%_layout_#1 l := View_#%Manager_aMonitor%_#%v%_layout_#1
If (Config_layoutFunction_#%l% = "tile") And (i = 1 Or i = 2 Or i = 3) If (Config_layoutFunction_#%l% = "tile") And (i = 1 Or i = 2 Or i = 3)
{ {
If (i = 1) If (i = 1)
{ {
If (d = +2) If (d = +2)
View_#%Manager_aMonitor%_#%v%_layoutAxis_#%i% *= -1 View_#%Manager_aMonitor%_#%v%_layoutAxis_#%i% *= -1
Else Else
{ {
f := View_#%Manager_aMonitor%_#%v%_layoutAxis_#%i% / Abs(View_#%Manager_aMonitor%_#%v%_layoutAxis_#%i%) f := View_#%Manager_aMonitor%_#%v%_layoutAxis_#%i% / Abs(View_#%Manager_aMonitor%_#%v%_layoutAxis_#%i%)
View_#%Manager_aMonitor%_#%v%_layoutAxis_#%i% := f * Manager_loop(Abs(View_#%Manager_aMonitor%_#%v%_layoutAxis_#%i%), d, 1, 2) View_#%Manager_aMonitor%_#%v%_layoutAxis_#%i% := f * Manager_loop(Abs(View_#%Manager_aMonitor%_#%v%_layoutAxis_#%i%), d, 1, 2)
} }
} }
Else Else
{ {
n := Manager_loop(View_#%Manager_aMonitor%_#%v%_layoutAxis_#%i%, d, 1, 3) n := Manager_loop(View_#%Manager_aMonitor%_#%v%_layoutAxis_#%i%, d, 1, 3)
;; When we rotate the axis, we may need to swap the X and Y dimensions. ;; When we rotate the axis, we may need to swap the X and Y dimensions.
;; We only need to check this when the master axis changes (i = 2) ;; We only need to check this when the master axis changes (i = 2)
;; If the original axis was 1 (X) or the new axis is 1 (X) (Y and Z are defined to be the same) ;; If the original axis was 1 (X) or the new axis is 1 (X) (Y and Z are defined to be the same)
If (i = 2) And Not (n = View_#%Manager_aMonitor%_#%v%_layoutAxis_#%i%) And (n = 1 Or View_#%Manager_aMonitor%_#%v%_layoutAxis_#%i% = 1) If (i = 2) And Not (n = View_#%Manager_aMonitor%_#%v%_layoutAxis_#%i%) And (n = 1 Or View_#%Manager_aMonitor%_#%v%_layoutAxis_#%i% = 1)
{ {
tmp := View_#%Manager_aMonitor%_#%v%_layoutMX tmp := View_#%Manager_aMonitor%_#%v%_layoutMX
View_#%Manager_aMonitor%_#%v%_layoutMX := View_#%Manager_aMonitor%_#%v%_layoutMY View_#%Manager_aMonitor%_#%v%_layoutMX := View_#%Manager_aMonitor%_#%v%_layoutMY
@ -350,20 +350,20 @@ View_rotateLayoutAxis(i, d)
} }
} }
View_setGapWidth(d) View_setGapWidth(d)
{ {
Local l, v, w Local l, v, w
v := Monitor_#%Manager_aMonitor%_aView_#1 v := Monitor_#%Manager_aMonitor%_aView_#1
l := View_#%Manager_aMonitor%_#%v%_layout_#1 l := View_#%Manager_aMonitor%_#%v%_layout_#1
If (Config_layoutFunction_#%l% = "tile" Or Config_layoutFunction_#%l% = "monocle") If (Config_layoutFunction_#%l% = "tile" Or Config_layoutFunction_#%l% = "monocle")
{ {
If (d < 0) If (d < 0)
d := Floor(d / 2) * 2 d := Floor(d / 2) * 2
Else Else
d := Ceil(d / 2) * 2 d := Ceil(d / 2) * 2
w := View_#%Manager_aMonitor%_#%v%_layoutGapWidth + d w := View_#%Manager_aMonitor%_#%v%_layoutGapWidth + d
If (w < Monitor_#%Manager_aMonitor%_height And w < Monitor_#%Manager_aMonitor%_width) If (w < Monitor_#%Manager_aMonitor%_height And w < Monitor_#%Manager_aMonitor%_width)
{ {
View_#%Manager_aMonitor%_#%v%_layoutGapWidth := w View_#%Manager_aMonitor%_#%v%_layoutGapWidth := w
View_arrange(Manager_aMonitor, v) View_arrange(Manager_aMonitor, v)
@ -371,18 +371,18 @@ View_setGapWidth(d)
} }
} }
View_setLayout(l) View_setLayout(l)
{ {
Local v Local v
v := Monitor_#%Manager_aMonitor%_aView_#1 v := Monitor_#%Manager_aMonitor%_aView_#1
If (l = -1) If (l = -1)
l := View_#%Manager_aMonitor%_#%v%_layout_#2 l := View_#%Manager_aMonitor%_#%v%_layout_#2
If (l = ">") If (l = ">")
l := Manager_loop(View_#%Manager_aMonitor%_#%v%_layout_#1, +1, 1, Config_layoutCount) l := Manager_loop(View_#%Manager_aMonitor%_#%v%_layout_#1, +1, 1, Config_layoutCount)
If (l > 0) And (l <= Config_layoutCount) If (l > 0) And (l <= Config_layoutCount)
{ {
If Not (l = View_#%Manager_aMonitor%_#%v%_layout_#1) If Not (l = View_#%Manager_aMonitor%_#%v%_layout_#1)
{ {
View_#%Manager_aMonitor%_#%v%_layout_#2 := View_#%Manager_aMonitor%_#%v%_layout_#1 View_#%Manager_aMonitor%_#%v%_layout_#2 := View_#%Manager_aMonitor%_#%v%_layout_#1
View_#%Manager_aMonitor%_#%v%_layout_#1 := l View_#%Manager_aMonitor%_#%v%_layout_#1 := l
@ -391,20 +391,20 @@ View_setLayout(l)
} }
} }
View_setMFactor(d) View_setMFactor(d)
{ {
Local l, mFact, v Local l, mFact, v
v := Monitor_#%Manager_aMonitor%_aView_#1 v := Monitor_#%Manager_aMonitor%_aView_#1
l := View_#%Manager_aMonitor%_#%v%_layout_#1 l := View_#%Manager_aMonitor%_#%v%_layout_#1
If (Config_layoutFunction_#%l% = "tile") If (Config_layoutFunction_#%l% = "tile")
{ {
mFact := 0 mFact := 0
If (d >= 1.05) If (d >= 1.05)
mFact := d mFact := d
Else Else
mFact := View_#%Manager_aMonitor%_#%v%_layoutMFact + d mFact := View_#%Manager_aMonitor%_#%v%_layoutMFact + d
If (mFact >= 0.05 And mFact <= 0.95) If (mFact >= 0.05 And mFact <= 0.95)
{ {
View_#%Manager_aMonitor%_#%v%_layoutMFact := mFact View_#%Manager_aMonitor%_#%v%_layoutMFact := mFact
View_arrange(Manager_aMonitor, v) View_arrange(Manager_aMonitor, v)
@ -412,55 +412,55 @@ View_setMFactor(d)
} }
} }
View_setMX(d) View_setMX(d)
{ {
Local l, n, v Local l, n, v
v := Monitor_#%Manager_aMonitor%_aView_#1 v := Monitor_#%Manager_aMonitor%_aView_#1
l := View_#%Manager_aMonitor%_#%v%_layout_#1 l := View_#%Manager_aMonitor%_#%v%_layout_#1
If Not (Config_layoutFunction_#%l% = "tile") If Not (Config_layoutFunction_#%l% = "tile")
Return Return
n := View_#%Manager_aMonitor%_#%v%_layoutMX + d n := View_#%Manager_aMonitor%_#%v%_layoutMX + d
If (n >= 1) And (n <= 9) If (n >= 1) And (n <= 9)
{ {
View_#%Manager_aMonitor%_#%v%_layoutMX := n View_#%Manager_aMonitor%_#%v%_layoutMX := n
View_arrange(Manager_aMonitor, v) View_arrange(Manager_aMonitor, v)
} }
} }
View_setMY(d) View_setMY(d)
{ {
Local l, n, v Local l, n, v
v := Monitor_#%Manager_aMonitor%_aView_#1 v := Monitor_#%Manager_aMonitor%_aView_#1
l := View_#%Manager_aMonitor%_#%v%_layout_#1 l := View_#%Manager_aMonitor%_#%v%_layout_#1
If Not (Config_layoutFunction_#%l% = "tile") If Not (Config_layoutFunction_#%l% = "tile")
Return Return
n := View_#%Manager_aMonitor%_#%v%_layoutMY + d n := View_#%Manager_aMonitor%_#%v%_layoutMY + d
If (n >= 1) And (n <= 9) If (n >= 1) And (n <= 9)
{ {
View_#%Manager_aMonitor%_#%v%_layoutMY := n View_#%Manager_aMonitor%_#%v%_layoutMY := n
View_arrange(Manager_aMonitor, v) View_arrange(Manager_aMonitor, v)
} }
} }
View_shuffleWindow(d) View_shuffleWindow(d)
{ {
Local aWndHeight, aWndId, aWndWidth, aWndX, aWndY, i, j, l, search, v Local aWndHeight, aWndId, aWndWidth, aWndX, aWndY, i, j, l, search, v
WinGet, aWndId, ID, A WinGet, aWndId, ID, A
v := Monitor_#%Manager_aMonitor%_aView_#1 v := Monitor_#%Manager_aMonitor%_aView_#1
l := View_#%Manager_aMonitor%_#%v%_layout_#1 l := View_#%Manager_aMonitor%_#%v%_layout_#1
If (Config_layoutFunction_#%l% = "tile" And InStr(Manager_managedWndIds, aWndId ";")) If (Config_layoutFunction_#%l% = "tile" And InStr(Manager_managedWndIds, aWndId ";"))
{ {
View_getTiledWndIds(Manager_aMonitor, v) View_getTiledWndIds(Manager_aMonitor, v)
If (View_tiledWndId0 > 1) If (View_tiledWndId0 > 1)
{ {
Loop, % View_tiledWndId0 Loop, % View_tiledWndId0
{ {
If (View_tiledWndId%A_Index% = aWndId) If (View_tiledWndId%A_Index% = aWndId)
{ {
i := A_Index i := A_Index
Break Break
@ -470,14 +470,14 @@ View_shuffleWindow(d)
j := 2 j := 2
Else Else
j := Manager_loop(i, d, 1, View_tiledWndId0) j := Manager_loop(i, d, 1, View_tiledWndId0)
If (j > 0 And j <= View_tiledWndId0) If (j > 0 And j <= View_tiledWndId0)
{ {
If (j = i) If (j = i)
{ {
StringReplace, View_#%Manager_aMonitor%_#%v%_wndIds, View_#%Manager_aMonitor%_#%v%_wndIds, %aWndId%`;, StringReplace, View_#%Manager_aMonitor%_#%v%_wndIds, View_#%Manager_aMonitor%_#%v%_wndIds, %aWndId%`;,
View_#%Manager_aMonitor%_#%v%_wndIds := aWndId ";" View_#%Manager_aMonitor%_#%v%_wndIds View_#%Manager_aMonitor%_#%v%_wndIds := aWndId ";" View_#%Manager_aMonitor%_#%v%_wndIds
} }
Else Else
{ {
search := View_tiledWndId%j% search := View_tiledWndId%j%
StringReplace, View_#%Manager_aMonitor%_#%v%_wndIds, View_#%Manager_aMonitor%_#%v%_wndIds, %aWndId%, SEARCH StringReplace, View_#%Manager_aMonitor%_#%v%_wndIds, View_#%Manager_aMonitor%_#%v%_wndIds, %aWndId%, SEARCH
@ -485,8 +485,8 @@ View_shuffleWindow(d)
StringReplace, View_#%Manager_aMonitor%_#%v%_wndIds, View_#%Manager_aMonitor%_#%v%_wndIds, SEARCH, %search% StringReplace, View_#%Manager_aMonitor%_#%v%_wndIds, View_#%Manager_aMonitor%_#%v%_wndIds, SEARCH, %search%
} }
View_arrange(Manager_aMonitor, v) View_arrange(Manager_aMonitor, v)
If Config_mouseFollowsFocus If Config_mouseFollowsFocus
{ {
WinGetPos, aWndX, aWndY, aWndWidth, aWndHeight, ahk_id %aWndId% WinGetPos, aWndX, aWndY, aWndWidth, aWndHeight, ahk_id %aWndId%
DllCall("SetCursorPos", "Int", Round(aWndX + aWndWidth / 2), "Int", Round(aWndY + aWndHeight / 2)) DllCall("SetCursorPos", "Int", Round(aWndX + aWndWidth / 2), "Int", Round(aWndY + aWndHeight / 2))
@ -496,11 +496,11 @@ View_shuffleWindow(d)
} }
} }
View_splitArea(axis, splitRatio, x, y, w, h, gapW, ByRef x1, ByRef y1, ByRef w1, ByRef h1, ByRef x2, ByRef y2, ByRef w2, ByRef h2) View_splitArea(axis, splitRatio, x, y, w, h, gapW, ByRef x1, ByRef y1, ByRef w1, ByRef h1, ByRef x2, ByRef y2, ByRef w2, ByRef h2)
{ {
x1 := x x1 := x
y1 := y y1 := y
If (splitRatio = 1) If (splitRatio = 1)
{ {
w1 := w w1 := w
w2 := 0 w2 := 0
@ -509,7 +509,7 @@ View_splitArea(axis, splitRatio, x, y, w, h, gapW, ByRef x1, ByRef y1, ByRef w1,
x2 := x + w1 x2 := x + w1
y2 := y + h1 y2 := y + h1
} }
Else If (axis = 0) Else If (axis = 0)
{ {
w1 := w * splitRatio - gapW / 2 w1 := w * splitRatio - gapW / 2
w2 := w - w1 - gapW w2 := w - w1 - gapW
@ -546,32 +546,32 @@ View_splitArea(axis, splitRatio, x, y, w, h, gapW, ByRef x1, ByRef y1, ByRef w1,
View_stackWindows(arrayName, startPos, len, d, axis, x, y, w, h, padding) View_stackWindows(arrayName, startPos, len, d, axis, x, y, w, h, padding)
{ {
Local dx, dy, i, wndH, wndW, wndX, wndY Local dx, dy, i, wndH, wndW, wndX, wndY
;; d = +1: Left-to-right and top-to-bottom, depending on axis ;; d = +1: Left-to-right and top-to-bottom, depending on axis
i := startPos i := startPos
;; d = -1: Right-to-left and bottom-to-top, depending on axis ;; d = -1: Right-to-left and bottom-to-top, depending on axis
If (d < 0) If (d < 0)
i += len - 1 i += len - 1
wndX := x wndX := x
wndY := y wndY := y
wndW := w wndW := w
wndH := h wndH := h
dx := 0 dx := 0
dy := 0 dy := 0
If (axis = 1) If (axis = 1)
{ {
wndW := (w - (len - 1) * padding) / len wndW := (w - (len - 1) * padding) / len
dx := wndW + padding dx := wndW + padding
} }
Else If (axis = 2) Else If (axis = 2)
{ {
wndH := (h - (len - 1) * padding) / len wndH := (h - (len - 1) * padding) / len
dy := wndH + padding dy := wndH + padding
} }
;; Else (axis = 3) and nothing to do ;; Else (axis = 3) and nothing to do
Loop, % len Loop, % len
{ {
Manager_winMove(%arrayName%%i%, wndX, wndY, wndW, wndH) Manager_winMove(%arrayName%%i%, wndX, wndY, wndW, wndH)
i += d i += d
@ -580,14 +580,14 @@ View_stackWindows(arrayName, startPos, len, d, axis, x, y, w, h, padding)
} }
} }
View_toggleFloating() View_toggleFloating()
{ {
Local aWndId, l, v Local aWndId, l, v
WinGet, aWndId, ID, A WinGet, aWndId, ID, A
v := Monitor_#%Manager_aMonitor%_aView_#1 v := Monitor_#%Manager_aMonitor%_aView_#1
l := View_#%Manager_aMonitor%_#%v%_layout_#1 l := View_#%Manager_aMonitor%_#%v%_layout_#1
If (Config_layoutFunction_#%l% And InStr(Manager_managedWndIds, aWndId ";")) If (Config_layoutFunction_#%l% And InStr(Manager_managedWndIds, aWndId ";"))
{ {
Manager_#%aWndId%_isFloating := Not Manager_#%aWndId%_isFloating Manager_#%aWndId%_isFloating := Not Manager_#%aWndId%_isFloating
View_arrange(Manager_aMonitor, v) View_arrange(Manager_aMonitor, v)
@ -595,18 +595,18 @@ View_toggleFloating()
} }
} }
View_toggleMargins() View_toggleMargins()
{ {
Local v 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) 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") If Not (Config_viewMargins = "0;0;0;0")
{ {
v := Monitor_#%Manager_aMonitor%_aView_#1 v := Monitor_#%Manager_aMonitor%_aView_#1
If (View_#%Manager_aMonitor%_#%v%_margins = "0;0;0;0") If (View_#%Manager_aMonitor%_#%v%_margins = "0;0;0;0")
View_#%Manager_aMonitor%_#%v%_margins := Config_viewMargins View_#%Manager_aMonitor%_#%v%_margins := Config_viewMargins
Else Else
View_#%Manager_aMonitor%_#%v%_margins := "0;0;0;0" View_#%Manager_aMonitor%_#%v%_margins := "0;0;0;0"
StringSplit, View_#%Manager_aMonitor%_#%v%_margin, View_#%Manager_aMonitor%_#%v%_margins, `; StringSplit, View_#%Manager_aMonitor%_#%v%_margin, View_#%Manager_aMonitor%_#%v%_margins, `;
View_arrange(Manager_aMonitor, v) View_arrange(Manager_aMonitor, v)

View file

@ -10,7 +10,8 @@
(~) changed (~) changed
(+) added (+) added
=?????=
=8.4.0=
(+) Session auto-save and restore. Layout and Window information is (+) Session auto-save and restore. Layout and Window information is
stored periodically so that it may be recovered after a restart. stored periodically so that it may be recovered after a restart.

View file

@ -38,32 +38,37 @@ window management of Microsoft Windows are as follows:
available screen estate. available screen estate.
Additionally bug.n increases the available screen estate by freeing up Additionally bug.n can increase the available screen estate by freeing
the space occupied by up the space occupied by
- the Microsoft Windows Taskbar - the Microsoft Windows Taskbar and
- the title bar for every single window - the title bar for every single window
by hiding and replacing all with a single slim status bar (but bug.n is by hiding and replacing all with a single slim status bar (but bug.n is
not a shell replacement). not a shell replacement).
This status bar may show the following: This status bar shows the following:
- system information
- time
- date
- CPU usage
- battery level
- active window title - active window title
- layout - layout, e. g.
- []= (tile) - 1x1|= (tile)
- [M] (monocle) - [0] (monocle)
- ><> (floating) - ><> (floating)
- up to nine views indicating - up to nine views indicating
- the active view - the active view
- how many windows are tagged with and shown on the view with the same - how many windows are tagged with and shown on the view with the same
number number
Additionally it can show the following system information:
- time
- date
- CPU usage
- memory usage
- disk load
- network load
- battery level
=== Layouts === === Layouts ===
There are three layouts. There are three layouts.
@ -74,7 +79,8 @@ There are three layouts.
- the dimensions of the master area (1x1 ... 2x3 ... 9x9) - the dimensions of the master area (1x1 ... 2x3 ... 9x9)
- the stacking direction of the master and stacking area (from left to - the stacking direction of the master and stacking area (from left to
right, from top to bottom or monocle) right, from top to bottom or monocle)
- the position of the master area (left, top, right or bottom) - the position of the master area (left, top, right or bottom) and
accordingly the position of the stacking area
- the witdh or height of the master area (depending on its position) - the witdh or height of the master area (depending on its position)
+ **monocle**''<BR>'' + **monocle**''<BR>''
All windows are maximized and only one is shown at any time. All windows are maximized and only one is shown at any time.
@ -109,10 +115,13 @@ read and write access. This is the only requirement for using bug.n (at
least for saving the bug.n configuration file). Apart from that you may least for saving the bug.n configuration file). Apart from that you may
copy bug.n to any directory. copy bug.n to any directory.
If you want to save it to a directory, to which you do not have write If you want to save it to a directory, to which you do not have write
access, you will have to run bug.n with a parameter indicating the file access and do not want to use the default directory for application data
path to the configuration file (<file path to the bug.n executable> (APPDATA, e. g. C:\Users\joten\AppData\Roaming\bug.n), you will have to
<file path to the session file>), e. g. run bug.n with a parameter indicating the file path to that application
"C:\Program Files\bugn\bugn.exe C:\Users\joten\bugn.ini". data directory, which i. a. contains the configuration file (config.ini)
(<file path to the bug.n executable> <file path to the data directory>),
e. g.
"C:\Program Files\bugn\bugn.exe D:\projects\bugn".
=== Microsoft Windows Vista / 7 and UAC === === Microsoft Windows Vista / 7 and UAC ===
@ -132,35 +141,37 @@ file properties.
Customization can be done Customization can be done
- with configuration variables for - with configuration variables for
- the appearance of the bug.n status bar (font, colour and content) - the appearance of the bug.n status bar (position, size, font,
colour and content)
- controlling Windows UI elements (border width and colour, hiding - controlling Windows UI elements (border width and colour, hiding
elements) elements)
- default values (number of tags, layouts, runtime and session - default values (number of tags, layouts, runtime and session
management) management)
- rules controlling specific windows (i. a. exclusions) - rules controlling specific windows (i. a. excluding windows from
tiling window management)
- for hotkeys (the key bindings for the bug.n functions) - for hotkeys (the key bindings for the bug.n functions)
The available configuration variables are listed in The available configuration variables are listed in
%%LINK_configuration.''<BR>'' %%LINK_configuration.''<BR>''
To change these, first create a session file by using the hotkey To change these, first create a configuration file by using the hotkey
"WIN+CTRL+S". The file is either saved in the directory you specified "WIN+CTRL+S". The file is either saved in the directory you specified
with the parameter to the executable, or in the same directory where the with the parameter to the executable, or in the same directory where the
executable is saved. You may then edit the file with a text editor executable is saved. You may then edit the file with a text editor
("WIN+CTRL+E" opens the file for editing) and add a new line for each ("WIN+CTRL+E" opens the file for editing) and add a new line for each
configuration variable with its value (format: <variable>=<value>, use configuration variable with its value (format: <variable>=<value>, use
no quotation marks, 1 for true and 0 for false), e. g. no quotation marks, 1 for true and 0 for false), e. g.
"Config_showBar=0". You will have to quit and run bug.n again for the "Config_showBar=0". You will have to reload bug.n for the changes to
changes to take effect.''<BR>'' take effect.''<BR>''
You may find a sample configuration file (Config_example.ini) in the You may find a sample configuration file (config_example.ini) in the
main directory of bug.n. main directory of bug.n.
== Usage == == Usage ==
bug.n is mostly controlled with hotkeys. The available hotkeys are bug.n is mostly controlled with hotkeys. The available hotkeys are
listed in %%LINK_hotkeys. A list of all functions is available through listed in %%LINK_hotkeys. For a quick help there are the following
the command GUI. For a quick help there are the following hotkeys: hotkeys:
- WIN+Y: Show the command GUI. - WIN+Y: Show the command GUI.
- WIN+Space: Show / Hide the Windows Taskbar. - WIN+Space: Show / Hide the Windows Taskbar.
- WIN+CTRL+Q: Quit bug.n and restore all windows and Windows UI - WIN+CTRL+Q: Quit bug.n and restore all windows and Windows UI
@ -176,8 +187,9 @@ The following functions can also be controlled with the mouse:
layout to the last used. layout to the last used.
- With a right-click on the layout symbol you can set the layout to the - With a right-click on the layout symbol you can set the layout to the
next in the list. next in the list.
- A function can be selected from a list in the command GUI, which is - A function can be selected from a list or entered in the command GUI,
accessible by cklickig on "#!" on the right end of the status bar. which is accessible by cklickig on "#!" on the right end of the status
bar.
''<BR>'' ''<BR>''