pull/2617/head
Rehan 2023-10-28 00:03:26 -04:00
parent dc208b66b3
commit 8606fb644f
2 changed files with 39 additions and 0 deletions

View File

@ -194,6 +194,8 @@ class Workspaces : public AModule, public EventHandler {
std::vector<WindowCreationPayload> m_windowsToCreate; std::vector<WindowCreationPayload> m_windowsToCreate;
std::vector<std::regex> m_ignoreWorkspaces; std::vector<std::regex> m_ignoreWorkspaces;
std::vector<int> exclude_persistence_point_;
std::vector<int> prune_past_persistence_point_;
std::mutex m_mutex; std::mutex m_mutex;
const Bar& m_bar; const Bar& m_bar;

View File

@ -127,6 +127,20 @@ auto Workspaces::parseConfig(const Json::Value &config) -> void {
m_windowRewriteRules = util::RegexCollection( m_windowRewriteRules = util::RegexCollection(
windowRewrite, windowRewriteDefault, windowRewrite, windowRewriteDefault,
[this](std::string &window_rule) { return windowRewritePriorityFunction(window_rule); }); [this](std::string &window_rule) { return windowRewritePriorityFunction(window_rule); });
Json::Value exclude_persistence_point = config["exclude-persistence-point"];
if (exclude_persistence_point.isArray()) {
for (Json::Value &ws_id : exclude_persistence_point) {
if (ws_id.isInt()) exclude_persistence_point_.emplace_back(ws_id.asInt());
}
}
Json::Value prune_past_persistence_point = config["prune-past-persistence-point"];
if (prune_past_persistence_point.isArray()) {
for (Json::Value &ws_id : prune_past_persistence_point) {
if (ws_id.isInt()) prune_past_persistence_point_.emplace_back(ws_id.asInt());
}
}
} }
auto Workspaces::registerIpc() -> void { auto Workspaces::registerIpc() -> void {
@ -179,7 +193,19 @@ auto Workspaces::update() -> void {
visibleWorkspaces.push_back(ws["name"].asString()); visibleWorkspaces.push_back(ws["name"].asString());
} }
} }
int persist_point = -1;
if (!prune_past_persistence_point_.empty()) {
for (int i = m_workspaces.size() - 1; i >= 0; i--) {
if ((!m_workspaces[i]->isEmpty() || m_workspaces[i]->isActive() || m_workspaces[i]->isVisible()) &&
!m_workspaces[i]->name().starts_with("special") &&
std::find(exclude_persistence_point_.begin(), exclude_persistence_point_.end(), m_workspaces[i]->id()) == exclude_persistence_point_.end()) {
persist_point = i;
break;
}
}
}
int i = 0;
for (auto &workspace : m_workspaces) { for (auto &workspace : m_workspaces) {
// active // active
workspace->setActive(workspace->name() == m_activeWorkspaceName); workspace->setActive(workspace->name() == m_activeWorkspaceName);
@ -198,6 +224,15 @@ auto Workspaces::update() -> void {
workspaceIcon = workspace->selectIcon(m_iconsMap); workspaceIcon = workspace->selectIcon(m_iconsMap);
} }
workspace->update(m_format, workspaceIcon); workspace->update(m_format, workspaceIcon);
if (!prune_past_persistence_point_.empty() &&
workspace->isPersistent() &&
i > persist_point &&
std::find(prune_past_persistence_point_.begin(), prune_past_persistence_point_.end(), m_workspaces[i]->id()) != prune_past_persistence_point_.end()) {
workspace->button().hide();
}
i++;
} }
bool anyWindowCreated = false; bool anyWindowCreated = false;
@ -637,6 +672,8 @@ void Workspaces::init() {
sortWorkspaces(); sortWorkspaces();
update();
dp.emit(); dp.emit();
} }