Hi,
I'm trying to code my custom tiling layout but having trouble to calculate
proper geometry of clients.
The goal is to have one master window on the left, main "slave" window on
the right ocuppying 85% of workspace height and remaining slave clients
stacked bellow in remaining 15%.
The issue is with gaps between xterm and gVim clients. I know about
disabling size_hints_honor but I would like to avoid it. The stock tiling
layout by D. E. Curtis and Julien Danjou aligns such clients geometry
without setting size_hints_honor to false, but I'm getting hard time to
understand their code.
Even stranger if I manually set master client x position to 0 and width to
877 pixels, slave x position at 877 and width to remaining workarea space,
there is still gap between. Awesome-client confirms master ends at 877 and
slave starts at 877 but there is still visible gap !
awesome-client> print(awful.tag.selected(1):clients()[1]:geometry().x)
0
awesome-client> print(awful.tag.selected(1):clients()[1]:geometry().width)
877
awesome-client> print(awful.tag.selected(1):clients()[2]:geometry().x)
877
awesome-client> print(awful.tag.selected(1):clients()[2]:geometry().width)
470
?!
Here is my attempt:
-- Stacked layout implementation
local function stacked_layout(p)
local function geom_hinted(cli, geom)
local size_hints = cli.size_hints
local width_hint = size_hints['width_inc']
local height_hint = size_hints['height_inc']
local g = { }
table.foreach(geom, function (k,v) g[k] = v end )
g.width = g.width - (g.width % width_hint) + cli.border_width*2
g.height = g.height - (g.height % height_hint) + cli.border_width*2
return g
end
local wa = p.workarea
local cls = p.clients
local mfact = awful.tag.getmwfact( awful.tag.selected(p.screen) )
awful.tag.getdata(awful.tag.selected(p.screen)).windowfact = {}
if #cls > 0 then
local g = { width = math.floor(wa.width * mfact),
height = wa.height,
x = wa.x, y = wa.y
}
g = geom_hinted( cls[1], g )
local mwidth = g.width
-- master client
cls[1]:geometry( g )
-- slave clients
local smheight = math.floor(wa.height * 0.85)
for ix=2, #cls do
g.x = mwidth
g.width = wa.width - g.x
if ix == 2 then
-- main
g.height = (#cls == 2) and wa.height or smheight
g.y = wa.y
g = geom_hinted( cls[ix], g )
else
-- remaining stacked
g.y = g.y + g.height
g.height = math.floor( wa.height * 0.15 / (#cls-2) )
g = geom_hinted( cls[ix], g )
end
cls[ix]:geometry( g )
end
end
end
awful.layout.suit.stacked = { name = "stacked", arrange = stacked_layout }