Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

159 lines (138 sloc) 4.999 kB
min = `a,b| (a > b) ? b ! a`
@Layout
{
- prepare: wm
{
idx = wm activeWindows indexOf: (AccessibilityWindow frontMostWindow)
if idx ~= -1 then
wm activeWindows swap: 0 with: idx
}
- windowBefore: window inWm: wm
{
windows = wm managedWindowsForScreen: window screen
space: wm currentSpaceId
^(windows itemBefore: window) || windows last
}
- windowAfter: window inWm: wm
{
windows = wm managedWindowsForScreen: window screen
space: wm currentSpaceId
^(windows itemAfter: window) || windows first
}
- focusOnWindow: window inWm: wm `window raise`
}
@TallLayout < Layout
{
- reflow: wm screen: screen space: spaceId
{
windows = wm managedWindowsForScreen: screen space: spaceId
screenFrame = screen flippedFrame
masterCount = wm maxMastersOnScreen: screen space: spaceId
left = screenFrame[0][0]
top = screenFrame[0][1]
masterCount = min(windows count, masterCount)
subCount = (windows count) - masterCount
split = screenFrame[1][0]
if windows count > masterCount {
split *= wm ratioForScreen: screen space: spaceId
subWidth = (screenFrame[1][0] - split) / subCount
}
i = 0
windows each: { win |
if i < masterCount {
h = screenFrame[1][1] / masterCount
y = top + h*i
masterCount = wm maxMastersOnScreen: screen space: spaceId
frame = [[left, y], [split, h]]
win setFrame: frame
} else {
h = screenFrame[1][1] / subCount
y = top + h*(i - masterCount)
frame = [[left + split, y], [screenFrame[1][0] - split, h]]
win setFrame: frame
}
++i
}
}
}
@MultiColLayout < Layout
{
accessor: #horizontallyFlipped
- reflow: wm screen: screen space: spaceId
{
windows = wm managedWindowsForScreen: screen space: spaceId
screenFrame = screen flippedFrame
masterCount = wm maxMastersOnScreen: screen space: spaceId
left = screenFrame[0][0]
top = screenFrame[0][1]
masterCount = min(windows count, masterCount)
subCount = windows count - masterCount
^nil if masterCount == 0
if subCount > 0 {
subX = screenFrame[1][0] * (wm ratioForScreen: screen space: spaceId)
subWidth = (screenFrame[1][0] - subX)
subX += left
} else
subWidth = 0
masterWidth = (screenFrame[1][0] - subWidth) / masterCount
subX = left if @horizontallyFlipped
i = 0
windows each: { win |
if i < masterCount {
x = i * masterWidth
x = screenFrame[1][0] - x - masterWidth if @horizontallyFlipped
x += left
masterCount = wm maxMastersOnScreen: screen space: spaceId
frame = [[x, top], [masterWidth, screenFrame[1][1]]]
win setFrame: frame
} else {
h = screenFrame[1][1] / subCount
y = top + h*(i - masterCount)
frame = [[subX, y], [subWidth, h]]
win setFrame: frame
}
++i
}
}
}
@WideLayout < Layout
{
- reflow: wm screen: screen space: spaceId
{
windows = wm managedWindowsForScreen: screen space: spaceId
screenFrame = screen flippedFrame
masterCount = wm maxMastersOnScreen: screen space: spaceId
left = screenFrame[0][0]
top = screenFrame[0][1]
masterCount = min(windows count, masterCount)
subCount = (windows count) - masterCount
split = screenFrame[1][1]
`split *= wm ratioForScreen: screen space: spaceId` unless: (windows count) <= masterCount
i = 0
windows each: { win |
if i < masterCount {
w = screenFrame[1][0] / masterCount
x = left + w*i
masterCount = wm maxMastersOnScreen: screen space: spaceId \ why is this here? TODO verify it is ok to delete
frame = [[x, top], [w, split]]
win setFrame: frame
} else {
w = screenFrame[1][0] / subCount
x = left + w*(i - masterCount)
frame = [[x, top + split], [w, screenFrame[1][1] - split]]
win setFrame: frame
}
++i
}
}
}
@FullscreenLayout < Layout
{
- reflow: wm screen: screen space: spaceId
{
windows = wm managedWindowsForScreen: screen space: spaceId
screenFrame = screen flippedFrame
masterCount = wm maxMastersOnScreen: screen space: spaceId
windows each: `window| window setFrame: screenFrame`
}
}
Jump to Line
Something went wrong with that request. Please try again.