Skip to content

Commit

Permalink
Handle floating sway windows
Browse files Browse the repository at this point in the history
Signed-off-by: Artem Senichev <[email protected]>
  • Loading branch information
artemsen committed Feb 10, 2024
1 parent 5abec66 commit 6ab8d2c
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/sway.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,20 +225,24 @@ static struct json_object* current_workspace(json_object* node)
*/
static struct json_object* current_window(json_object* node)
{
static const char* nnames[] = { "nodes", "floating_nodes" };

struct json_object* focused;
if (json_object_object_get_ex(node, "focused", &focused) &&
json_object_get_boolean(focused)) {
return node;
}

struct json_object* nodes;
if (json_object_object_get_ex(node, "nodes", &nodes)) {
int idx = json_object_array_length(nodes);
while (--idx >= 0) {
struct json_object* sub = json_object_array_get_idx(nodes, idx);
struct json_object* focus = current_window(sub);
if (focus) {
return focus;
for (size_t i = 0; i < sizeof(nnames) / sizeof(nnames[0]); ++i) {
struct json_object* nodes;
if (json_object_object_get_ex(node, nnames[i], &nodes)) {
int idx = json_object_array_length(nodes);
while (--idx >= 0) {
struct json_object* sub = json_object_array_get_idx(nodes, idx);
struct json_object* focus = current_window(sub);
if (focus) {
return focus;
}
}
}
}
Expand Down

0 comments on commit 6ab8d2c

Please sign in to comment.