From 975aac5c0ca592cf3487140b19f159e6cc1e335e Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sun, 1 May 2016 19:41:40 +0200 Subject: [PATCH] awful.tag: Delete a screen's tag on removal Any clients with these tags end up somewhere random (the first tag on the first remaining screen). This certainly can be improved in the future, but at least this is a start. Signed-off-by: Uli Schlachter --- lib/awful/tag.lua | 24 ++++++++++++++++++++++++ tests/examples/shims/screen.lua | 2 ++ 2 files changed, 26 insertions(+) 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