diff --git a/lib/awful/tag.lua b/lib/awful/tag.lua index a4a45510..331b0deb 100644 --- a/lib/awful/tag.lua +++ b/lib/awful/tag.lua @@ -1352,11 +1352,35 @@ capi.tag.add_signal("property::urgent") capi.tag.add_signal("property::urgent_count") capi.tag.add_signal("property::volatile") +capi.tag.add_signal("removal-pending") capi.screen.add_signal("tag::history::update") capi.screen.connect_signal("tag::history::update", tag.history.update) +capi.screen.connect_signal("removed", function(s) + -- First give other code a chance to clean up + for _, t in pairs(s.tags) do + t:emit_signal("removal-pending") + end + -- Then force all clients left to go somewhere random + local fallback = nil + for other_screen in capi.screen do + if #other_screen.tags > 0 then + fallback = other_screen.tags[1] + break + end + end + for _, t in pairs(s.tags) do + t:delete(fallback, true) + end + -- If any tag survived until now, forcefully get rid of it + for _, t in pairs(s.tags) do + t.activated = false + data.tags[t] = nil + end +end) + function tag.mt:__call(...) return tag.new(...) end diff --git a/tests/examples/shims/screen.lua b/tests/examples/shims/screen.lua index a0d4eb6b..ca36a063 100644 --- a/tests/examples/shims/screen.lua +++ b/tests/examples/shims/screen.lua @@ -100,6 +100,8 @@ end screen._add_screen {width=320, height=240} screen.add_signal("property::workarea") +screen.add_signal("added") +screen.add_signal("removed") return screen