fix tags being orphaned by screen disconnect

In the case where the primary screen is the one that
will be removed, the salvage function will not successfully
salvage the shared tag, resulting in being unable to retrieve
it in new screens.

Introduce additional fallback logic to find a suitable screen
to move to when salvaging.
This commit is contained in:
Yusuke Tsutsumi 2021-11-26 23:32:48 -08:00
parent 9cf8f90004
commit 096114a7ef
1 changed files with 7 additions and 0 deletions

View File

@ -44,6 +44,13 @@ local sharedtags = {
local function salvage(tag)
-- The screen to move the orphaned tag to.
local newscreen = capi.screen.primary
-- the primary screen may be the one that is being
-- removed, so try to find a different screen if possible.
for s in capi.screen do
if s ~= tag.screen then
newscreen = s
end
end
-- Make sure the tag isn't selected when moved to the new screen.
tag.selected = false