Fix peristant workspaces for sway

Fixes: #2998

Signed-off-by: Jo De Boeck <deboeck.jo@gmail.com>
This commit is contained in:
Jo De Boeck 2024-03-12 00:09:47 +02:00
parent 380607583e
commit 7b3d155608
No known key found for this signature in database
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;
} }