Skip to content

Commit

Permalink
Made the focused check fully recursive
Browse files Browse the repository at this point in the history
  • Loading branch information
bruceblore committed Dec 26, 2024
1 parent 5346649 commit 2dc269f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/modules/sway/workspaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,14 +494,18 @@ std::string Workspaces::trimWorkspaceName(std::string name) {
return name;
}

bool checkFocused(const Json::Value &node) {
return node["focused"].asBool() ||
std::any_of(node["nodes"].begin(), node["nodes"].end(),
[](const auto &child) { return checkFocused(child); });
}

void Workspaces::onButtonReady(const Json::Value &node, Gtk::Button &button) {
if (config_["current-only"].asBool()) {
// If a workspace has a focused container then get_tree will say
// that the workspace itself isn't focused. Therefore we need to
// check if any of its nodes are focused as well.
bool focused = node["focused"].asBool() ||
std::any_of(node["nodes"].begin(), node["nodes"].end(),
[](const auto &child) { return child["focused"].asBool(); });
bool focused = checkFocused(node);

if (focused) {
button.show();
Expand Down

0 comments on commit 2dc269f

Please sign in to comment.