Skip to content

Commit

Permalink
Issue 1399: style refactor Part 4: allow off-screen styling
Browse files Browse the repository at this point in the history
requires new config "offscreen-text", if left empty, no styles are set.
If config "all-outputs" is set, this has no effect.
  • Loading branch information
RobertMueller2 committed Feb 19, 2022
1 parent d859b71 commit 90f60ce
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions src/modules/sway/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,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) {
bool found_visible = false;
for(auto const& node : nodes) {
if (node["output"].isString()) {
output = node["output"].asString();
if (!config_["all-outputs"].asBool() && output != bar_.output->name) {
continue;
}
}
// found node
if (node["focused"].asBool() && (node["type"] == "con" || node["type"] == "floating_con")) {
if ((!config_["all-outputs"].asBool() && output == bar_.output->name) ||
config_["all-outputs"].asBool()) {
if (node["type"] == "con" || node["type"] == "floating_con") {
// found node
if (node["focused"].asBool()) {
spdlog::trace("actual output {}, output found {}, node (focused) found {}", bar_.output->name, output, node["name"].asString());
auto app_id = node["app_id"].isString() ? node["app_id"].asString()
: node["window_properties"]["instance"].asString();
int nb = node.size();
Expand All @@ -154,7 +158,14 @@ std::tuple<std::size_t, int, int, std::string, std::string, std::string> gfnWith
app_id,
workspace_layout};
}
//record visible nodes, but since we don't know if a focused node is yet found, we can't return anything yet
else if (!config_["all-outputs"].asBool() && node["visible"].asBool()) {
spdlog::trace("actual output {}, output found {}, node (visible) found {}", bar_.output->name, output, node["name"].asString());
found_visible=true;
}
}


// iterate
if(node["type"] == "workspace")
parentWorkspace = node;
Expand All @@ -168,6 +179,21 @@ std::tuple<std::size_t, int, int, std::string, std::string, std::string> gfnWith
return {nb, f, id, name, app_id,workspace_layout};
}
}
if (found_visible) {
int tiled_count = 0;
int floating_count = 0;
std::string workspace_layout = "";
if(parentWorkspace != 0) {
std::pair all_leaf_nodes = leafNodesInWorkspace(parentWorkspace);
tiled_count = all_leaf_nodes.first;
floating_count = all_leaf_nodes.second;
if (parentWorkspace["layout"].isString()) {
workspace_layout = parentWorkspace["layout"].asString();
}
}
//using an empty string as default ensures that no window depending styles are set due to the checks above for !name.empty()
return {tiled_count, floating_count, 0, config_["offscreen-text"].isString() ? config_["offscreen-text"].asString() : "", "", workspace_layout};
}
return {0, 0, -1, "", "", ""};
}

Expand Down

0 comments on commit 90f60ce

Please sign in to comment.