awful.placement: add centered placement

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2009-02-13 23:56:26 +01:00
parent b5db8032f9
commit 7349fb56a8
1 changed files with 9 additions and 0 deletions

View File

@ -170,4 +170,13 @@ function under_mouse(c)
y = m_coords.y - c_geometry.height / 2 }) y = m_coords.y - c_geometry.height / 2 })
end end
--- Place the client centered in the screen.
-- @param c The client.
function centered(c)
local c_geometry = c:geometry()
local s_geometry = capi.screen[c.screen].geometry
c:geometry({ x = s_geometry.x + (s_geometry.width - c_geometry.width) / 2,
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 -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80