At Mon, 8 Dec 2008 10:00:49 +0100 Julien Danjou wrote: > Please, be careful at this kind of detail, it's annoying. :) >
D'oh! I should've git diff'ed that, sorry :)
> > + hooks.timer.register(0.001, ud)
>
> No, I won't accept that. I've no idea why you use this but if you
> need, find another way. :)
>
Mmh, weird, at first I though there was an absolute need for setting the mouse
geometry via a hook... No idea where that came from, but without it works fine,
a patch is attached :)
--
Gregor Best
From 9912a331cb43a10e8f9e7cd7bd071ecb8119bae6 Mon Sep 17 00:00:00 2001
From: Gregor Best <[EMAIL PROTECTED]>
Date: Mon, 8 Dec 2008 19:56:00 +0100
Subject: [PATCH] awful.mouse/widget: enable drag'n'dropping clients on tags
Signed-off-by: Gregor Best <[EMAIL PROTECTED]>
---
lib/awful/mouse.lua.in | 37 ++++++++++++++++++++++++++++++++-----
lib/awful/widget.lua.in | 16 +++++++++++++---
2 files changed, 45 insertions(+), 8 deletions(-)
diff --git a/lib/awful/mouse.lua.in b/lib/awful/mouse.lua.in
index d840410..fdce542 100644
--- a/lib/awful/mouse.lua.in
+++ b/lib/awful/mouse.lua.in
@@ -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
@@ -82,7 +83,7 @@ end
function client.snap(c, snap, x, y)
local snap = snap or 8
local c = c or client.focus
- local geom = c:fullgeometry()
+ local geom = c:geometry()
geom.x = x or geom.x
geom.y = y or geom.y
@@ -91,7 +92,7 @@ function client.snap(c, snap, x, y)
for k, snapper in ipairs(aclient.visible(c.screen)) do
if snapper ~= c then
- geom = snap_outside(geom, snapper:fullgeometry(), snap)
+ geom = snap_outside(geom, snapper:geometry(), snap)
end
end
return geom
@@ -114,14 +115,14 @@ function client.move(c, snap)
c:raise()
- local orig = c:fullgeometry()
+ local orig = c:geometry()
local m_c = capi.mouse.coords()
local dist_x = m_c.x - orig.x
local dist_y = m_c.y - orig.y
local function ug(c, prop)
if prop == "geometry" then
- local g = c:fullgeometry()
+ local g = c:geometry()
capi.mouse.coords({ x = g.x + dist_x, y = g.y + dist_y })
end
end
@@ -134,7 +135,7 @@ function client.move(c, snap)
if lay == layout.suit.floating or aclient.floating.get(c) then
local x = mouse.x - dist_x
local y = mouse.y - dist_y
- c:fullgeometry(client.snap(c, snap, x, y))
+ c:geometry(client.snap(c, snap, x, y))
if layout.get(c.screen) ~= layout.suit.floating and not aclient.floating.get(c) then
hooks.property.register(ug)
end
@@ -158,6 +159,32 @@ 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)
+ local m_c = capi.mouse.coords()
+ local dist_x = 0
+ local dist_y = 0
+
+ capi.mousegrabber.run(function (mouse)
+ local button_down = false
+ for k, v in ipairs(mouse.buttons) do
+ if v then
+ button_down = true
+ dist_x = mouse.x - dist_x
+ dist_y = mouse.y - dist_y
+ end
+ end
+ if not button_down then
+ local w = widget_under_pointer()
+ if w and widget.taglist.gettag(w) then
+ aclient.movetotag(widget.taglist.gettag(w), 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,
diff --git a/lib/awful/widget.lua.in b/lib/awful/widget.lua.in
index ae3f72e..063866f 100644
--- a/lib/awful/widget.lua.in
+++ b/lib/awful/widget.lua.in
@@ -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", name = "taglist" .. i })
+ 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.
@@ -202,8 +212,8 @@ local function tasklist_update(w, buttons, label, data)
-- Add more widgets
if len < #clients then
for i = len * 2 + 1, #clients * 2, 2 do
- w[i] = capi.widget({ type = "imagebox", align = "flex" })
- w[i + 1] = capi.widget({ type = "textbox", align = "flex" })
+ w[i] = capi.widget({ type = "imagebox", name = "tasklist_icon" .. i, align = "flex" })
+ w[i + 1] = capi.widget({ type = "textbox", name = "tasklist_text" .. i, align = "flex" })
w[i + 1]:margin({ left = 2, right = 2 })
w[i + 1].bg_resize = true
w[i + 1].bg_align = "right"
--
1.6.0.4
signature.asc
Description: PGP signature
