placement: import center_horizontal and center_vertical

Signed-off-by: Cedric GESTES <ctaf42@gmail.com>
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Cedric GESTES 2009-09-13 14:50:53 +02:00 committed by Julien Danjou
parent 626ea00ca0
commit 9a0ae64840
1 changed files with 33 additions and 0 deletions

View File

@ -192,4 +192,37 @@ function centered(c, p)
y = s_geometry.y + (s_geometry.height - c_geometry.height) / 2 })
end
--- Place the client centered on the horizontal axis with respect to a parent or the clients screen.
-- @param c The client.
-- @param p The parent (optional, nil for screen centering).
-- @return The new client geometry.
function center_horizontal(c, p)
local c = c or capi.client.focus
local c_geometry = c:geometry()
local s_geometry
if p then
s_geometry = p:geometry()
else
s_geometry = capi.screen[c.screen].geometry
end
return c:geometry({ x = s_geometry.x + (s_geometry.width - c_geometry.width) / 2 })
end
--- Place the client centered on the vertical axis with respect to a parent or the clients screen.
-- @param c The client.
-- @param p The parent (optional, nil for screen centering).
-- @return The new client geometry.
function center_vertical(c, p)
local c = c or capi.client.focus
local c_geometry = c:geometry()
local s_geometry
if p then
s_geometry = p:geometry()
else
s_geometry = capi.screen[c.screen].geometry
end
return c:geometry({ y = s_geometry.y + (s_geometry.height - c_geometry.height) / 2 })
end
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80