Skip to content

Commit

Permalink
added extendOrphans
Browse files Browse the repository at this point in the history
  • Loading branch information
zjeffer committed Feb 11, 2024
1 parent 157c622 commit e4b6d6d
Showing 1 changed file with 25 additions and 10 deletions.
35 changes: 25 additions & 10 deletions src/modules/hyprland/workspaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,22 +331,26 @@ void Workspaces::onWorkspaceCreated(std::string const &workspaceName,
auto const workspaceRules = gIPC->getSocket1JsonReply("workspacerules");
for (Json::Value workspaceJson : workspacesJson) {
std::string name = workspaceJson["name"].asString();
if (name == workspaceName &&
(allOutputs() || m_bar.output->name == workspaceJson["monitor"].asString()) &&
(showSpecial() || !name.starts_with("special")) && !isDoubleSpecial(workspaceName)) {
for (Json::Value const &rule : workspaceRules) {
if (rule["workspaceString"].asString() == workspaceName) {
workspaceJson["persistent"] = rule["persistent"].asBool();
break;
if (name == workspaceName) {
if ((allOutputs() || m_bar.output->name == workspaceJson["monitor"].asString()) &&
(showSpecial() || !name.starts_with("special")) && !isDoubleSpecial(workspaceName)) {
for (Json::Value const &rule : workspaceRules) {
if (rule["workspaceString"].asString() == workspaceName) {
workspaceJson["persistent"] = rule["persistent"].asBool();
break;
}
}
}

m_workspacesToCreate.emplace_back(workspaceJson, clientsData);
m_workspacesToCreate.emplace_back(workspaceJson, clientsData);
break;
}
} else {
extendOrphans(workspaceJson["id"].asInt(), clientsData);
break;
}
}
} else {
spdlog::debug("Not creating workspace because it is ignored: {}", workspaceName);
spdlog::trace("Not creating workspace because it is ignored: {}", workspaceName);
}
}

Expand Down Expand Up @@ -734,6 +738,8 @@ void Workspaces::initializeWorkspaces() {
(!workspaceName.starts_with("special") || showSpecial()) &&
!isWorkspaceIgnored(workspaceName)) {
m_workspacesToCreate.emplace_back(workspaceJson, clientsJson);
} else {
extendOrphans(workspaceJson["id"].asInt(), clientsJson);
}
}

Expand All @@ -747,6 +753,15 @@ void Workspaces::initializeWorkspaces() {
}
}

void Workspaces::extendOrphans(int workspaceId, Json::Value const &clientsJson) {
spdlog::trace("Extending orphans with workspace {}", workspaceId);
for (const auto &client : clientsJson) {
if (client["workspace"]["id"].asInt() == workspaceId) {
registerOrphanWindow({client});
}
}
}

void Workspaces::init() {
m_activeWorkspaceName = (gIPC->getSocket1JsonReply("activeworkspace"))["name"].asString();

Expand Down

0 comments on commit e4b6d6d

Please sign in to comment.