awful.tag.object.set_screen: Cope with screen being nil (#2202)

For "stuff around screen's 'removed' signal", it might make sense to
temporarily set a tags screen to nil. The idea is that it will only
later be assigned to a new screen, not immediately.

However, currently a tag with screen nil causes quite some problems in
the set_screen() function. This commit works around this with a generous
amount of "wrap this in if".

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2018-03-13 03:50:44 +01:00 committed by Emmanuel Lepage Vallée
parent aabff6dac7
commit f9eec13144
1 changed files with 12 additions and 8 deletions

View File

@ -500,7 +500,9 @@ function tag.object.set_screen(t, s)
-- Change the screen
tag.setproperty(t, "screen", s)
if s then
tag.setproperty(t, "index", #s:get_tags(true))
end
-- Make sure the client's screen matches its tags
for _,c in ipairs(t:clients()) do
@ -508,6 +510,7 @@ function tag.object.set_screen(t, s)
c:tags({t})
end
if old_screen then
-- Update all indexes
for i,t2 in ipairs(old_screen.tags) do
tag.setproperty(t2, "index", i)
@ -518,6 +521,7 @@ function tag.object.set_screen(t, s)
tag.history.restore(old_screen, 1)
end
end
end
--- Set a tag's screen
-- @deprecated awful.tag.setscreen