awful.mouse/widget: enable drag'n'dropping clients on tags
Signed-off-by: Gregor Best <farhaven@googlemail.com> Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
2ab78b847d
commit
27e7b4bc9b
|
@ -9,6 +9,7 @@ local layout = require("awful.layout")
|
|||
local tag = require("awful.tag")
|
||||
local hooks = require("awful.hooks")
|
||||
local aclient = require("awful.client")
|
||||
local widget = require("awful.widget")
|
||||
local type = type
|
||||
local math = math
|
||||
local ipairs = ipairs
|
||||
|
@ -158,6 +159,31 @@ function client.move(c, snap)
|
|||
end, "fleur")
|
||||
end
|
||||
|
||||
--- Move a client to a tag by drag'n'dropping it over a taglist widget
|
||||
-- @param c The client to move
|
||||
function client.dragtotag(c)
|
||||
capi.mousegrabber.run(function (mouse)
|
||||
local button_down = false
|
||||
for k, v in ipairs(mouse.buttons) do
|
||||
if v then
|
||||
button_down = true
|
||||
end
|
||||
end
|
||||
if not button_down then
|
||||
local w = widget_under_pointer()
|
||||
if w and widget.taglist.gettag(w) then
|
||||
local t = widget.taglist.gettag(w)
|
||||
if t.screen ~= c.screen then
|
||||
aclient.movetoscreen(c, t.screen)
|
||||
end
|
||||
aclient.movetotag(t, c)
|
||||
end
|
||||
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,
|
||||
|
|
|
@ -33,6 +33,9 @@ taglist.label = {}
|
|||
tasklist = {}
|
||||
tasklist.label = {}
|
||||
|
||||
-- Private structures
|
||||
local tagwidgets = otable()
|
||||
|
||||
local function taglist_update (screen, w, label, buttons, data)
|
||||
local tags = capi.screen[screen]:tags()
|
||||
-- Hack: if it has been registered as a widget in a wibox,
|
||||
|
@ -42,11 +45,14 @@ local function taglist_update (screen, w, label, buttons, data)
|
|||
-- Add more widgets
|
||||
if len < #tags then
|
||||
for i = len + 1, #tags do
|
||||
w[i] = capi.widget({ type = "textbox" })
|
||||
local wi = capi.widget({ type = "textbox" })
|
||||
w[i] = wi
|
||||
tagwidgets[wi] = tags[i]
|
||||
end
|
||||
-- Remove widgets
|
||||
elseif len > #tags then
|
||||
for i = #tags + 1, len do
|
||||
tagwidgets[w[i]] = nil
|
||||
w[i] = nil
|
||||
end
|
||||
end
|
||||
|
@ -74,6 +80,10 @@ local function taglist_update (screen, w, label, buttons, data)
|
|||
end
|
||||
end
|
||||
|
||||
function taglist.gettag(widget)
|
||||
return tagwidgets[widget]
|
||||
end
|
||||
|
||||
--- Create a new taglist widget.
|
||||
-- @param screen The screen to draw tag list for.
|
||||
-- @param label Label function to use.
|
||||
|
|
Loading…
Reference in New Issue