awful.placement: return new geometry and use focused client by default
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
7349fb56a8
commit
e8b7bf9a18
|
@ -13,6 +13,7 @@ local capi =
|
||||||
{
|
{
|
||||||
screen = screen,
|
screen = screen,
|
||||||
mouse = mouse,
|
mouse = mouse,
|
||||||
|
client = client
|
||||||
}
|
}
|
||||||
local client = require("awful.client")
|
local client = require("awful.client")
|
||||||
local layout = require("awful.layout")
|
local layout = require("awful.layout")
|
||||||
|
@ -100,7 +101,9 @@ end
|
||||||
|
|
||||||
--- Place the client without it being outside the screen.
|
--- Place the client without it being outside the screen.
|
||||||
-- @param c The client.
|
-- @param c The client.
|
||||||
|
-- @return The new client geometry.
|
||||||
function no_offscreen(c)
|
function no_offscreen(c)
|
||||||
|
local c = c or capi.client.focus
|
||||||
local geometry = c:geometry()
|
local geometry = c:geometry()
|
||||||
local screen_geometry = capi.screen[c.screen].workarea
|
local screen_geometry = capi.screen[c.screen].workarea
|
||||||
|
|
||||||
|
@ -158,25 +161,29 @@ function no_overlap(c)
|
||||||
new.width = geometry.width
|
new.width = geometry.width
|
||||||
new.height = geometry.height
|
new.height = geometry.height
|
||||||
|
|
||||||
c:geometry(new)
|
return c:geometry(new)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Place the client under the mouse.
|
--- Place the client under the mouse.
|
||||||
-- @param c The client.
|
-- @param c The client.
|
||||||
|
-- @return The new client geometry.
|
||||||
function under_mouse(c)
|
function under_mouse(c)
|
||||||
|
local c = c or capi.client.focus
|
||||||
local c_geometry = c:geometry()
|
local c_geometry = c:geometry()
|
||||||
local m_coords = capi.mouse.coords()
|
local m_coords = capi.mouse.coords()
|
||||||
c:geometry({ x = m_coords.x - c_geometry.width / 2,
|
return c:geometry({ x = m_coords.x - c_geometry.width / 2,
|
||||||
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.
|
--- Place the client centered in the screen.
|
||||||
-- @param c The client.
|
-- @param c The client.
|
||||||
|
-- @return The new client geometry.
|
||||||
function centered(c)
|
function centered(c)
|
||||||
|
local c = c or capi.client.focus
|
||||||
local c_geometry = c:geometry()
|
local c_geometry = c:geometry()
|
||||||
local s_geometry = capi.screen[c.screen].geometry
|
local s_geometry = capi.screen[c.screen].geometry
|
||||||
c:geometry({ x = s_geometry.x + (s_geometry.width - c_geometry.width) / 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 })
|
y = s_geometry.y + (s_geometry.height - c_geometry.height) / 2 })
|
||||||
end
|
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
|
||||||
|
|
Loading…
Reference in New Issue