As I read the BTS, i saw that Martin posted a comment some time ago in which he
requested moving the client to the previous / next tag if it is moved to the
left / right side of the screen. The attached patch changes
awful.mouse.client.dragtotag() to take a further parameter, called "side",
which if set to true enables this behaviour. If side is either nil or false, a
taglist is used to determine the target tag.

-- 
    Gregor Best
From ece91565ac27e068173fb1858e581bb0fc97c52b Mon Sep 17 00:00:00 2001
From: Gregor Best <[email protected]>
Date: Fri, 12 Dec 2008 21:09:11 +0100
Subject: [PATCH] awful.mouse: make client.dragtotag() move to prev/next tag

Signed-off-by: Gregor Best <[email protected]>
---
 lib/awful/mouse.lua.in |   49 +++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 42 insertions(+), 7 deletions(-)

diff --git a/lib/awful/mouse.lua.in b/lib/awful/mouse.lua.in
index e5c84c0..ddadace 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
@@ -172,8 +173,12 @@ function client.move(c, snap)
 end
 
 --- Move a client to a tag by drag'n'dropping it over a taglist widget
+--- or by dragging it over the far left / right side of a screen to move
+--- it to the tag behind / in front of the current tag. The first behaviour
+--- is the default
 -- @param c The client to move
-function client.dragtotag(c)
+-- @param side Set this to true to enable dragging clients over screen sides
+function client.dragtotag(c, side)
     capi.mousegrabber.run(function (mouse)
                               local button_down = false
                               for k, v in ipairs(mouse.buttons) do
@@ -181,14 +186,44 @@ function client.dragtotag(c)
                                       button_down = true
                                   end
                               end
+                              if side then
+                                  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
+                              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)
+                                  if side then
+                                      local wa = capi.screen[c.screen].workarea
+                                      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
+                                      local newtag
+                                      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
+                                  else
+                                      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
-                                      aclient.movetotag(t, c)
                                   end
                                   return false
                               end
-- 
1.6.0.4

Attachment: signature.asc
Description: PGP signature

Reply via email to