updated version number (my text editor might also have deleted unnecessary space)

This commit is contained in:
joten 2012-12-05 13:39:51 +01:00
parent e6ee31c281
commit ea41d7ae00
9 changed files with 721 additions and 720 deletions

View File

@ -1,32 +1,32 @@
/*
bug.n -- tiling window management
Copyright (c) 2010-2012 Joshua Fuhs, joten
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
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
If (SubStr(Config_barWidth, 0) = "%")
If (SubStr(Config_barWidth, 0) = "%")
{
StringTrimRight, wndWidth, Config_barWidth, 1
wndWidth := Round(Monitor_#%m%_width * wndWidth / 100)
}
}
Else
wndWidth := Config_barWidth
Monitor_#%m%_barWidth := wndWidth
@ -37,7 +37,7 @@ Bar_init(m)
y1 := 0
y2 := (Bar_ctrlHeight - Bar_textHeight) / 2
h2 := Bar_ctrlHeight - 2 * y2
;; Create the GUI window
wndTitle := "bug.n_BAR_" m
GuiN := (m - 1) + 1
@ -47,14 +47,14 @@ Bar_init(m)
Gui, +AlwaysOnTop -Caption +LabelBar_Gui +LastFound +ToolWindow
Gui, Color, %Config_normBgColor1%
Gui, Font, c%Config_normFgColor1% s%Config_fontSize%, %Config_fontName%
;; Tags
Loop, % Config_viewCount
Loop, % Config_viewCount
{
i := A_Index
text := " " Config_viewNames_#%i% " "
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)
Gui, Add, Progress, x%x1% y%y1% w%w% h%h1% Background%Config_normBgColor1% Vertical vBar_#%m%_#%i%_tagged
Else
@ -67,41 +67,41 @@ Bar_init(m)
i := Config_viewCount + 1
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, Font, c%Config_normFgColor2%
Gui, Add, Text, x%x1% y%y2% w%w% h%h2% -Wrap Center BackgroundTrans vBar_#%m%_#%i%, %text%
titleWidth -= w
x1 += w
;; 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
w := 0
If (i = Config_viewCount + 6)
If (i = Config_viewCount + 6)
{ ;; Command gui
Gui, -Disabled
w := Bar_getTextWidth(" ?? ")
x2 -= 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, 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
w := Bar_getTextWidth(" ??:?? ")
x2 -= w
titleWidth -= w
If Config_readinAny() Or Config_readinBat
If Config_readinAny() Or Config_readinBat
{
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%, ??:??
}
Else If (i = Config_viewCount + 4) And Config_readinAny()
}
Else If (i = Config_viewCount + 4) And Config_readinAny()
{ ;; Any
text := Config_readinAny()
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, Font, c%Config_normFgColor2%
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
w := Bar_getTextWidth(" BAT: ???% ")
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: ???`%
}
}
;; Window title (remaining space)
Gui, Add, Text, x%x1% y%y1% w%titleWidth% h%h1%,
If Not Config_singleRowBar
Gui, Add, Text, x%x1% y%y1% w%titleWidth% h%h1%,
If Not Config_singleRowBar
{
titleWidth := wndWidth
x1 := 0
@ -133,9 +133,9 @@ Bar_init(m)
}
i := Config_viewCount + 2
Gui, Font, c%Config_normFgColor1%
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%y1% w%titleWidth% h%h1%,
Gui, Add, Text, x%x1% y%y2% w%titleWidth% h%h2% BackgroundTrans Center vBar_#%m%_#%i%,
If (Config_horizontalBarPos = "left")
x1 := 0
Else If (Config_horizontalBarPos = "right")
@ -148,25 +148,25 @@ Bar_init(m)
x1 := Monitor_#%m%_width - wndWidth + Config_horizontalBarPos
If Not (Config_verticalBarPos = "tray" And m = Manager_taskBarMonitor)
x1 += Monitor_#%m%_x
Bar_#%m%_titleWidth := titleWidth
Monitor_#%m%_barX := x1
y1 := Monitor_#%m%_barY
If Monitor_#%m%_showBar
Gui, Show, NoActivate x%x1% y%y1% w%wndWidth% h%Bar_height%, %wndTitle%
Else
Gui, Show, NoActivate Hide x%x1% y%y1% w%wndWidth% h%Bar_height%, %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")
DllCall("SetParent", "UInt", wndId, "UInt", trayWndId)
}
Else
}
Else
{
appBarMsg := DllCall("RegisterWindowMessage", Str, "AppBarMsg")
;; appBarData: http://msdn2.microsoft.com/en-us/library/ms538008.aspx
VarSetCapacity(Bar_appBarData, 36, 0)
offset := NumPut( 36, Bar_appBarData)
@ -178,7 +178,7 @@ Bar_init(m)
offset := NumPut( wndWidth, offset+0)
offset := NumPut(Bar_height, offset+0)
offset := NumPut( 1, offset+0)
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_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
Bar_cmdGuiIsVisible := False
wndTitle := "bug.n_BAR_0"
Gui, 99: Default
@ -214,7 +214,7 @@ Bar_cmdGuiEscape:
Return
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
Bar_cmdGuiIsVisible := False
@ -225,11 +225,11 @@ Bar_cmdGuiEnter:
}
Return
Bar_getBatteryStatus(ByRef batteryLifePercent, ByRef acLineStatus)
Bar_getBatteryStatus(ByRef batteryLifePercent, ByRef acLineStatus)
{
VarSetCapacity(powerStatus, (1 + 1 + 1 + 1 + 4 + 4))
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...
Return
@ -249,31 +249,31 @@ Bar_getBatteryStatus(ByRef batteryLifePercent, ByRef acLineStatus)
}
;; 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 Config_fontName, Config_fontSize, Config_singleRowBar, Config_spaciousBar, Config_verticalBarPos
wndTitle := "bug.n_BAR_0"
Gui, 99: Default
Gui, Font, s%Config_fontSize%, %Config_fontName%
Gui, Add, Text, x0 y0 vBar_#0_#1, |
GuiControlGet, Bar_#0_#1, Pos
Bar_textHeight := Bar_#0_#1H
If Config_spaciousBar
If Config_spaciousBar
{
Gui, Add, ComboBox, r9 x0 y0 vBar_#0_#2, |
GuiControlGet, Bar_#0_#2, Pos
Bar_ctrlHeight := Bar_#0_#2H
}
}
Else
Bar_ctrlHeight := Bar_textHeight
Gui, Destroy
Bar_height := Bar_ctrlHeight
If Not Config_singleRowBar
Bar_height *= 2
If (Config_verticalBarPos = "tray")
If (Config_verticalBarPos = "tray")
{
WinGetPos, , , , buttonH, Start ahk_class Button
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
If reverse
If reverse
{ ;; 'reverse' calculates the number of characters to a given width.
w := x
i := w / (Config_fontSize - 1)
@ -302,8 +302,8 @@ Bar_getTextWidth(x, reverse=False)
Else If (Config_fontSize > 17)
i := w / (Config_fontSize - 4)
textWidth := i
}
Else
}
Else
{ ;; 'else' calculates the width to a given string.
textWidth := StrLen(x) * (Config_fontSize - 1)
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)
textWidth := StrLen(x) * (Config_fontSize - 4)
}
Return, textWidth
}
Bar_GuiClick:
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)
Manager_activateMonitor(SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6) - Manager_aMonitor)
@ -332,15 +332,15 @@ Return
Bar_GuiContextMenu:
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)
Manager_activateMonitor(SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6) - Manager_aMonitor)
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)
Manager_setWindowMonitor(SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6) - Manager_aMonitor)
@ -353,13 +353,13 @@ Bar_loop:
Bar_updateStatus()
Return
Bar_move(m)
Bar_move(m)
{
Local wndTitle, x, y
x := Monitor_#%m%_barX
y := Monitor_#%m%_barY
wndTitle := "bug.n_BAR_" m
WinMove, %wndTitle%, , %x%, %y%
}
@ -371,18 +371,18 @@ Bar_toggleCommandGui:
Bar_toggleCommandGui()
Return
Bar_toggleCommandGui()
Bar_toggleCommandGui()
{
Local wndId, x, y
Gui, 99: Default
If Bar_cmdGuiIsVisible
If Bar_cmdGuiIsVisible
{
Bar_cmdGuiIsVisible := False
Gui, Cancel
Manager_winActivate(Bar_aWndId)
}
Else
}
Else
{
Bar_cmdGuiIsVisible := True
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
GuiN := (m - 1) + 1
If Monitor_#%m%_showBar
If Monitor_#%m%_showBar
{
If Not (GuiN = 99) Or Bar_cmdGuiIsVisible
Gui, %GuiN%: Show
}
}
Else
Gui, %GuiN%: Cancel
}
Bar_updateLayout(m)
Bar_updateLayout(m)
{
Local aView, GuiN, i
aView := Monitor_#%m%_aView_#1
i := Config_viewCount + 1
GuiN := (m - 1) + 1
GuiControl, %GuiN%: , Bar_#%m%_#%i%, % View_#%m%_#%aView%_layoutSymbol
}
Bar_updateStatus()
Bar_updateStatus()
{
Local anyContent, anyText, b1, b2, b3, GuiN, i, m
Loop, % Manager_monitorCount
Loop, % Manager_monitorCount
{
m := A_Index
GuiN := (m - 1) + 1
Debug_logMessage("DEBUG[6] Bar_updateStatus(): Gui, " . GuiN . ": Default", 6)
Gui, %GuiN%: Default
If Config_readinBat
If Config_readinBat
{
Bar_getBatteryStatus(b1, b2)
b3 := SubStr(" " b1, -2)
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%
GuiControl, +Background%Config_normBgColor4% +c%Config_normBgColor2%, Bar_#%m%_#%i%_tagged
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
GuiControl, +Background%Config_normBgColor2% +c%Config_normFgColor5%, Bar_#%m%_#%i%_tagged
GuiControl, +c%Config_normFgColor4%, Bar_#%m%_#%i%
}
Else
}
Else
{
GuiControl, +Background%Config_normBgColor3% +c%Config_normFgColor3%, Bar_#%m%_#%i%_tagged
GuiControl, +c%Config_normFgColor2%, Bar_#%m%_#%i%
@ -454,14 +454,14 @@ Bar_updateStatus()
GuiControl, , Bar_#%m%_#%i%, % " BAT: " b3 "% "
}
anyText := Config_readinAny()
If anyText
If anyText
{
i := Config_viewCount + 4
GuiControlGet, anyContent, , Bar_#%m%_#%i%
If Not (anyText = anyContent)
GuiControl, , Bar_#%m%_#%i%, % anyText
}
If Config_readinTime
If Config_readinTime
{
i := Config_viewCount + 5
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
If debugMsg
aWndTitle := debugMsg
Else
Else
{
WinGet, aWndId, ID, A
WinGetTitle, aWndTitle, ahk_id %aWndId%
@ -487,59 +487,59 @@ Bar_updateTitle(debugMsg = "")
aWndTitle := "[" Manager_aMonitor "] " 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
i := Bar_getTextWidth(Bar_#%Manager_aMonitor%_titleWidth, True) - 6
StringLeft, title, aWndTitle, i
title := " " . title . " ... "
}
i := Config_viewCount + 2
Loop, % Manager_monitorCount
Loop, % Manager_monitorCount
{
GuiN := (A_Index - 1) + 1
Debug_logMessage("DEBUG[6] Bar_updateTitle(): Gui, " . GuiN . ": Default", 6)
Gui, %GuiN%: Default
GuiControlGet, content, , Bar_#%A_Index%_#%i%
If (A_Index = Manager_aMonitor)
If (A_Index = Manager_aMonitor)
{
If Not (content = title)
GuiControl, , Bar_#%A_Index%_#%i%, % title
} Else If Not (content = "")
GuiControl, , Bar_#%A_Index%_#%i%,
GuiControl, , Bar_#%A_Index%_#%i%,
}
Bar_aWndId := aWndId
}
Bar_updateView(m, v)
Bar_updateView(m, v)
{
Local managedWndId0, wndId0, wndIds
GuiN := (m - 1) + 1
Gui, %GuiN%: Default
Debug_logMessage("DEBUG[6] Bar_updateView(): m: " . m . "; Gui, " . GuiN . ": Default", 6)
StringTrimRight, wndIds, Manager_managedWndIds, 1
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.
GuiControl, +Background%Config_selBgColor1% +c%Config_selFgColor2%, Bar_#%m%_#%v%_tagged
GuiControl, +c%Config_selFgColor1%, Bar_#%m%_#%v%
}
Else If wndId0
}
Else If wndId0
{ ;; Set foreground/background colors if the view contains windows.
GuiControl, +Background%Config_normBgColor5% +c%Config_normFgColor8%, Bar_#%m%_#%v%_tagged
GuiControl, +c%Config_normFgColor7%, Bar_#%m%_#%v%
}
Else
}
Else
{ ;; Set foreground/background colors if the view is empty.
GuiControl, +Background%Config_normBgColor1% +c%Config_normFgColor8%, Bar_#%m%_#%v%_tagged
GuiControl, +c%Config_normFgColor1%, Bar_#%m%_#%v%
}
Loop, %Config_viewCount%
Loop, %Config_viewCount%
{
StringTrimRight, wndIds, View_#%m%_#%A_Index%_wndIds, 1
StringSplit, wndId, wndIds, `;

View File

@ -1,27 +1,27 @@
/*
bug.n -- tiling window management
Copyright (c) 2010-2012 Joshua Fuhs, joten
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
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
;; Status bar
Config_showBar := True
Config_horizontalBarPos := "left"
@ -30,11 +30,11 @@ Config_init()
Config_singleRowBar := True
Config_spaciousBar := False
Config_fontName := "Lucida Console"
Config_fontSize :=
Config_normBgColor :=
Config_normFgColor :=
Config_selBgColor :=
Config_selFgColor :=
Config_fontSize :=
Config_normBgColor :=
Config_normFgColor :=
Config_selBgColor :=
Config_selFgColor :=
Config_barCommands := "Run, explore doc;Monitor_toggleBar();Main_reload();Reload;ExitApp"
Config_readinBat := False
Config_readinCpu := False
@ -44,7 +44,7 @@ Config_init()
Config_readinNetworkLoad := False
Config_readinTime := True
Config_readinInterval := 30000
;; Windows ui elements
Config_bbCompatibility := False
Config_borderWidth := 0
@ -52,7 +52,7 @@ Config_init()
Config_showTaskBar := False
Config_showBorder := True
Config_selBorderColor := ""
;; Window arrangement
Config_viewNames := "1;2;3;4;5;6;7;8;9"
Config_layout_#1 := "[]=;tile"
@ -72,7 +72,7 @@ Config_init()
Config_shellMsgDelay := 350
Config_syncMonitorViews := 0
Config_viewFollowsTagged := False
;; 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_#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_#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.
;; Configuration management
Config_autoSaveSession := False
; @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).
Config_filePath := A_ScriptDir "\Config.ini"
Config_maintenanceInterval := 5000
Config_restoreConfig(Config_filePath)
Config_getSystemSettings()
Config_initColors()
Loop, % Config_layoutCount
Loop, % Config_layoutCount
{
StringSplit, layout, Config_layout_#%A_Index%, `;
Config_layoutFunction_#%A_Index% := layout2
@ -115,76 +115,76 @@ Config_init()
}
}
Config_initColors()
Config_initColors()
{
Global
StringReplace, Config_normBgColor, Config_normBgColor, `;0`;, `;000000`;, All
Config_normBgColor := RegExReplace(Config_normBgColor, "^0;", "000000;")
Config_normBgColor := RegExReplace(Config_normBgColor, ";0$", ";000000")
StringSplit, Config_normBgColor, Config_normBgColor, `;
StringReplace, Config_normFgColor, Config_normFgColor, `;0`;, `;000000`;, All
Config_normFgColor := RegExReplace(Config_normFgColor, "^0;", "000000;")
Config_normFgColor := RegExReplace(Config_normFgColor, ";0$", ";000000")
StringSplit, Config_normFgColor, Config_normFgColor, `;
StringReplace, Config_selBgColor, Config_selBgColor, `;0`;, `;000000`;, All
Config_selBgColor := RegExReplace(Config_selBgColor, "^0;", "000000;")
Config_selBgColor := RegExReplace(Config_selBgColor, ";0$", ";000000")
StringSplit, Config_selBgColor, Config_selBgColor, `;
StringReplace, Config_selFgColor, Config_selFgColor, `;0`;, `;000000`;, All
Config_selFgColor := RegExReplace(Config_selFgColor, "^0;", "000000;")
Config_selFgColor := RegExReplace(Config_selFgColor, ";0$", ";000000")
StringSplit, Config_selFgColor, Config_selFgColor, `;
}
Config_convertSystemColor(systemColor)
Config_convertSystemColor(systemColor)
{ ;; systemColor format: 0xBBGGRR
rr := SubStr(systemColor, 7, 2)
gg := SubStr(systemColor, 5, 2)
bb := SubStr(systemColor, 3, 2)
Return, rr gg bb
}
Config_getSystemSettings()
Config_getSystemSettings()
{
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)
NumPut(ncmSize, ncm, 0, "UInt")
DllCall("SystemParametersInfo", "UInt", 0x0029, "UInt", ncmSize, "UInt", &ncm, "UInt", 0)
VarSetCapacity(lf, 28 + 32 * (A_IsUnicode ? 2 : 1), 0)
DllCall("RtlMoveMemory", "Str", lf, "UInt", &ncm + 24, "UInt", 28 + 32 * (A_IsUnicode ? 2 : 1))
VarSetCapacity(Config_fontName, 32 * (A_IsUnicode ? 2 : 1), 0)
DllCall("RtlMoveMemory", "Str", Config_fontName, "UInt", &lf + 28, "UInt", 32 * (A_IsUnicode ? 2 : 1))
;; 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)
NumPut(ncmSize, ncm, 0, "UInt")
DllCall("SystemParametersInfo", "UInt", 0x0029, "UInt", ncmSize, "UInt", &ncm, "UInt", 0)
lfSize := VarSetCapacity(lf, 28 + 32 * (A_IsUnicode ? 2 : 1), 0)
NumPut(lfSize, lf, 0, "UInt")
DllCall("RtlMoveMemory", "Str", lf, "UInt", &ncm + 24, "UInt", 28 + 32 * (A_IsUnicode ? 2 : 1))
lfHeightSize := VarSetCapacity(lfHeight, 4, 0)
NumPut(lfHeightSize, lfHeight, 0, "Int")
lfHeight := NumGet(lf, 0, "Int")
lfPixelsY := DllCall("GetDeviceCaps", "UInt", DllCall("GetDC", "UInt", 0), "UInt", 90) ;; LOGPIXELSY
Config_fontSize := -DllCall("MulDiv", "Int", lfHeight, "Int", 72, "Int", lfPixelsY)
;; maestrith: Script Writer (http://www.autohotkey.net/~maestrith/Script Writer/)
}
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", 3)) ;; COLOR_INACTIVECAPTION
@ -192,7 +192,7 @@ Config_getSystemSettings()
Config_normBgColor .= ";Red"
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 .= ";Default"
@ -203,11 +203,11 @@ Config_getSystemSettings()
Config_normFgColor .= ";Default"
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
}
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", 2)) ;; COLOR_ACTIVECAPTION
@ -219,25 +219,25 @@ Config_hotkeyLabel:
Config_redirectHotkey(A_ThisHotkey)
Return
Config_readinAny()
Config_readinAny()
{ ;; Add information to the variable 'text' in this function to display it in the status bar.
Global Config_readinDate
text := ""
text .= ResourceMonitor_getText()
If Config_readinDate
text .= " " A_DDD ", " A_DD ". " A_MMM ". " A_YYYY " "
Return, text
}
Config_redirectHotkey(key)
Config_redirectHotkey(key)
{
Global
Loop, % Config_hotkeyCount
{
If (key = Config_hotkey_#%A_index%_key)
If (key = Config_hotkey_#%A_index%_key)
{
Main_evalCommand(Config_hotkey_#%A_index%_command)
Break
@ -245,13 +245,13 @@ Config_redirectHotkey(key)
}
}
Config_restoreLayout(filename, m)
Config_restoreLayout(filename, m)
{
Local i, var, val
If Not FileExist(filename)
Return
Loop, READ, %filename%
If (SubStr(A_LoopReadLine, 1, 10 + StrLen(m)) = "Monitor_#" m "_" Or SubStr(A_LoopReadLine, 1, 8 + StrLen(m)) = "View_#" m "_#") {
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
If Not FileExist(filename)
Return
Loop, READ, %filename%
If (SubStr(A_LoopReadLine, 1, 7) = "Config_")
If (SubStr(A_LoopReadLine, 1, 7) = "Config_")
{
;Log_msg("Processing line: " . A_LoopReadLine)
i := InStr(A_LoopReadLine, "=")
var := SubStr(A_LoopReadLine, 1, i - 1)
val := SubStr(A_LoopReadLine, i + 1)
type := SubStr(var, 1, 13)
If (type = "Config_hotkey")
If (type = "Config_hotkey")
{
Debug_logMessage("Processing configured hotkey: " . A_LoopReadLine, 0)
i := InStr(val, "::")
@ -284,7 +284,7 @@ Config_restoreConfig(filename)
cmd := SubStr(val, i + 2)
If Not cmd
Hotkey, %key%, Off
Else
Else
{
Debug_logMessage(" Hotkey: " . key . " -> " . cmd, 0)
Config_hotkeyCount += 1
@ -293,12 +293,12 @@ Config_restoreConfig(filename)
Hotkey, %key%, Config_hotkeyLabel
}
}
Else If (type = "Config_rule")
Else If (type = "Config_rule")
{
i := 0
If InStr(var, "Config_rule_#")
i := SubStr(var, 14)
If (i = 0 Or i > Config_ruleCount)
If (i = 0 Or i > Config_ruleCount)
{
Config_ruleCount += 1
i := Config_ruleCount
@ -309,20 +309,20 @@ Config_restoreConfig(filename)
}
}
Config_UI_saveSession()
Config_UI_saveSession()
{
Config_saveSession(Config_filePath, Config_filePath)
}
Config_saveSession(original, target)
Config_saveSession(original, target)
{
Local m, text, tmpfilename
tmpfilename := target . ".tmp"
FileDelete, %tmpfilename%
text := "; bug.n - tiling window management`n; @version " VERSION "`n`n"
If FileExist(original)
If FileExist(original)
{
Loop, READ, %original%
{
@ -331,8 +331,8 @@ Config_saveSession(original, target)
}
text .= "`n"
}
Loop, % Manager_monitorCount
Loop, % Manager_monitorCount
{
m := A_Index
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"
If Not (Monitor_#%m%_showBar = Config_showBar)
text .= "Monitor_#" m "_showBar=" Monitor_#%m%_showBar "`n"
Loop, % Config_viewCount
Loop, % Config_viewCount
{
If Not (View_#%m%_#%A_Index%_layout_#1 = 1)
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"
}
}
;; The FileMove below is an all-or-nothing replacement of the file.
;; We don't want to leave this half-finished.
FileAppend, %text%, %tmpfilename%
If ErrorLevel
If ErrorLevel
{
If FileExist(tmpfilename)
FileDelete, %tmpfilename%

View File

@ -1,27 +1,27 @@
/*
bug.n -- tiling window management
Copyright (c) 2010-2012 Joshua Fuhs, joten
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
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
Debug_logFilename := filename
Debug_logLevel := level
If truncateFile
@ -29,7 +29,7 @@ Debug_initLog(filename, level = 0, truncateFile = True)
FileDelete, %Debug_logFilename%
}
Debug_logHelp()
Debug_logHelp()
{
Debug_logMessage("Help Display", 0)
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_logManagedWindowList()
Debug_logManagedWindowList()
{
Local wndIds
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)
StringTrimRight, wndIds, Manager_managedWndIds, 1
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
If (Debug_logLevel >= level)
{
If includeTimestamp
If includeTimestamp
{
FormatTime, time, , yyyy-MM-dd HH:mm:ss
text := time " " text
@ -82,14 +82,14 @@ Debug_logMessage(text, level = 1, includeTimestamp = True)
}
}
Debug_logViewWindowList()
Debug_logViewWindowList()
{
Local v, wndIds
v := Monitor_#%Manager_aMonitor%_aView_#1
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)
StringTrimRight, wndIds, View_#%Manager_aMonitor%_#%v%_wndIds, 1
Loop, PARSE, wndIds, `;
{
@ -97,12 +97,12 @@ Debug_logViewWindowList()
}
}
Debug_logWindowInfo(wndId)
Debug_logWindowInfo(wndId)
{
Local aWndId, detect_state, text, v
Local isBugnActive, isDecorated, isFloating, isGhost, isHidden, isResponsive, isWinFocus
Local wndClass, wndH, wndProc, wndStyle, wndTitle, wndW, wndX, wndY
detect_state := A_DetectHiddenWindows
DetectHiddenWindows, On
WinGet, aWndId, ID, A
@ -120,7 +120,7 @@ Debug_logWindowInfo(wndId)
WinGet, wndProc, ProcessName, ahk_id %wndId%
If InStr(Bar_hiddenWndIds, wndId)
isHidden := "*"
Else
Else
isHidden := " "
If Manager_#%wndId%_isFloating
isFloating := "*"
@ -137,13 +137,13 @@ Debug_logWindowInfo(wndId)
Else
isGhost := " "
DetectHiddenWindows, %detect_state%
;; Intentionally don't detect hidden windows here to see what Manager_hungTest does
If Manager_isHung(wndId)
isResponsive := " "
Else
isResponsive := "*"
text := wndId "`t"
text .= isHidden " " isWinFocus " " isBugnActive " " isFloating " " isDecorated " " isResponsive " " isGhost " "
text .= Manager_#%wndId%_monitor "`t" Manager_#%wndId%_tags "`t"
@ -151,10 +151,10 @@ Debug_logWindowInfo(wndId)
Debug_logMessage(text , 0, False)
}
Debug_setLogLevel(d)
Debug_setLogLevel(d)
{
Global Debug_logLevel
i := Debug_logLevel + d
If (i >= 0)
{

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -1,31 +1,31 @@
/*
bug.n -- tiling window management
Copyright (c) 2010-2012 Joshua Fuhs, joten
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
@version 8.3.0
@version 8.4.0
*/
Monitor_init(m)
Monitor_init(m)
{
Global
Monitor_#%m%_aView_#1 := 1
Monitor_#%m%_aView_#2 := 1
Monitor_#%m%_showBar := Config_showBar
Loop, % Config_viewCount
Loop, % Config_viewCount
{
View_init(m, A_Index)
}
@ -34,50 +34,50 @@ Monitor_init(m)
Bar_init(m)
}
Monitor_activateView(v)
Monitor_activateView(v)
{
Local aView, aWndId, m, n, wndId, wndIds
If (v = -1)
v := Monitor_#%Manager_aMonitor%_aView_#2
Else If (v = ">")
v := Manager_loop(Monitor_#%Manager_aMonitor%_aView_#1, +1, 1, Config_viewCount)
Else If (v = "<")
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)
If (v <= 0) Or (v > Config_viewCount) Or Manager_hideShow
Return
;; 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)
Return
}
aView := Monitor_#%Manager_aMonitor%_aView_#1
aWndId := View_getActiveWindow(Manager_aMonitor, aView)
If aWndId
View_#%Manager_aMonitor%_#%aView%_aWndId := aWndId
n := Config_syncMonitorViews
If (n = 1)
n := Manager_monitorCount
Else If (n < 1)
n := 1
Loop, % n
Loop, % n
{
If (n = 1)
m := Manager_aMonitor
Else
m := A_Index
Monitor_#%m%_aView_#2 := aView
Monitor_#%m%_aView_#1 := v
Monitor_#%m%_aView_#1 := v
Manager_hideShow := True
SetWinDelay, 0
StringTrimRight, wndIds, View_#%m%_#%aView%_wndIds, 1
Loop, PARSE, wndIds, `;
Loop, PARSE, wndIds, `;
{
If Not (Manager_#%A_LoopField%_tags & (1 << v - 1))
Manager_winHide(A_LoopField)
@ -88,95 +88,95 @@ Monitor_activateView(v)
DetectHiddenWindows, Off
StringTrimRight, wndIds, View_#%m%_#%v%_wndIds, 1
SetWinDelay, 0
Loop, PARSE, wndIds, `;
Loop, PARSE, wndIds, `;
{
Manager_winShow(A_LoopField)
}
SetWinDelay, 10
Manager_hideShow := False
Bar_updateView(m, aView)
Bar_updateView(m, v)
}
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)
View_#%Manager_aMonitor%_#%v%_aWndId := wndId
}
}
Else
wndId := 0
}
Manager_winActivate(wndId)
}
Monitor_get(x, y)
Monitor_get(x, y)
{
Local m
m := 0
Loop, % Manager_monitorCount
Loop, % Manager_monitorCount
{ ;; 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
Break
}
}
Return, m
}
Monitor_getWorkArea(m)
Monitor_getWorkArea(m)
{
Local bTop, x, y
Local monitor, monitorBottom, monitorLeft, monitorRight, monitorTop
Local wndClasses, wndHeight, wndId, wndWidth, wndX, wndY
SysGet, monitor, Monitor, %m%
wndClasses := "Shell_TrayWnd"
If Config_bbCompatibility
wndClasses .= ";bbLeanBar;bbSlit;BBToolbar;SystemBarEx"
Loop, PARSE, wndClasses, `;
{
wndId := WinExist("ahk_class " A_LoopField)
If wndId
If wndId
{
WinGetPos, wndX, wndY, wndWidth, wndHeight, ahk_id %wndId%
x := wndX + wndWidth / 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")
Manager_taskBarMonitor := m
If (wndHeight < wndWidth)
If (wndHeight < wndWidth)
{ ;; Horizontal
If (wndY <= monitorTop)
If (wndY <= monitorTop)
{ ;; Top
wndHeight += wndY - monitorTop
monitorTop += wndHeight
If (A_LoopField = "Shell_TrayWnd")
Manager_taskBarPos := "top"
}
Else
}
Else
{ ;; Bottom
wndHeight := monitorBottom - wndY
monitorBottom -= wndHeight
}
}
Else
}
Else
{ ;; Vertical
If (wndX <= monitorLeft)
If (wndX <= monitorLeft)
{ ;; Left
wndWidth += wndX
monitorLeft += wndWidth
}
Else
}
Else
{ ;; Right
wndWidth := monitorRight - wndX
monitorRight -= wndWidth
@ -186,20 +186,20 @@ Monitor_getWorkArea(m)
}
}
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
monitorTop += Bar_height
}
Else If (Config_verticalBarPos = "bottom")
}
Else If (Config_verticalBarPos = "bottom")
{
bTop := monitorBottom - Bar_height
monitorBottom -= Bar_height
}
}
Monitor_#%m%_height := monitorBottom - monitorTop
Monitor_#%m%_width := monitorRight - monitorLeft
Monitor_#%m%_x := monitorLeft
@ -207,30 +207,30 @@ Monitor_getWorkArea(m)
Monitor_#%m%_barY := bTop
}
Monitor_moveWindow(m, wndId)
Monitor_moveWindow(m, wndId)
{
Global
Manager_#%wndId%_monitor := m
}
Monitor_setWindowTag(t)
Monitor_setWindowTag(t)
{
Local aView, aWndId, wndId
If (t = ">")
t := Manager_loop(Monitor_#%Manager_aMonitor%_aView_#1, +1, 1, Config_viewCount)
Else If (t = "<")
t := Manager_loop(Monitor_#%Manager_aMonitor%_aView_#1, -1, 1, Config_viewCount)
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%_aWndId := aWndId
@ -238,26 +238,26 @@ Monitor_setWindowTag(t)
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
Bar_updateView(Manager_aMonitor, A_Index)
}
}
If Not (Manager_#%aWndId%_tags & (1 << t - 1))
View_#%Manager_aMonitor%_#%t%_wndIds := aWndId ";" View_#%Manager_aMonitor%_#%t%_wndIds
View_#%Manager_aMonitor%_#%t%_aWndId := aWndId
Manager_#%aWndId%_tags := 1 << t - 1
aView := Monitor_#%Manager_aMonitor%_aView_#1
If Not (t = aView)
If Not (t = aView)
{
Manager_hideShow := True
wndId := SubStr(View_#%Manager_aMonitor%_#%aView%_wndIds, 1, InStr(View_#%Manager_aMonitor%_#%aView%_wndIds, ";")-1)
@ -265,7 +265,7 @@ Monitor_setWindowTag(t)
Manager_hideShow := False
If Config_viewFollowsTagged
Monitor_activateView(t)
Else
Else
{
Manager_hideShow := True
Manager_winHide(aWndId)
@ -278,10 +278,10 @@ Monitor_setWindowTag(t)
}
}
Monitor_toggleBar()
Monitor_toggleBar()
{
Global
Monitor_#%Manager_aMonitor%_showBar := Not Monitor_#%Manager_aMonitor%_showBar
Bar_toggleVisibility(Manager_aMonitor)
Monitor_getWorkArea(Manager_aMonitor)
@ -289,21 +289,21 @@ Monitor_toggleBar()
Manager_winActivate(Bar_aWndId)
}
Monitor_toggleTaskBar()
Monitor_toggleTaskBar()
{
Local m
m := Manager_aMonitor
If (m = Manager_taskBarMonitor)
If (m = Manager_taskBarMonitor)
{
Manager_showTaskBar := Not Manager_showTaskBar
Manager_hideShow := True
If Not Manager_showTaskBar
If Not Manager_showTaskBar
{
WinHide, Start ahk_class Button
WinHide, ahk_class Shell_TrayWnd
}
Else
}
Else
{
WinShow, Start ahk_class Button
WinShow, ahk_class Shell_TrayWnd
@ -315,21 +315,21 @@ Monitor_toggleTaskBar()
}
}
Monitor_toggleWindowTag(t)
Monitor_toggleWindowTag(t)
{
Local aWndId, wndId
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
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)
If (t = Monitor_#%Manager_aMonitor%_aView_#1)
If (t = Monitor_#%Manager_aMonitor%_aView_#1)
{
Manager_hideShow := True
Manager_winHide(aWndId)
@ -339,8 +339,8 @@ Monitor_toggleWindowTag(t)
View_arrange(Manager_aMonitor, t)
}
}
}
Else
}
Else
{
View_#%Manager_aMonitor%_#%t%_wndIds := aWndId ";" View_#%Manager_aMonitor%_#%t%_wndIds
View_#%Manager_aMonitor%_#%t%_aWndId := aWndId

View File

@ -1,55 +1,55 @@
/*
bug.n -- tiling window management
Copyright (c) 2010-2012 Joshua Fuhs, joten
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
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_getNetworkInterface()
}
ResourceMonitor_cleanup()
ResourceMonitor_cleanup()
{
DllCall("CloseHandle", "UInt", ResourceMonitor_hDrive) ;; used in ResourceMonitor_getDiskLoad
}
ResourceMonitor_getText()
ResourceMonitor_getText()
{
Global Config_readinCpu, Config_readinDate, Config_readinDiskLoad, Config_readinMemoryUsage, Config_readinNetworkLoad
text := ""
If Config_readinCpu
text .= " CPU: " ResourceMonitor_getSystemTimes() "% "
If Config_readinMemoryUsage
If Config_readinMemoryUsage
{
If Config_readinCpu
text .= "|"
text .= " RAM: " ResourceMonitor_getMemoryUsage() "% "
}
If Config_readinDiskLoad
If Config_readinDiskLoad
{
If (Config_readinCpu Or Config_readinMemoryUsage)
text .= "|"
ResourceMonitor_getDiskLoad(rLoad, wLoad)
text .= " Dr: " rLoad "% | Dw: " wLoad "% "
}
If Config_readinNetworkLoad
If Config_readinNetworkLoad
{
If (Config_readinCpu Or Config_readinMemoryUsage Or Config_readinDiskLoad)
text .= "|"
@ -58,19 +58,19 @@ ResourceMonitor_getText()
}
If Config_readinDate And (Config_readinCpu Or Config_readinMemoryUsage Or Config_readinDiskLoad Or Config_readinNetworkLoad)
text .= "|"
Return, text
}
ResourceMonitor_getDiskLoad(ByRef readLoad, ByRef writeLoad)
ResourceMonitor_getDiskLoad(ByRef readLoad, ByRef writeLoad)
{
Global ResourceMonitor_hDrive
Static oldReadCount, oldWriteCount
dpSize := 5 * 8 + 4 + 4 + 4 + 4 + 8 + 4 + 8 * (A_IsUnicode ? 2 : 1) + 12 ;; 88?
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
newReadCount := NumGet(dp, 40)
newWriteCount := NumGet(dp, 44)
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)
;; 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)
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)
ResourceMonitor_getNetworkInterface()
ResourceMonitor_getNetworkInterface()
{
Global ResourceMonitor_networkInterface, ResourceMonitor_networkInterfaceTable
DllCall("iphlpapi\GetNumberOfInterfaces", "UIntP", n)
nSize := 4 + 860 * n + 8
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
j := A_Index
Loop, % NumGet(ResourceMonitor_networkInterfaceTable)
Loop, % NumGet(ResourceMonitor_networkInterfaceTable)
{
If NumGet(ResourceMonitor_networkInterfaceTable, 4 + 860 * (A_Index - 1) + 544) < 4
|| NumGet(ResourceMonitor_networkInterfaceTable, 4 + 860 * (A_Index - 1) + 516) = 24
@ -114,10 +114,10 @@ ResourceMonitor_getNetworkInterface()
If (A_Index < 2)
RunWait, %Comspec% /c ping -n 1 127.0.0.1, , hide
}
Loop, % i
{
If (dn_#%i%_#2 > dn_#%i%_1)
If (dn_#%i%_#2 > dn_#%i%_1)
{
ResourceMonitor_networkInterface := i
Break
@ -127,27 +127,27 @@ ResourceMonitor_getNetworkInterface()
}
;; 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
Static dn_#0, t_#0, up_#0
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
up_#1 := NumGet(ResourceMonitor_networkInterfaceTable, 4 + 860 * (ResourceMonitor_networkInterface - 1) + 576) ;; Total Outgoing Bytes
tDiff := (A_TickCount - t_#0) / 1000
t_#0 := A_TickCount
dnLoad := SubStr(" " Round((dn_#1 - dn_#0) / 1024 / tDiff), -3)
upLoad := SubStr(" " Round((up_#1 - up_#0) / 1024 / tDiff), -3)
dn_#0 := dn_#1
up_#0 := up_#1
}
;; 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)
ResourceMonitor_getSystemTimes()
ResourceMonitor_getSystemTimes()
{ ;; Total CPU Load
Static oldIdleTime, oldKrnlTime, oldUserTime
Static newIdleTime, newKrnlTime, newUserTime

View File

@ -1,27 +1,27 @@
/*
bug.n -- tiling window management
Copyright (c) 2010-2012 Joshua Fuhs, joten
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
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
View_#%m%_#%v%_aWndId := 0
View_#%m%_#%v%_layout_#1 := 1
View_#%m%_#%v%_layout_#2 := 1
@ -38,14 +38,14 @@ View_init(m, v)
View_#%m%_#%v%_wndIds := ""
}
View_activateWindow(d)
View_activateWindow(d)
{
Local aWndId, direction, failure, i, j, v, wndId, wndId0, wndIds
Debug_logMessage("DEBUG[1] View_activateWindow(" . d . ")", 1)
If (d = 0)
Return
WinGet, aWndId, ID, A
Debug_logMessage("DEBUG[2] Active Windows ID: " . aWndId, 2, False)
v := Monitor_#%Manager_aMonitor%_aView_#1
@ -53,55 +53,55 @@ View_activateWindow(d)
StringTrimRight, wndIds, View_#%Manager_aMonitor%_#%v%_wndIds, 1
StringSplit, wndId, wndIds, `;
Debug_logMessage("DEBUG[2] wndId count: " . wndId0, 2, False)
If (wndId0 > 1)
If (wndId0 > 1)
{
If Manager_#%aWndId%_isFloating
Manager_winSet("Bottom", "", aWndId)
Loop, % wndId0
Loop, % wndId0
{
If (wndId%A_Index% = aWndId)
If (wndId%A_Index% = aWndId)
{
i := A_Index
Break
}
}
Debug_logMessage("DEBUG[2] Current wndId index: " . i, 2, False)
If (d > 0)
If (d > 0)
direction = 1
Else
direction = -1
j := Manager_loop(i, d, 1, wndId0)
Loop, % wndId0
Loop, % wndId0
{
Debug_logMessage("DEBUG[2] Next wndId index: " . j, 2, False)
wndId := wndId%j%
Manager_winSet("AlwaysOnTop", "On", wndId)
Manager_winSet("AlwaysOnTop", "Off", wndId)
;; If there are hung windows on the screen, we still want to be able to cycle through them.
failure := Manager_winActivate(wndId)
If Not failure
If Not failure
Break
j := Manager_loop(j, direction, 1, wndId0)
}
}
}
View_addWindow(m, v, wndId)
View_addWindow(m, v, wndId)
{
Local i, l, mSplit, n, replace, search
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)
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
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 ";"
Else
Else
{
If (Config_newWndPosition = "masterBottom")
i := mSplit - 1
@ -118,21 +118,21 @@ View_addWindow(m, v, wndId)
View_#%m%_#%v%_wndIds := wndId ";" View_#%m%_#%v%_wndIds
}
View_arrange(m, v)
View_arrange(m, v)
{
Local fn, h, l, w, x, y
Debug_logMessage("DEBUG[1] View_arrange(" . m . ", " . v . ")", 1)
l := View_#%m%_#%v%_layout_#1
fn := Config_layoutFunction_#%l%
If fn
If fn
{
x := Monitor_#%m%_x + View_#%m%_#%v%_layoutGapWidth + View_#%m%_#%v%_margin4
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
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.
SetWinDelay, 0
View_getTiledWndIds(m, v)
@ -141,30 +141,30 @@ View_arrange(m, v)
}
Else ;; floating layout (no 'View_arrange_', following is 'View_getLayoutSymbol_')'
View_#%m%_#%v%_layoutSymbol := Config_layoutSymbol_#%l%
Bar_updateLayout(m)
}
View_arrange_monocle(m, v, x, y, w, h)
View_arrange_monocle(m, v, x, y, w, h)
{
Global
;; 'View_getLayoutSymbol_monocle'
View_#%m%_#%v%_layoutSymbol := "[" View_tiledWndId0 "]"
;; 'View_arrange_monocle'
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
View_#%m%_#%v%_layoutSymbol := View_getLayoutSymbol_tile(m, v, View_tiledWndId0)
Debug_logMessage("DEBUG[1] View_arrange_tile: (" . View_tiledWndId0 . ") ", 1)
If (View_tiledWndId0 = 0)
Return
axis1 := Abs(View_#%m%_#%v%_layoutAxis_#1)
axis2 := View_#%m%_#%v%_layoutAxis_#2
axis3 := View_#%m%_#%v%_layoutAxis_#3
@ -176,20 +176,20 @@ View_arrange_tile(m, v, x, y, w, h)
mSplit := mXSet * mYSet
If (mSplit > View_tiledWndId0)
mSplit := View_tiledWndId0
;; Areas (master and stack)
x1 := x
y1 := y
w1 := w
h1 := h
If (View_tiledWndId0 > mSplit)
If (View_tiledWndId0 > mSplit)
{ ;; There is a stack area.
If flipped
View_splitArea(axis1 - 1, 1 - mFact, x1, y1, w1, h1, gapW, x2, y2, w2, h2, x1, y1, w1, h1)
Else
View_splitArea(axis1 - 1, mFact, x1, y1, w1, h1, gapW, x1, y1, w1, h1, x2, y2, w2, h2)
}
;; Master
If (axis2 = 3)
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)
subAreaCount := mYActual
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)
subAreaWndCount := mXSet
@ -209,16 +209,16 @@ View_arrange_tile(m, v, x, y, w, h)
subAreaCount -= 1
}
}
;; Stack
If (View_tiledWndId0 <= mSplit)
If (View_tiledWndId0 <= mSplit)
Return
stackLen := View_tiledWndId0 - mSplit
;; 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.
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)
Else
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)
{
Local aWndClass, aWndId, aWndTitle
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%
WinGetTitle, aWndTitle, ahk_id %aWndId%
@ -239,10 +239,10 @@ View_getActiveWindow(m, v)
Return, 0
}
View_getLayoutSymbol_tile(m, v, n)
View_getLayoutSymbol_tile(m, v, n)
{
Local axis1, axis2, axis3, masterDim, masterDiv, mx, my, stackSym
;; Main axis
;; 1 - vertical divider, master left
;; 2 - horizontal divider, master top
@ -261,39 +261,39 @@ View_getLayoutSymbol_tile(m, v, n)
axis3 := View_#%m%_#%v%_layoutAxis_#3
mx := View_#%m%_#%v%_layoutMX
my := View_#%m%_#%v%_layoutMY
If (Abs(axis1) = 1)
If (Abs(axis1) = 1)
masterDiv := "|"
Else
Else
masterDiv := "-"
If (axis2 = 1)
If (axis2 = 1)
masterDim := mx . "x" . my
Else If (axis2 = 2)
Else If (axis2 = 2)
masterDim := mx . "x" . my
Else
Else
masterDim := "[" . (mx * my) . "]"
If (axis3 = 1)
stackSym := "|"
Else If (axis3 = 2)
stackSym := "="
Else
stackSym := n - (mx * my)
If (axis1 > 0)
Return, masterDim . masterDiv . stackSym
Else
Return, stackSym . masterDiv . masterDim
}
View_getTiledWndIds(m, v)
View_getTiledWndIds(m, v)
{
Local n, tiledWndIds, wndIds
StringTrimRight, wndIds, View_#%m%_#%v%_wndIds, 1
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
tiledWndIds .= A_LoopField ";"
@ -301,44 +301,44 @@ View_getTiledWndIds(m, v)
}
StringTrimRight, tiledWndIds, tiledWndIds, 1
StringSplit, View_tiledWndId, tiledWndIds, `;
Return, n
}
View_ghostWindow(m, v, bodyWndId, ghostWndId)
View_ghostWindow(m, v, bodyWndId, ghostWndId)
{
Local search, replace
search := bodyWndId ";"
replace := search ghostWndId ";"
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
v := Monitor_#%Manager_aMonitor%_aView_#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)
View_#%Manager_aMonitor%_#%v%_layoutAxis_#%i% *= -1
Else
Else
{
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)
}
}
Else
}
Else
{
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.
;; 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 (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
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
v := Monitor_#%Manager_aMonitor%_aView_#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)
d := Floor(d / 2) * 2
Else
d := Ceil(d / 2) * 2
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_arrange(Manager_aMonitor, v)
@ -371,18 +371,18 @@ View_setGapWidth(d)
}
}
View_setLayout(l)
View_setLayout(l)
{
Local v
v := Monitor_#%Manager_aMonitor%_aView_#1
If (l = -1)
l := View_#%Manager_aMonitor%_#%v%_layout_#2
If (l = ">")
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_#1 := l
@ -391,20 +391,20 @@ View_setLayout(l)
}
}
View_setMFactor(d)
View_setMFactor(d)
{
Local l, mFact, v
v := Monitor_#%Manager_aMonitor%_aView_#1
l := View_#%Manager_aMonitor%_#%v%_layout_#1
If (Config_layoutFunction_#%l% = "tile")
If (Config_layoutFunction_#%l% = "tile")
{
mFact := 0
If (d >= 1.05)
mFact := d
Else
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_arrange(Manager_aMonitor, v)
@ -412,55 +412,55 @@ View_setMFactor(d)
}
}
View_setMX(d)
View_setMX(d)
{
Local l, n, v
v := Monitor_#%Manager_aMonitor%_aView_#1
l := View_#%Manager_aMonitor%_#%v%_layout_#1
If Not (Config_layoutFunction_#%l% = "tile")
Return
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_arrange(Manager_aMonitor, v)
}
}
View_setMY(d)
View_setMY(d)
{
Local l, n, v
v := Monitor_#%Manager_aMonitor%_aView_#1
l := View_#%Manager_aMonitor%_#%v%_layout_#1
If Not (Config_layoutFunction_#%l% = "tile")
Return
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_arrange(Manager_aMonitor, v)
}
}
View_shuffleWindow(d)
View_shuffleWindow(d)
{
Local aWndHeight, aWndId, aWndWidth, aWndX, aWndY, i, j, l, search, v
WinGet, aWndId, ID, A
v := Monitor_#%Manager_aMonitor%_aView_#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)
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
Break
@ -470,14 +470,14 @@ View_shuffleWindow(d)
j := 2
Else
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
}
Else
}
Else
{
search := View_tiledWndId%j%
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%
}
View_arrange(Manager_aMonitor, v)
If Config_mouseFollowsFocus
If Config_mouseFollowsFocus
{
WinGetPos, aWndX, aWndY, aWndWidth, aWndHeight, ahk_id %aWndId%
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
y1 := y
If (splitRatio = 1)
If (splitRatio = 1)
{
w1 := w
w2 := 0
@ -509,7 +509,7 @@ View_splitArea(axis, splitRatio, x, y, w, h, gapW, ByRef x1, ByRef y1, ByRef w1,
x2 := x + w1
y2 := y + h1
}
Else If (axis = 0)
Else If (axis = 0)
{
w1 := w * splitRatio - gapW / 2
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)
{
Local dx, dy, i, wndH, wndW, wndX, wndY
;; d = +1: Left-to-right and top-to-bottom, depending on axis
i := startPos
;; d = -1: Right-to-left and bottom-to-top, depending on axis
If (d < 0)
If (d < 0)
i += len - 1
wndX := x
wndY := y
wndW := w
wndH := h
dx := 0
dy := 0
If (axis = 1)
If (axis = 1)
{
wndW := (w - (len - 1) * padding) / len
dx := wndW + padding
}
Else If (axis = 2)
Else If (axis = 2)
{
wndH := (h - (len - 1) * padding) / len
dy := wndH + padding
}
;; Else (axis = 3) and nothing to do
Loop, % len
Loop, % len
{
Manager_winMove(%arrayName%%i%, wndX, wndY, wndW, wndH)
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
WinGet, aWndId, ID, A
v := Monitor_#%Manager_aMonitor%_aView_#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
View_arrange(Manager_aMonitor, v)
@ -595,18 +595,18 @@ View_toggleFloating()
}
}
View_toggleMargins()
View_toggleMargins()
{
Local v
Debug_logMessage("DEBUG[3] View_toggleMargins(" . View_#%Manager_aMonitor%_#%v%_margin1 . ", " . View_#%Manager_aMonitor%_#%v%_margin2 . ", " . View_#%Manager_aMonitor%_#%v%_margin3 . ", " . View_#%Manager_aMonitor%_#%v%_margin4 . ")", 3)
If Not (Config_viewMargins = "0;0;0;0")
If Not (Config_viewMargins = "0;0;0;0")
{
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
Else
Else
View_#%Manager_aMonitor%_#%v%_margins := "0;0;0;0"
StringSplit, View_#%Manager_aMonitor%_#%v%_margin, View_#%Manager_aMonitor%_#%v%_margins, `;
View_arrange(Manager_aMonitor, v)

View File

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