Skip to content

Commit

Permalink
Issue 1399: use parent node instead of filterWorkspace
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertMueller2 committed Apr 2, 2022
1 parent d999b5f commit 5868f76
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/modules/sway/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,22 +188,18 @@ std::pair<int, int> leafNodesInWorkspace(const Json::Value& node) {

std::tuple<std::size_t, int, int, std::string, std::string, std::string> gfnWithWorkspace(
const Json::Value& nodes, std::string& output, const Json::Value& config_,
const Bar& bar_, Json::Value& parentWorkspace, Json::Value& filterWorkspace, const Json::Value& immediateParent) {
const Bar& bar_, Json::Value& parentWorkspace, const Json::Value& immediateParent) {
bool found_visible = false;
for(auto const& node : nodes) {
if (node["type"].asString() == "output") {
if (!config_["all-outputs"].asBool() && node["name"].asString() != bar_.output->name) {
continue;
}
filterWorkspace = node["current_workspace"];
output = node["name"].asString();
}
else if(node["type"].asString() == "workspace") {
if (!filterWorkspace.isString()) {
continue;
}
// needs to be a string comparison, because filterWorkspace is the current_workspace
if (node["name"].asString() != filterWorkspace.asString()) {
if (node["name"].asString() != immediateParent["current_workspace"].asString()) {
continue;
}
parentWorkspace = node;
Expand Down Expand Up @@ -239,8 +235,8 @@ std::tuple<std::size_t, int, int, std::string, std::string, std::string> gfnWith
}

// iterate
auto [nb, f, id, name, app_id, workspace_layout] = gfnWithWorkspace(node["nodes"], output, config_, bar_, parentWorkspace, filterWorkspace, node);
auto [nb2, f2, id2, name2, app_id2, workspace_layout2] = gfnWithWorkspace(node["floating_nodes"], output, config_, bar_, parentWorkspace, filterWorkspace, node);
auto [nb, f, id, name, app_id, workspace_layout] = gfnWithWorkspace(node["nodes"], output, config_, bar_, parentWorkspace, node);
auto [nb2, f2, id2, name2, app_id2, workspace_layout2] = gfnWithWorkspace(node["floating_nodes"], output, config_, bar_, parentWorkspace, node);

if ((id > 0 || ((id2 < 0 || name2.empty()) && id > -1)) && !name.empty()) {
return {nb, f, id, name, app_id, workspace_layout};
Expand Down Expand Up @@ -271,7 +267,7 @@ std::tuple<std::size_t, int, int, std::string, std::string, std::string> gfnWith
std::tuple<std::size_t, int, int, std::string, std::string, std::string> Window::getFocusedNode(
const Json::Value& nodes, std::string& output) {
Json::Value placeholder = 0;
return gfnWithWorkspace(nodes, output, config_, bar_, placeholder, placeholder, placeholder);
return gfnWithWorkspace(nodes, output, config_, bar_, placeholder, placeholder);
}

void Window::getTree() {
Expand Down

0 comments on commit 5868f76

Please sign in to comment.