2020-10-19 17:25:05 +02:00
|
|
|
local math = math
|
|
|
|
|
|
|
|
local mylayout = {}
|
|
|
|
|
|
|
|
mylayout.name = "vertical"
|
|
|
|
|
|
|
|
function mylayout.arrange(p)
|
|
|
|
local area = p.workarea
|
|
|
|
local t = p.tag or screen[p.screen].selected_tag
|
|
|
|
local mwfact = t.master_width_factor
|
|
|
|
local nmaster = math.min(t.master_count, #p.clients)
|
|
|
|
local nslaves = #p.clients - nmaster
|
|
|
|
|
|
|
|
local master_area_width = area.width * mwfact
|
|
|
|
local slave_area_width = area.width - master_area_width
|
|
|
|
|
2021-08-27 20:01:22 +02:00
|
|
|
-- Special case: no slaves
|
|
|
|
if nslaves == 0 then
|
2020-10-19 17:25:05 +02:00
|
|
|
master_area_width = area.width
|
|
|
|
slave_area_width = 0
|
2021-08-27 20:01:22 +02:00
|
|
|
end
|
2020-10-19 17:25:05 +02:00
|
|
|
|
2021-08-27 20:01:22 +02:00
|
|
|
-- Special case: no masters
|
|
|
|
if nmaster == 0 then
|
2020-10-19 17:25:05 +02:00
|
|
|
master_area_width = 0
|
|
|
|
slave_area_width = area.width
|
2021-08-27 20:01:22 +02:00
|
|
|
end
|
2020-10-19 17:25:05 +02:00
|
|
|
|
|
|
|
-- iterate through masters
|
2021-08-27 20:01:22 +02:00
|
|
|
for idx = 1, nmaster do
|
2020-10-19 17:25:05 +02:00
|
|
|
local c = p.clients[idx]
|
|
|
|
local g = {
|
|
|
|
x = area.x,
|
2021-08-27 20:01:22 +02:00
|
|
|
y = area.y + (idx - 1) * (area.height / nmaster),
|
2020-10-19 17:25:05 +02:00
|
|
|
width = master_area_width,
|
2021-08-27 20:01:22 +02:00
|
|
|
height = area.height / nmaster,
|
2020-10-19 17:25:05 +02:00
|
|
|
}
|
|
|
|
p.geometries[c] = g
|
|
|
|
end
|
|
|
|
|
|
|
|
-- itearte through slaves
|
2021-08-27 20:01:22 +02:00
|
|
|
for idx = 1, nslaves do
|
|
|
|
local c = p.clients[idx + nmaster]
|
2020-10-19 17:25:05 +02:00
|
|
|
local g = {
|
2021-08-27 20:01:22 +02:00
|
|
|
x = area.x
|
|
|
|
+ master_area_width
|
|
|
|
+ (idx - 1) * (slave_area_width / nslaves),
|
2020-10-19 17:25:05 +02:00
|
|
|
y = area.y,
|
2021-08-27 20:01:22 +02:00
|
|
|
width = slave_area_width / nslaves,
|
2020-10-19 17:25:05 +02:00
|
|
|
height = area.height,
|
|
|
|
}
|
|
|
|
p.geometries[c] = g
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-11-06 19:33:58 +01:00
|
|
|
return mylayout
|