@@ -126,14 +126,18 @@ std::pair<int, int> leafNodesInWorkspace(const Json::Value& node) {
126
126
std::tuple<std::size_t , int , int , std::string, std::string, std::string> gfnWithWorkspace (
127
127
const Json::Value& nodes, std::string& output, const Json::Value& config_,
128
128
const Bar& bar_, Json::Value& parentWorkspace) {
129
+ bool found_visible = false ;
129
130
for (auto const & node : nodes) {
130
131
if (node[" output" ].isString ()) {
131
132
output = node[" output" ].asString ();
133
+ if (!config_[" all-outputs" ].asBool () && output != bar_.output ->name ) {
134
+ continue ;
135
+ }
132
136
}
133
- // found node
134
- if (node[ " focused " ]. asBool () && (node[ " type " ] == " con " || node[ " type " ] == " floating_con " )) {
135
- if ((!config_[ " all-outputs " ].asBool () && output == bar_. output -> name ) ||
136
- config_[ " all-outputs " ]. asBool ()) {
137
+ if (node[ " type " ] == " con " || node[ " type " ] == " floating_con " ) {
138
+ // found node
139
+ if (node[ " focused " ].asBool ()) {
140
+ spdlog::trace ( " actual output {}, output found {}, node (focused) found {} " , bar_. output -> name , output, node[ " name " ]. asString ());
137
141
auto app_id = node[" app_id" ].isString () ? node[" app_id" ].asString ()
138
142
: node[" window_properties" ][" instance" ].asString ();
139
143
int nb = node.size ();
@@ -154,7 +158,14 @@ std::tuple<std::size_t, int, int, std::string, std::string, std::string> gfnWith
154
158
app_id,
155
159
workspace_layout};
156
160
}
161
+ // record visible nodes, but since we don't know if a focused node is yet found, we can't return anything yet
162
+ else if (!config_[" all-outputs" ].asBool () && node[" visible" ].asBool ()) {
163
+ spdlog::trace (" actual output {}, output found {}, node (visible) found {}" , bar_.output ->name , output, node[" name" ].asString ());
164
+ found_visible=true ;
165
+ }
157
166
}
167
+
168
+
158
169
// iterate
159
170
if (node[" type" ] == " workspace" )
160
171
parentWorkspace = node;
@@ -168,6 +179,21 @@ std::tuple<std::size_t, int, int, std::string, std::string, std::string> gfnWith
168
179
return {nb, f, id, name, app_id,workspace_layout};
169
180
}
170
181
}
182
+ if (found_visible) {
183
+ int tiled_count = 0 ;
184
+ int floating_count = 0 ;
185
+ std::string workspace_layout = " " ;
186
+ if (parentWorkspace != 0 ) {
187
+ std::pair all_leaf_nodes = leafNodesInWorkspace (parentWorkspace);
188
+ tiled_count = all_leaf_nodes.first ;
189
+ floating_count = all_leaf_nodes.second ;
190
+ if (parentWorkspace[" layout" ].isString ()) {
191
+ workspace_layout = parentWorkspace[" layout" ].asString ();
192
+ }
193
+ }
194
+ // using an empty string as default ensures that no window depending styles are set due to the checks above for !name.empty()
195
+ return {tiled_count, floating_count, 0 , config_[" offscreen-text" ].isString () ? config_[" offscreen-text" ].asString () : " " , " " , workspace_layout};
196
+ }
171
197
return {0 , 0 , -1 , " " , " " , " " };
172
198
}
173
199
0 commit comments