awful.mouse: add wibox.move()

Signed-off-by: Gregor Best <farhaven@googlemail.com>
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Gregor Best 2008-12-10 19:57:58 +01:00 committed by Julien Danjou
parent 59c04ce3dc
commit f655e8bcf4
1 changed files with 43 additions and 0 deletions

View File

@ -25,6 +25,7 @@ local capi =
module("awful.mouse")
client = {}
wibox = {}
function client_under_pointer()
local obj = capi.mouse.object_under_pointer()
@ -184,6 +185,48 @@ function client.dragtotag(c)
end, "fleur")
end
--- Move the wibox under the cursor
--@param w The wibox to move, or none to use that under the pointer
function wibox.move(w)
if not w then w = wibox_under_pointer() end
if not w then return end
local offset = {
x = w:geometry()["x"] - capi.mouse.coords()["x"],
y = w:geometry()["y"] - capi.mouse.coords()["y"]
}
capi.mousegrabber.run(function (mouse)
local button_down = false
if w.position == "floating" then
w:geometry({
x = capi.mouse.coords()["x"] + offset["x"],
y = capi.mouse.coords()["y"] + offset["y"],
})
else
local wa = capi.screen[capi.mouse.screen].workarea
if capi.mouse.coords()["y"] > wa.y + wa.height - 10 then
w.position = "bottom"
elseif capi.mouse.coords()["y"] < wa.y + 10 then
w.position = "top"
elseif capi.mouse.coords()["x"] > wa.x + wa.width - 10 then
w.position = "right"
elseif capi.mouse.coords()["x"] < wa.x + 10 then
w.position = "left"
end
w.screen = capi.mouse.screen
end
for k, v in ipairs(mouse.buttons) do
if v then button_down = true end
end
if not button_down then
return false
end
return true
end, "fleur")
end
--- Get a client corner coordinates.
-- @param c The client to get corner from, focused one by default.
-- @param corner The corner to use: auto, top_left, top_right, bottom_left,