Merge pull request #3001 from grimpy/fixpersitantworkspaces

Fix peristant workspaces for sway
This commit is contained in:
Alexis Rouillard 2024-03-12 14:22:18 +01:00 committed by GitHub
commit 214858f413
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 7 deletions

View File

@ -141,12 +141,12 @@ void Workspaces::onCmd(const struct Ipc::ipc_response &res) {
for (const std::string &p_w_name : p_workspaces_names) { for (const std::string &p_w_name : p_workspaces_names) {
const Json::Value &p_w = p_workspaces[p_w_name]; const Json::Value &p_w = p_workspaces[p_w_name];
auto it = auto it = std::find_if(workspaces_.begin(), workspaces_.end(),
std::find_if(payload.begin(), payload.end(), [&p_w_name](const Json::Value &node) { [&p_w_name](const Json::Value &node) {
return node["name"].asString() == p_w_name; return node["name"].asString() == p_w_name;
}); });
if (it != payload.end()) { if (it != workspaces_.end()) {
continue; // already displayed by some bar continue; // already displayed by some bar
} }
@ -156,7 +156,7 @@ void Workspaces::onCmd(const struct Ipc::ipc_response &res) {
if (output.asString() == bar_.output->name) { if (output.asString() == bar_.output->name) {
Json::Value v; Json::Value v;
v["name"] = p_w_name; v["name"] = p_w_name;
v["target_output"] = bar_.output->name; v["output"] = bar_.output->name;
v["num"] = convertWorkspaceNameToNum(p_w_name); v["num"] = convertWorkspaceNameToNum(p_w_name);
workspaces_.emplace_back(std::move(v)); workspaces_.emplace_back(std::move(v));
break; break;
@ -166,7 +166,7 @@ void Workspaces::onCmd(const struct Ipc::ipc_response &res) {
// Adding to all outputs // Adding to all outputs
Json::Value v; Json::Value v;
v["name"] = p_w_name; v["name"] = p_w_name;
v["target_output"] = ""; v["output"] = "";
v["num"] = convertWorkspaceNameToNum(p_w_name); v["num"] = convertWorkspaceNameToNum(p_w_name);
workspaces_.emplace_back(std::move(v)); workspaces_.emplace_back(std::move(v));
} }
@ -250,6 +250,9 @@ bool Workspaces::filterButtons() {
} }
bool Workspaces::hasFlag(const Json::Value &node, const std::string &flag) { bool Workspaces::hasFlag(const Json::Value &node, const std::string &flag) {
if (!node[flag].isBool()) {
return false;
}
if (node[flag].asBool()) { if (node[flag].asBool()) {
return true; return true;
} }