On Sat, May 29, 2010 at 08:44:32AM +0200, Uli Schlachter wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> @jd: Please look below
>
> Am 29.05.2010 01:39, Perry Hargrave wrote:
> > tag.move_screen(s, t, ft):
> > + if #o_clients > 0 then
>
> That if serves no purpose, the for loop can handle that case as well.
i have had it in shifty forever thinking why bother instantiating the
next iterator and such in the loop when I can just do an 'if' outside
the loop?
I am not bothered by removing it either. I'm sure the difference is
imperceptible..
>
> This won't work, use {fallback_tag or oscr_tags[1]} instead of do this once at
<insert facepalm here... again>
> the beginning of the function: local fallback_tag = fallback_tag or
> oscr_tags[1]
> Also, what happens if we are moving oscr_tags[1]?
i don't do it at the beginning of the function for this very reason.
if its done after setting
>> origin_tag.screen = nil
then we know
>> oscr_tags[1] ~= origin_tag
no?
>
> I think you found a bug...
>
> If I'm not mistaken, the client will show up on the new screen but it's
> c.screen
> property won't be updated. At least I'm not seeing anything in
> luaA_tag_set_screen() that actually moves the clients to their new screens...
> I'll investigate in the C core once I find the time
>
this is another thing we've always done (since moving tags across
screens) in shifty. clients have never just moved properly. I'm not sure
I would call this a bug, I don't think many people are moving tags
across screens, and this seems an adequate way to update the clients
screen?
if you set a c:tags(<tag that is on another screen>) and don't set
c.screen the client 'disappears'
also attached is fixed of this one.. except i didn't move the
fallback_tag to the top of the function for the reason i said above.
what do you think?
--
perry
>From 091859e9a149e71ea6526f8346d0317e5e9377b4 Mon Sep 17 00:00:00 2001
From: Perry Hargrave <[email protected]>
Date: Fri, 28 May 2010 12:58:29 -0700
Subject: [PATCH 5/5] tag.lua: move_screen() moves tag to another screen
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 | 38 ++++++++++++++++++++++++++++++++++++++
1 files changed, 38 insertions(+), 0 deletions(-)
diff --git a/lib/awful/tag.lua.in b/lib/awful/tag.lua.in
index 605cfa6..9abfa0f 100644
--- a/lib/awful/tag.lua.in
+++ b/lib/awful/tag.lua.in
@@ -119,6 +119,44 @@ 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()
+ 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
+ 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