The attached patch splits awful.mouse.client.dragtotag into awful.mouse.client.dragtotag.widget for the regular target selection by dragging the client over a taglist and awful.mouse.client.dragtotag.border for selecting the target tag by dragging the client over a screen border.
--
Gregor Best
From 2d8a06918859f670c6a6db48b45f54b8cd7b780c Mon Sep 17 00:00:00 2001 From: Gregor Best <[email protected]> Date: Sun, 14 Dec 2008 14:38:48 +0100 Subject: [PATCH] awful.mouse: split client.dragtotag into .widget and .border Signed-off-by: Gregor Best <[email protected]> --- lib/awful/mouse.lua.in | 49 +++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 44 insertions(+), 5 deletions(-) diff --git a/lib/awful/mouse.lua.in b/lib/awful/mouse.lua.in index e5c84c0..4390506 100644 --- a/lib/awful/mouse.lua.in +++ b/lib/awful/mouse.lua.in @@ -10,6 +10,7 @@ local tag = require("awful.tag") local hooks = require("awful.hooks") local aclient = require("awful.client") local widget = require("awful.widget") +local util = require("awful.util") local type = type local math = math local ipairs = ipairs @@ -171,15 +172,15 @@ function client.move(c, snap) end, "fleur") end +client.dragtotag = { } + --- 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) +function client.dragtotag.widget(c, side) capi.mousegrabber.run(function (mouse) local button_down = false - for k, v in ipairs(mouse.buttons) do - if v then - button_down = true - end + for _, v in ipairs(mouse.buttons) do + if v then button_down = true end end if not button_down then local w = widget_under_pointer() @@ -196,6 +197,44 @@ function client.dragtotag(c) end, "fleur") end +--- Move a client to a tag by dragging it onto the left / right side of the screen +-- @param c The client to move +function client.dragtotag.border(c) + capi.mousegrabber.run(function (mouse) + local button_down = false + for _, v in ipairs(mouse.buttons) do + if v then button_down = true end + end + local wa = capi.screen[c.screen].workarea + if mouse.x >= wa.x + wa.width then + capi.mouse.coords({ x = wa.x + wa.width - 1 }) + elseif mouse.x <= wa.x then + capi.mouse.coords({ x = wa.x + 1 }) + end + if not button_down then + local tags = capi.screen[c.screen]:tags() + local t = tag.selected() + local idx + for i, v in ipairs(tags) do + if v == t then + idx = i + end + end + if mouse.x > wa.x + wa.width - 10 then + local newtag = tags[util.cycle(#tags, idx + 1)] + aclient.movetotag(newtag, c) + tag.viewnext() + elseif mouse.x < wa.x + 10 then + local newtag = tags[util.cycle(#tags, idx - 1)] + aclient.movetotag(newtag, c) + tag.viewprev() + end + return false + end + return true + 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) -- 1.6.0.4
signature.asc
Description: PGP signature
