Manual merge with latest from berlios

This commit is contained in:
Joshua Fuhs 2012-12-03 21:52:43 -05:00
parent e9e5a853cc
commit fe1f4793f4
3 changed files with 1081 additions and 867 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,38 +1,42 @@
/**
* bug.n - tiling window management
* Copyright (c) 2010-2012 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
*/
/*
bug.n -- tiling window management
Copyright (c) 2010-2012 Joshua Fuhs, joten
Monitor_init(m) {
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
*/
Monitor_init(m)
{
Global
Monitor_#%m%_aView_#1 := 1
Monitor_#%m%_aView_#2 := 1
Monitor_#%m%_showBar := Config_showBar
Loop, % Config_viewCount
{
View_init(m, A_Index)
}
Config_restoreLayout(Main_autoLayout, m)
Monitor_getWorkArea(m)
Bar_init(m)
}
Monitor_activateView(v) {
Local aView, aWndClass, aWndId, aWndTitle, m, n, wndId, wndIds
Monitor_activateView(v)
{
Local aView, aWndId, m, n, wndId, wndIds
If (v = -1)
v := Monitor_#%Manager_aMonitor%_aView_#2
@ -41,29 +45,28 @@ Monitor_activateView(v) {
Else If (v = "<")
v := Manager_loop(Monitor_#%Manager_aMonitor%_aView_#1, -1, 1, Config_viewCount)
Debug_logMessage("Monitor_activateView(" . v . ") Manager_aMonitor: " . Manager_aMonitor . "; wndIds: " . View_#%m%_#%aView%_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
Return
; Re-arrange the windows on the view.
If (v = Monitor_#%Manager_aMonitor%_aView_#1) {
;; Re-arrange the windows on the active view.
If (v = Monitor_#%Manager_aMonitor%_aView_#1)
{
View_arrange(Manager_aMonitor, v)
Return
}
aView := Monitor_#%Manager_aMonitor%_aView_#1
WinGet, aWndId, ID, A
If WinExist("ahk_id" aWndId) And InStr(View_#%Manager_aMonitor%_#%aView%_wndIds, aWndId ";") {
WinGetClass, aWndClass, ahk_id %aWndId%
WinGetTitle, aWndTitle, ahk_id %aWndId%
If Not (aWndClass = "Progman") And Not (aWndClass = "AutoHotkeyGui" And SubStr(aWndTitle, 1, 10) = "bug.n_BAR_") And Not (aWndClass = "DesktopBackgroundClass")
aWndId := View_getActiveWindow(Manager_aMonitor, aView)
If aWndId
View_#%Manager_aMonitor%_#%aView%_aWndId := aWndId
}
n := 1
If (Config_syncMonitorViews > 0)
n := Config_syncMonitorViews
If (n = 1)
n := Manager_monitorCount
Loop, % n {
Else If (n < 1)
n := 1
Loop, % n
{
If (n = 1)
m := Manager_aMonitor
Else
@ -71,16 +74,14 @@ Monitor_activateView(v) {
Monitor_#%m%_aView_#2 := aView
Monitor_#%m%_aView_#1 := v
Manager_hideShow := True
; Most of the operations here are dispersed to multiple _different_ windows.
; Delays in this part of the code are extremely noticeable and the users
; do a lot of view switching.
SetWinDelay, 0
StringTrimRight, wndIds, View_#%m%_#%aView%_wndIds, 1
Loop, PARSE, wndIds, `;
{
If Not (Manager_#%A_LoopField%_tags & (1 << v - 1))
Manager_winHide(A_LoopField)
}
SetWinDelay, 10
DetectHiddenWindows, On
View_arrange(m, v)
@ -88,7 +89,9 @@ Monitor_activateView(v) {
StringTrimRight, wndIds, View_#%m%_#%v%_wndIds, 1
SetWinDelay, 0
Loop, PARSE, wndIds, `;
{
Manager_winShow(A_LoopField)
}
SetWinDelay, 10
Manager_hideShow := False
@ -97,30 +100,38 @@ Monitor_activateView(v) {
}
wndId := View_#%Manager_aMonitor%_#%v%_aWndId
If Not (wndId And WinExist("ahk_id" wndId)) {
If View_#%Manager_aMonitor%_#%v%_wndIds {
If Not (wndId And WinExist("ahk_id" wndId))
{
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
}
Else
wndId := 0
}
Manager_winActivate(wndId)
}
Monitor_get(x, y) {
Monitor_get(x, y)
{
Local m
m := 0
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) {
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)
{
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
@ -133,27 +144,40 @@ Monitor_getWorkArea(m) {
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) { ; Horizontal
If (wndY <= monitorTop) { ; Top
If (wndHeight < wndWidth)
{ ;; Horizontal
If (wndY <= monitorTop)
{ ;; Top
wndHeight += wndY - monitorTop
monitorTop += wndHeight
} Else { ; Bottom
If (A_LoopField = "Shell_TrayWnd")
Manager_taskBarPos := "top"
}
Else
{ ;; Bottom
wndHeight := monitorBottom - wndY
monitorBottom -= wndHeight
}
} Else { ; Vertical
If (wndX <= monitorLeft) { ; Left
}
Else
{ ;; Vertical
If (wndX <= monitorLeft)
{ ;; Left
wndWidth += wndX
monitorLeft += wndWidth
} Else { ; Right
}
Else
{ ;; Right
wndWidth := monitorRight - wndX
monitorRight -= wndWidth
}
@ -161,11 +185,16 @@ Monitor_getWorkArea(m) {
}
}
}
If Monitor_#%m%_showBar {
If (Config_verticalBarPos = "top" Or (Config_verticalBarPos = "tray" And Not m = Manager_taskBarMonitor)) {
bTop := 0
If Monitor_#%m%_showBar
{
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
}
@ -178,13 +207,15 @@ 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 = ">")
@ -193,22 +224,32 @@ Monitor_setWindowTag(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 (t = 0) {
If (InStr(Manager_managedWndIds, aWndId ";") And t >= 0 And t <= Config_viewCount)
{
If (t = 0)
{
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
Bar_updateView(Manager_aMonitor, A_Index)
Manager_#%aWndId%_tags += 1 << A_Index - 1
}
} Else {
}
}
Else
{
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%`;,
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
@ -216,14 +257,16 @@ Monitor_setWindowTag(t) {
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)
Manager_winActivate(wndId)
Manager_hideShow := False
If Config_viewFollowsTagged
Monitor_activateView(t)
Else {
Else
{
Manager_hideShow := True
Manager_winHide(aWndId)
Manager_hideShow := False
@ -235,7 +278,8 @@ Monitor_setWindowTag(t) {
}
}
Monitor_toggleBar() {
Monitor_toggleBar()
{
Global
Monitor_#%Manager_aMonitor%_showBar := Not Monitor_#%Manager_aMonitor%_showBar
@ -245,17 +289,22 @@ 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
}
@ -266,17 +315,22 @@ 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 (Manager_#%aWndId%_tags & (1 << t - 1)) {
If Not ((Manager_#%aWndId%_tags - (1 << t - 1)) = 0) {
If (InStr(Manager_managedWndIds, aWndId ";") And t >= 0 And t <= Config_viewCount)
{
If (Manager_#%aWndId%_tags & (1 << t - 1))
{
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%`;,
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)
Manager_hideShow := False
@ -285,7 +339,9 @@ 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
Bar_updateView(Manager_aMonitor, t)

View file

@ -1,24 +1,25 @@
/**
* bug.n - tiling window management
* Copyright (c) 2010-2012 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
*/
/*
bug.n -- tiling window management
Copyright (c) 2010-2012 Joshua Fuhs, joten
View_init(m, v) {
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
*/
View_init(m, v)
{
Global
View_#%m%_#%v%_aWndId := 0
@ -32,84 +33,81 @@ View_init(m, v) {
View_#%m%_#%v%_layoutMX := 1
View_#%m%_#%v%_layoutMY := 1
View_#%m%_#%v%_layoutSymbol := Config_layoutSymbol_#1
View_#%m%_#%v%_margins := "0;0;0;0"
StringSplit, View_#%m%_#%v%_margin, View_#%m%_#%v%_margins, `;
View_#%m%_#%v%_wndIds := ""
}
View_activateWindow(d) {
Local aWndId, i, j, v, wndId, wndId0, wndIds, failure, direction
Debug_logMessage("View_activateWindow(" . d . ")", 1)
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("Active Windows ID: " . aWndId, 2, False)
Debug_logMessage("DEBUG[2] Active Windows ID: " . aWndId, 2, False)
v := Monitor_#%Manager_aMonitor%_aView_#1
Debug_logMessage("View (" . v . ") wndIds: " . View_#%Manager_aMonitor%_#%v%_wndIds, 2)
Debug_logMessage("DEBUG[2] View (" . v . ") wndIds: " . View_#%Manager_aMonitor%_#%v%_wndIds, 2, False)
StringTrimRight, wndIds, View_#%Manager_aMonitor%_#%v%_wndIds, 1
StringSplit, wndId, wndIds, `;
Debug_logMessage("wndId count: " . wndId0, 2)
If (wndId0 > 1) {
Debug_logMessage("DEBUG[2] wndId count: " . wndId0, 2, False)
If (wndId0 > 1)
{
If Manager_#%aWndId%_isFloating
Manager_winSet("Bottom", "", aWndId)
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)
direction = 1
Else
direction = -1
Debug_logMessage("Current wndId index: " . i, 2, False)
j := Manager_loop(i, d, 1, wndId0)
Loop, % wndId0 {
Debug_logMessage("Next wndId index: " . j, 2, False)
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)
; This is a lot of extra work in case there are hung windows on the screen.
; We still want to be able to cycle through them.
failure := Manager_winActivate(wndId)
If Not failure {
Break
}
;; 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
Break
j := Manager_loop(j, direction, 1, wndId0)
}
}
}
View_updateLayout(m, v) {
Local fn, l, wndIds
l := View_#%m%_#%v%_layout_#1
fn := Config_layoutFunction_#%l%
View_updateLayout_%fn%(m, v)
}
; Add a window to the view in question.
View_addWnd(m, v, wndId) {
Local l, msplit, i, wndIds, n
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")) {
n := View_getTiledWndIds(m, v, wndIds)
msplit := View_#%m%_#%v%_layoutMX * View_#%m%_#%v%_layoutMY
If ( msplit = 1 And Config_newWndPosition="masterBottom" ) {
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")
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 {
If (Config_newWndPosition="masterBottom")
i := msplit - 1
Else
i := msplit
StringSplit, wndId, wndIds, `;
search := wndId%i% ";"
{
If (Config_newWndPosition = "masterBottom")
i := mSplit - 1
Else
i := mSplit
search := View_tiledWndId%i% ";"
replace := search wndId ";"
StringReplace, View_#%m%_#%v%_wndIds, View_#%m%_#%v%_wndIds, %search%, %replace%
}
@ -120,7 +118,195 @@ View_addWnd(m, v, wndId) {
View_#%m%_#%v%_wndIds := wndId ";" View_#%m%_#%v%_wndIds
}
View_ghostWnd(m, v, bodyWndId, ghostWndId) {
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
{
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)
View_arrange_%fn%(m, v, x, y, w, h)
SetWinDelay, 10
}
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)
{
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)
{
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
flipped := View_#%m%_#%v%_layoutAxis_#1 < 0
gapW := View_#%m%_#%v%_layoutGapWidth
mFact := View_#%m%_#%v%_layoutMFact
mXSet := (axis2 = 1) ? View_#%m%_#%v%_layoutMX : View_#%m%_#%v%_layoutMY
mYSet := (axis2 = 1) ? View_#%m%_#%v%_layoutMY : View_#%m%_#%v%_layoutMX
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)
{ ;; 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)
Else
{
mYActual := Ceil(mSplit / mXSet)
subAreaCount := mYActual
mWndCount := mSplit
Loop, % mYActual
{
View_splitArea(Not (axis2 - 1), 1 / subAreaCount, x1, y1, w1, h1, gapW, subX1, subY1, subW1, subH1, x1, y1, w1, h1)
subAreaWndCount := mXSet
If (mWndCount < subAreaWndCount)
subAreaWndCount := mWndCount
View_stackWindows("View_tiledWndId", mSplit - mWndCount + 1, subAreaWndCount, +1, axis2, subX1, subY1, subW1, subH1, gapW)
mWndCount -= subAreaWndCount
subAreaCount -= 1
}
}
;; Stack
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;
;; 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))
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)
}
View_getActiveWindow(m, v)
{
Local aWndClass, aWndId, aWndTitle
WinGet, aWndId, ID, A
If WinExist("ahk_id" aWndId) And InStr(View_#%m%_#%v%_wndIds, aWndId ";")
{
WinGetClass, aWndClass, ahk_id %aWndId%
WinGetTitle, aWndTitle, ahk_id %aWndId%
If Not (aWndClass = "Progman") And Not (aWndClass = "AutoHotkeyGui" And SubStr(aWndTitle, 1, 10) = "bug.n_BAR_") And Not (aWndClass = "DesktopBackgroundClass")
Return, aWndId
}
Return, 0
}
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
;; -1 - vertical divider, master right
;; -2 - horizontal divider, master bottom
axis1 := View_#%m%_#%v%_layoutAxis_#1
;; Master axis
;; 1 - vertical divider
;; 2 - horizontal divider
;; 3 - monocle
axis2 := View_#%m%_#%v%_layoutAxis_#2
;; Stack axis
;; 1 - vertical divider
;; 2 - horizontal divider
;; 3 - monocle
axis3 := View_#%m%_#%v%_layoutAxis_#3
mx := View_#%m%_#%v%_layoutMX
my := View_#%m%_#%v%_layoutMY
If (Abs(axis1) = 1)
masterDiv := "|"
Else
masterDiv := "-"
If (axis2 = 1)
masterDim := mx . "x" . my
Else If (axis2 = 2)
masterDim := mx . "x" . my
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)
{
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)
{
n += 1
tiledWndIds .= A_LoopField ";"
}
}
StringTrimRight, tiledWndIds, tiledWndIds, 1
StringSplit, View_tiledWndId, tiledWndIds, `;
Return, n
}
View_ghostWindow(m, v, bodyWndId, ghostWndId)
{
Local search, replace
search := bodyWndId ";"
@ -128,88 +314,32 @@ View_ghostWnd(m, v, bodyWndId, ghostWndId) {
StringReplace, View_#%m%_#%v%_wndIds, View_#%m%_#%v%_wndIds, %search%, %replace%
}
; Remove a window from the view in question.
View_delWnd(m, v, wndId) {
StringReplace, View_#%m%_#%v%_wndIds, View_#%m%_#%v%_wndIds, %wndId%`;,
}
View_arrange(m, v) {
Local fn, l, wndIds
Debug_logMessage("View_arrange(" . m . ", " . v . ")", 1)
; All window actions are performed on independent windows. A delay won't help.
SetWinDelay, 0
l := View_#%m%_#%v%_layout_#1
fn := Config_layoutFunction_#%l%
View_getTiledWndIds(m, v, wndIds)
View_arrange_%fn%(m, v, wndIds)
View_updateLayout(m, v)
Bar_updateLayout(m)
SetWinDelay, 10
}
View_getTiledWndIds(m, v, ByRef tiledWndIds) {
Local n, 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) {
n += 1
tiledWndIds .= A_LoopField ";"
}
}
Return, n
}
View_updateLayout_(m, v)
View_rotateLayoutAxis(i, d)
{
View_#%m%_#%v%_layoutSymbol := "><>"
}
View_arrange_(m, v)
{
; Place-holder
}
View_updateLayout_monocle(m, v)
{
Local wndIds, wndId, wndId0
StringTrimRight, wndIds, View_#%m%_#%v%_wndIds, 1
StringSplit, wndId, wndIds, `;
View_#%m%_#%v%_layoutSymbol := "[" wndId0 "]"
}
View_arrange_monocle(m, v, wndIds) {
Local gw
gw := View_#%m%_#%v%_layoutGapWidth
StringTrimRight, wndIds, wndIds, 1
StringSplit, View_arrange_monocle_wndId, wndIds, `;
View_draw_stack("View_arrange_monocle_wndId", 1, View_arrange_monocle_wndId0, 0, Monitor_#%m%_x, Monitor_#%m%_y, Monitor_#%m%_width, Monitor_#%m%_height, gw/2)
}
View_rotateLayoutAxis(i, d) {
Local f, l, v, n, tmp
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 (i = 1) {
If (Config_layoutFunction_#%l% = "tile") And (i = 1 Or i = 2 Or i = 3)
{
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 axis doesn't change, there's no need to adjust (Not (n = View_#%Manager_aMonitor%_#%v%_layoutAxis_#%i%))
; 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)) {
;; 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)
{
tmp := View_#%Manager_aMonitor%_#%v%_layoutMX
View_#%Manager_aMonitor%_#%v%_layoutMX := View_#%Manager_aMonitor%_#%v%_layoutMY
View_#%Manager_aMonitor%_#%v%_layoutMY := tmp
@ -220,25 +350,29 @@ 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") {
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)
}
}
}
View_setLayout(l) {
View_setLayout(l)
{
Local v
v := Monitor_#%Manager_aMonitor%_aView_#1
@ -246,8 +380,10 @@ View_setLayout(l) {
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 Not (l = View_#%Manager_aMonitor%_#%v%_layout_#1) {
If (l > 0) And (l <= Config_layoutCount)
{
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
}
@ -255,85 +391,103 @@ View_setLayout(l) {
}
}
View_setMFactor(d) {
Local l, mfact, v
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") {
mfact := View_#%Manager_aMonitor%_#%v%_layoutMFact + d
If (mfact >= 0.05 And mfact <= 0.95) {
View_#%Manager_aMonitor%_#%v%_layoutMFact := mfact
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)
{
View_#%Manager_aMonitor%_#%v%_layoutMFact := mFact
View_arrange(Manager_aMonitor, v)
}
}
}
View_setMX(d) {
Local l, n, m, v
View_setMX(d)
{
Local l, n, v
m := Manager_aMonitor
v := Monitor_#%m%_aView_#1
l := View_#%m%_#%v%_layout_#1
v := Monitor_#%Manager_aMonitor%_aView_#1
l := View_#%Manager_aMonitor%_#%v%_layout_#1
If Not (Config_layoutFunction_#%l% = "tile")
Return
n := View_#%m%_#%v%_layoutMX + d
If (n >= 1) And (n <= 9) {
View_#%m%_#%v%_layoutMX := n
View_arrange(m, v)
n := View_#%Manager_aMonitor%_#%v%_layoutMX + d
If (n >= 1) And (n <= 9)
{
View_#%Manager_aMonitor%_#%v%_layoutMX := n
View_arrange(Manager_aMonitor, v)
}
}
View_setMY(d) {
Local l, n, m, v
View_setMY(d)
{
Local l, n, v
m := Manager_aMonitor
v := Monitor_#%m%_aView_#1
l := View_#%m%_#%v%_layout_#1
v := Monitor_#%Manager_aMonitor%_aView_#1
l := View_#%Manager_aMonitor%_#%v%_layout_#1
If Not (Config_layoutFunction_#%l% = "tile")
Return
n := View_#%m%_#%v%_layoutMY + d
If (n >= 1) And (n <= 9) {
View_#%m%_#%v%_layoutMY := n
View_arrange(m, v)
n := View_#%Manager_aMonitor%_#%v%_layoutMY + d
If (n >= 1) And (n <= 9)
{
View_#%Manager_aMonitor%_#%v%_layoutMY := n
View_arrange(Manager_aMonitor, v)
}
}
View_shuffleWindow(d) {
Local aWndHeight, aWndId, aWndWidth, aWndX, aWndY, i, j, l, search, v, wndId0, wndIds
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 ";")) {
View_getTiledWndIds(Manager_aMonitor, v, wndIds)
StringTrimRight, wndIds, wndIds, 1
StringSplit, wndId, wndIds, `;
If (wndId0 > 1) {
Loop, % wndId0
If (wndId%A_Index% = aWndId) {
If (Config_layoutFunction_#%l% = "tile" And InStr(Manager_managedWndIds, aWndId ";"))
{
View_getTiledWndIds(Manager_aMonitor, v)
If (View_tiledWndId0 > 1)
{
Loop, % View_tiledWndId0
{
If (View_tiledWndId%A_Index% = aWndId)
{
i := A_Index
Break
}
}
If (d = 0 And i = 1)
j := 2
Else
j := Manager_loop(i, d, 1, wndId0)
If (j > 0 And j <= wndId0) {
If (j = i) {
j := Manager_loop(i, d, 1, View_tiledWndId0)
If (j > 0 And j <= View_tiledWndId0)
{
If (j = i)
{
StringReplace, View_#%Manager_aMonitor%_#%v%_wndIds, View_#%Manager_aMonitor%_#%v%_wndIds, %aWndId%`;,
View_#%Manager_aMonitor%_#%v%_wndIds := aWndId ";" View_#%Manager_aMonitor%_#%v%_wndIds
} Else {
search := wndId%j%
}
Else
{
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, %search%, %aWndId%
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))
}
@ -342,252 +496,119 @@ View_shuffleWindow(d) {
}
}
View_updateLayout_tile(m, v) {
Local axis1, axis2, axis3, mp, ms, sym1, sym3, master_div, master_dim, master_sym, stack_sym
; Main axis
; 1 - vertical divider, master left
; 2 - horizontal divider, master top
; -1 - vertical divider, master right
; -2 - horizontal divider, master bottom
axis1 := View_#%m%_#%v%_layoutAxis_#1
; Master axis
; 1 - vertical divider
; 2 - horizontal divider
; 3 - monocle
axis2 := View_#%m%_#%v%_layoutAxis_#2
; Stack axis
; 1 - vertical divider
; 2 - horizontal divider
; 3 - monocle
axis3 := View_#%m%_#%v%_layoutAxis_#3
mx := View_#%m%_#%v%_layoutMX
my := View_#%m%_#%v%_layoutMY
If ( Abs(axis1) = 1 )
master_div := "|"
Else
master_div := "="
If ( axis2 = 1 ) {
master_sym := "|"
master_dim := mx . "x" . my
}
Else If ( axis2 = 2 ) {
master_sym := "-"
master_dim := mx . "x" . my
}
Else
master_sym := "[" . (mx * my) . "]"
If ( axis3 = 1 )
stack_sym := "|"
Else If ( axis3 = 2 )
stack_sym := "-"
Else
stack_sym := "o"
If ( axis1 > 0 )
View_#%m%_#%v%_layoutSymbol := master_dim . master_sym . master_div . stack_sym
Else
View_#%m%_#%v%_layoutSymbol := stack_sym . master_div . master_sym . master_dim
}
; Stack a bunch of windows on top of each other.
;
; arrName - Name of a globally stored array of windows:
; %arrName%1, %arrName%2, ...
; off - Offset into the array from which to start drawing.
; len - Number of windows from the array to draw.
; dir - Determines the direction through which we traverse arrName
; x - View x-position
; y - View y-position
; w - View width
; h - View height
; margin - Number of pixels to put between the windows.
View_draw_stack( arrName, off, len, dir, x, y, w, h, margin ) {
Local base, inc
If (dir = 0) {
base := off
inc := 1
}
Else {
base := off + len - 1
inc := -1
}
x += margin
y += margin
w -= 2 * margin
h -= 2 * margin
Loop, % len {
Manager_winMove(%arrName%%base%, x, y, w, h)
base += inc
}
}
; Draw a row of windows.
;
; arrName - Name of a globally stored array of windows:
; %arrName%1, %arrName%2, ...
; off - Offset into the array from which to start drawing.
; len - Number of windows from the array to draw.
; dir - Determines the direction through which we traverse arrName
; axis - X/Y <=> 0/1
; x - View x-position
; y - View y-position
; w - View width
; h - View height
; margin - Number of pixels to put between the windows.
View_draw_row( arrName, off, len, dir, axis, x, y, w, h, margin ) {
Local base, inc, x_inc, y_inc, wHeight, wWidth
;Debug_logMessage("View_draw_row(" . arrName . ", " . off . ", " . len . ", " . dir . ", " . axis . ", " . x . ", " . y . ", " . w . ", " . h . ", " . margin . ")", 0)
If (dir = 0) {
; Left-to-right and top-to-bottom, depending on axis
base := off
inc := 1
}
Else {
; Right-to-left and bottom-to-top, depending on axis
base := off + len - 1
inc := -1
}
If (axis = 0) {
; Create row along X
x_inc := w / len
y_inc := 0
wWidth := x_inc - 2 * margin
wHeight := h - 2 * margin
}
Else {
; Create row along Y
x_inc := 0
y_inc := h / len
wWidth := w - 2 * margin
wHeight := y_inc - 2 * margin
}
; Set original positions with respect to the margins.
x += margin
y += margin
Loop, % len {
Manager_winMove(%arrName%%base%, x, y, wWidth, wHeight)
x += x_inc
y += y_inc
base += inc
}
}
View_arrange_tile_action(arrName, off, len, bugn_axis, x, y, w, h, m) {
; 161 is a magic number determined somewhere. Maybe make this configurable.
; Same with 2*Bar_height.
If (bugn_axis = 3 Or (bugn_axis = 1 And w/len < 161) Or (bugn_axis = 2 And h/len < (2*Bar_height)))
View_draw_stack(arrName, off, len, 0, x, y, w, h, m)
Else
View_draw_row(arrName, off, len, 0, bugn_axis - 1, x, y, w, h, m)
}
View_split_region(axis, split_point, x, y, w, h, 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(axis = 0) {
w1 := w * split_point
w2 := w - w1
If (splitRatio = 1)
{
w1 := w
w2 := 0
h1 := h
h2 := 0
x2 := x + w1
y2 := y + h1
}
Else If (axis = 0)
{
w1 := w * splitRatio - gapW / 2
w2 := w - w1 - gapW
h1 := h
h2 := h
x2 := x + w1
x2 := x + w1 + gapW
y2 := y
}
Else
{
w1 := w
w2 := w
h1 := h * split_point
h2 := h - h1
h1 := h * splitRatio - gapW / 2
h2 := h - h1 - gapW
x2 := x
y2 := y + h1
y2 := y + h1 + gapW
}
}
View_arrange_tile(m, v, wndIds) {
Local axis1, axis2, axis3, gapW_2, h1, h2, i, mfact, mp, ms, mx2, my2, mw2, mh2, msplit, n1, n2, w1, w2, x1, x2, y1, y2, flipped, stack_len, secondary_areas, areas_remaining, draw_windows
;; ARRAY SPECIFICATION
;; arrayName - Name of a globally stored array of windows:
;; %arrayName%1, %arrayName%2, ...
;; startPos - First entry of the array, which should be used.
;; len - Number of entries from the array, which should be used.
;; d - +1/-1: In-/Decrement (direction) for traversing through the array.
;; STACKING SPECIFICATION
;; axis - 1/2/3: Stacking axis (X/Y/Z)
;; AREA SPECIFICATION
;; x - X-position of the stacking area
;; y - Y-position of the stacking area
;; w - Width of the stacking area
;; h - Height of the stacking area
;; padding - Number of pixels to put between the windows.
View_stackWindows(arrayName, startPos, len, d, axis, x, y, w, h, padding)
{
Local dx, dy, i, wndH, wndW, wndX, wndY
StringTrimRight, wndIds, wndIds, 1
StringSplit, View_arrange_tile_wndId, wndIds, `;
Debug_logMessage("View_arrange_tile: (" . View_arrange_tile_wndId0 . ") " . wndIds, 1)
If (View_arrange_tile_wndId0 = 0)
Return
;; 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)
i += len - 1
axis1 := Abs(View_#%m%_#%v%_layoutAxis_#1)
axis2 := View_#%m%_#%v%_layoutAxis_#2
axis3 := View_#%m%_#%v%_layoutAxis_#3
flipped := View_#%m%_#%v%_layoutAxis_#1 < 0
gapW_2 := View_#%m%_#%v%_layoutGapWidth/2
mfact := View_#%m%_#%v%_layoutMFact
dimAligned := (axis2 = 1) ? View_#%m%_#%v%_layoutMX : View_#%m%_#%v%_layoutMY
dimOrtho := (axis2 = 1) ? View_#%m%_#%v%_layoutMY : View_#%m%_#%v%_layoutMX
msplit := dimAligned * dimOrtho
If (msplit > View_arrange_tile_wndId0) {
msplit := View_arrange_tile_wndId0
}
; master and stack area
If( View_arrange_tile_wndId0 > msplit) {
If( flipped = 0)
View_split_region( axis1 - 1, mfact, Monitor_#%m%_x, Monitor_#%m%_y, Monitor_#%m%_width, Monitor_#%m%_height, x1, y1, w1, h1, x2, y2, w2, h2)
Else
View_split_region( axis1 - 1, 1 - mfact, Monitor_#%m%_x, Monitor_#%m%_y, Monitor_#%m%_width, Monitor_#%m%_height, x2, y2, w2, h2, x1, y1, w1, h1)
}
Else {
x1 := Monitor_#%m%_x
y1 := Monitor_#%m%_y
w1 := Monitor_#%m%_width
h1 := Monitor_#%m%_height
}
; master
; Number
If( axis2 = 3 )
wndX := x
wndY := y
wndW := w
wndH := h
dx := 0
dy := 0
If (axis = 1)
{
View_draw_stack("View_arrange_tile_wndId", 1, msplit, 0, x1, y1, w1, h1, gapW_2)
wndW := (w - (len - 1) * padding) / len
dx := wndW + padding
}
Else
Else If (axis = 2)
{
secondary_areas := Ceil(msplit / dimAligned)
areas_remaining := secondary_areas
windows_remaining := msplit
;Debug_logMessage("msplit: " . msplit . "; layoutMX/Y: " . dimAligned . "; secondary_areas: " . secondary_areas . "; areas_remaining: " . areas_remaining . "; windows_remaining: " . windows_remaining, 0)
Loop, % secondary_areas {
View_split_region(Not (axis2 - 1), (1/areas_remaining), x1, y1, w1, h1, mx1, my1, mw1, mh1, x1, y1, w1, h1)
draw_windows := dimAligned
If (windows_remaining < dimAligned) {
draw_windows := windows_remaining
}
View_draw_row("View_arrange_tile_wndId", msplit - windows_remaining + 1, draw_windows, 0, axis2 - 1, mx1, my1, mw1, mh1, gapW_2)
windows_remaining -= draw_windows
areas_remaining -= 1
}
wndH := (h - (len - 1) * padding) / len
dy := wndH + padding
}
;; Else (axis = 3) and nothing to do
; stack
If (View_arrange_tile_wndId0 <= msplit)
Return
stack_len := View_arrange_tile_wndId0 - msplit
View_arrange_tile_action("View_arrange_tile_wndId", msplit + 1, stack_len, axis3, x2, y2, w2, h2, gapW_2)
Loop, % len
{
Manager_winMove(%arrayName%%i%, wndX, wndY, wndW, wndH)
i += d
wndX += dx
wndY += dy
}
}
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)
Bar_updateTitle()
}
}
View_toggleMargins()
{
Local v
Debug_logMessage("DEBUG[3] View_toggleMargins(" . View_#%Manager_aMonitor%_#%v%_margin1 . ", " . View_#%Manager_aMonitor%_#%v%_margin2 . ", " . View_#%Manager_aMonitor%_#%v%_margin3 . ", " . View_#%Manager_aMonitor%_#%v%_margin4 . ")", 3)
If Not (Config_viewMargins = "0;0;0;0")
{
v := Monitor_#%Manager_aMonitor%_aView_#1
If (View_#%Manager_aMonitor%_#%v%_margins = "0;0;0;0")
View_#%Manager_aMonitor%_#%v%_margins := Config_viewMargins
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)
}
}