awful.tag.move_screen(target_screen, origin_tag):
    moves a tag and its non-stickied clients to the screen
    'target_screen'
    stickied clients are left on the original screen
---
 lib/awful/tag.lua.in |   42 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/lib/awful/tag.lua.in b/lib/awful/tag.lua.in
index 6d03add..99bc382 100644
--- a/lib/awful/tag.lua.in
+++ b/lib/awful/tag.lua.in
@@ -101,6 +101,48 @@ function move(new_index, target_tag)
     capi.screen[scr]:tags(tmp_tags)
 end
 
+--- Move a tag to another screen, along with any clients except sticky ones
+-- @param target_screen The screen number to move TO, an integer
+-- @param origin_tag Optional tag you want to move, tag object [selected()]
+-- @return The tag moved or nil
+function move_screen(target_screen, origin_tag)
+    if target_screen < 1 or
+        target_screen > capi.screen.count() then return end
+
+    -- make sure we have a tag to operate on, then get its original
+    -- screen for assigning tags to sticky clients later
+    local origin_tag = origin_tag or selected()
+    local origin_screen
+    if origin_tag then
+        origin_screen = origin_tag.screen
+    else
+        return
+    end
+
+    history.restore(origin_screen)
+
+    origin_tag.screen = nil
+
+    -- set screen for clients except for sticky ones toggle the tag off
+    -- but leave them on the original screen
+    origin_screen_tags = capi.screen[origin_screen]:tags()
+
+    if #origin_tag:clients() > 0 then
+        for _, c in ipairs(origin_tag:clients()) do
+            if not c.sticky then
+                c.screen = target_screen
+                c:tags({origin_tag})
+            else
+                c:tags(origin_screen_tags)
+            end
+        end
+    end
+    origin_tag.screen = target_screen
+    capi.screen[origin_screen]:emit_signal("tag::history::update")
+    capi.screen[target_screen]:emit_signal("tag::history::update")
+    return origin_tag
+end
+
 --- Delete a tag
 -- @param target_tag Optional tag object to delete, [tag.selected()]
 function delete(target_tag)
-- 
1.7.0.1


-- 
To unsubscribe, send mail to awesome-devel-unsubscr...@naquadah.org.

Reply via email to