tag.move_screen(s, t, ft):
Move a tag 't', or selected(), from its current screen to 's'. If
any non-stickied clients are present then move those also.
Stickied clients are assigned a fallback tag 'ft' or
screen[]:tags()[1].
If no tags exist on the originating screen then the stickied client
is moved to the target screen as well.
Signed-off-by: Perry Hargrave <[email protected]>
---
lib/awful/tag.lua.in | 40 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 40 insertions(+), 0 deletions(-)
diff --git a/lib/awful/tag.lua.in b/lib/awful/tag.lua.in
index 9046eda..8b0f7c9 100644
--- a/lib/awful/tag.lua.in
+++ b/lib/awful/tag.lua.in
@@ -104,6 +104,46 @@ 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. integer
+-- @param origin_tag The tag you want to move. tag object [selected()]
+-- @param fallback_tag Tag to apply to stickied clients. [screen:tags[1]]
+-- @return The tag moved or nil
+function move_screen(target_screen, origin_tag, fallback_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 origination
+ -- 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
+
+ local oscr_tags = capi.screen[origin_screen]:tags()
+
+ origin_tag.screen = nil
+
+ -- set screen for clients (except sticky ones)
+ -- toggle the tag off for sticky clients
+ o_clients = origin_tag:clients()
+ if #o_clients > 0 then
+ for _, c in ipairs(o_clients) do
+ if not c.sticky or (c.sticky and #oscr_tags < 2) then
+ c.screen = target_screen
+ c:tags({origin_tag})
+ else
+ c:tags({fallback_tag} or {oscr_tags[1]})
+ end
+ end
+ end
+ origin_tag.screen = target_screen
+ return origin_tag
+end
+
--- Create a set of tags and attach it to a screen.
-- @param names The tag name, in a table
-- @param screen The tag screen, or 1 if not set.
--
1.7.1
--
To unsubscribe, send mail to [email protected].