bling/layout/horizontal.lua

57 lines
1.4 KiB
Lua
Raw Normal View History

2020-10-19 17:25:05 +02:00
local math = math
local mylayout = {}
mylayout.name = "horizontal"
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_height = area.height * mwfact
local slave_area_height = area.height - master_area_height
-- Special case: no slaves
2021-08-27 20:01:22 +02:00
if nslaves == 0 then
2020-10-19 17:25:05 +02:00
master_area_height = area.height
slave_area_height = 0
2021-08-27 20:01:22 +02:00
end
2020-10-19 17:25:05 +02:00
-- Special case: no masters
2021-08-27 20:01:22 +02:00
if nmaster == 0 then
master_area_height = 0
2020-10-19 17:25:05 +02:00
slave_area_height = area.height
2021-08-27 20:01:22 +02:00
end
2020-10-19 17:25:05 +02:00
-- itearte 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 = {
2021-08-27 20:01:22 +02:00
x = area.x + (idx - 1) * (area.width / nmaster),
2020-10-19 17:25:05 +02:00
y = area.y,
2021-08-27 20:01:22 +02:00
width = area.width / nmaster,
2020-10-19 17:25:05 +02:00
height = master_area_height,
}
p.geometries[c] = g
end
-- iterate 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 = {
x = area.x,
2021-08-27 20:01:22 +02:00
y = area.y
+ master_area_height
+ (idx - 1) * (slave_area_height / nslaves),
2020-10-19 17:25:05 +02:00
width = area.width,
2021-08-27 20:01:22 +02:00
height = slave_area_height / nslaves,
2020-10-19 17:25:05 +02:00
}
p.geometries[c] = g
end
end
return mylayout