feat(hyprland): support createworkspacev2
This commit is contained in:
committed by
Matthew White
parent
8490a1d9b9
commit
26a344b131
@ -322,7 +322,7 @@ void Workspaces::onEvent(const std::string &ev) {
|
|||||||
onSpecialWorkspaceActivated(payload);
|
onSpecialWorkspaceActivated(payload);
|
||||||
} else if (eventName == "destroyworkspace") {
|
} else if (eventName == "destroyworkspace") {
|
||||||
onWorkspaceDestroyed(payload);
|
onWorkspaceDestroyed(payload);
|
||||||
} else if (eventName == "createworkspace") {
|
} else if (eventName == "createworkspacev2") {
|
||||||
onWorkspaceCreated(payload);
|
onWorkspaceCreated(payload);
|
||||||
} else if (eventName == "focusedmon") {
|
} else if (eventName == "focusedmon") {
|
||||||
onMonitorFocused(payload);
|
onMonitorFocused(payload);
|
||||||
@ -362,18 +362,31 @@ void Workspaces::onWorkspaceDestroyed(std::string const &payload) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Workspaces::onWorkspaceCreated(std::string const &workspaceName,
|
void Workspaces::onWorkspaceCreated(std::string const &payload,
|
||||||
Json::Value const &clientsData) {
|
Json::Value const &clientsData) {
|
||||||
spdlog::debug("Workspace created: {}", workspaceName);
|
spdlog::debug("Workspace created: {}", payload);
|
||||||
auto const workspacesJson = m_ipc.getSocket1JsonReply("workspaces");
|
std::string workspaceIdStr = payload.substr(0, payload.find(','));
|
||||||
|
std::string workspaceName = payload.substr(workspaceIdStr.size() + 1);
|
||||||
|
int workspaceId = std::stoi(workspaceIdStr);
|
||||||
|
|
||||||
if (!isWorkspaceIgnored(workspaceName)) {
|
auto const workspacesJson = gIPC->getSocket1JsonReply("workspaces");
|
||||||
auto const workspaceRules = m_ipc.getSocket1JsonReply("workspacerules");
|
|
||||||
|
auto workspaceIgnored = isWorkspaceIgnored(workspaceName);
|
||||||
|
if (!workspaceIgnored) {
|
||||||
|
auto const workspaceRules = gIPC->getSocket1JsonReply("workspacerules");
|
||||||
for (Json::Value workspaceJson : workspacesJson) {
|
for (Json::Value workspaceJson : workspacesJson) {
|
||||||
std::string name = workspaceJson["name"].asString();
|
int currentId = workspaceJson["id"].asInt();
|
||||||
if (name == workspaceName) {
|
std::string currentName = workspaceJson["name"].asString();
|
||||||
|
if (currentId == workspaceId) {
|
||||||
|
// The workspace may have been renamed since creation
|
||||||
|
// Check if the configured ignore rules apply to the new name
|
||||||
|
workspaceIgnored = isWorkspaceIgnored(currentName);
|
||||||
|
if (workspaceIgnored) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if ((allOutputs() || m_bar.output->name == workspaceJson["monitor"].asString()) &&
|
if ((allOutputs() || m_bar.output->name == workspaceJson["monitor"].asString()) &&
|
||||||
(showSpecial() || !name.starts_with("special")) && !isDoubleSpecial(workspaceName)) {
|
(showSpecial() || !currentName.starts_with("special")) && !isDoubleSpecial(currentName)) {
|
||||||
for (Json::Value const &rule : workspaceRules) {
|
for (Json::Value const &rule : workspaceRules) {
|
||||||
auto ruleWorkspaceName = rule.isMember("defaultName")
|
auto ruleWorkspaceName = rule.isMember("defaultName")
|
||||||
? rule["defaultName"].asString()
|
? rule["defaultName"].asString()
|
||||||
@ -388,11 +401,13 @@ void Workspaces::onWorkspaceCreated(std::string const &workspaceName,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
extendOrphans(workspaceJson["id"].asInt(), clientsData);
|
extendOrphans(workspaceId, clientsData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
spdlog::trace("Not creating workspace because it is ignored: {}", workspaceName);
|
if (workspaceIgnored) {
|
||||||
|
spdlog::trace("Not creating workspace because it is ignored: id={} name={}", workspaceId,
|
||||||
|
workspaceName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user