tag: Fix index when screen count change.

There was still a problem that caused the "old" tags to be
inserted in the wrong position when "saved" from a screen being
removed.

Also, this use a :get_tags(true) to save an uneeded sorting pass.
This commit is contained in:
Emmanuel Lepage Vallee 2016-08-28 16:35:47 -04:00
parent 1be737be3a
commit d2988d1aab
1 changed files with 3 additions and 4 deletions

View File

@ -465,6 +465,7 @@ function tag.object.set_screen(t, s)
-- Change the screen -- Change the screen
tag.setproperty(t, "screen", s) tag.setproperty(t, "screen", s)
tag.setproperty(t, "index", #s:get_tags(true))
-- Make sure the client's screen matches its tags -- Make sure the client's screen matches its tags
for _,c in ipairs(t:clients()) do for _,c in ipairs(t:clients()) do
@ -473,10 +474,8 @@ function tag.object.set_screen(t, s)
end end
-- Update all indexes -- Update all indexes
for _,screen in ipairs {old_screen, s} do for i,t2 in ipairs(old_screen.tags) do
for i,t2 in ipairs(screen.tags) do tag.setproperty(t2, "index", i)
tag.setproperty(t2, "index", i)
end
end end
-- Restore the old screen history if the tag was selected -- Restore the old screen history if the tag was selected