awful.placement: return new geometry and use focused client by default

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2009-02-13 23:57:40 +01:00
parent 7349fb56a8
commit e8b7bf9a18
1 changed files with 12 additions and 5 deletions

View File

@ -13,6 +13,7 @@ local capi =
{
screen = screen,
mouse = mouse,
client = client
}
local client = require("awful.client")
local layout = require("awful.layout")
@ -100,7 +101,9 @@ end
--- Place the client without it being outside the screen.
-- @param c The client.
-- @return The new client geometry.
function no_offscreen(c)
local c = c or capi.client.focus
local geometry = c:geometry()
local screen_geometry = capi.screen[c.screen].workarea
@ -158,25 +161,29 @@ function no_overlap(c)
new.width = geometry.width
new.height = geometry.height
c:geometry(new)
return c:geometry(new)
end
--- Place the client under the mouse.
-- @param c The client.
-- @return The new client geometry.
function under_mouse(c)
local c = c or capi.client.focus
local c_geometry = c:geometry()
local m_coords = capi.mouse.coords()
c:geometry({ x = m_coords.x - c_geometry.width / 2,
y = m_coords.y - c_geometry.height / 2 })
return c:geometry({ x = m_coords.x - c_geometry.width / 2,
y = m_coords.y - c_geometry.height / 2 })
end
--- Place the client centered in the screen.
-- @param c The client.
-- @return The new client geometry.
function centered(c)
local c = c or capi.client.focus
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 })
return 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