diff options
-rw-r--r-- | sway/ipc-json.c | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/sway/ipc-json.c b/sway/ipc-json.c index 775fcc24..94768aa4 100644 --- a/sway/ipc-json.c +++ b/sway/ipc-json.c | |||
@@ -454,21 +454,50 @@ json_object *ipc_json_describe_container_recursive(swayc_t *c) { | |||
454 | int i; | 454 | int i; |
455 | 455 | ||
456 | json_object *floating = json_object_new_array(); | 456 | json_object *floating = json_object_new_array(); |
457 | if (c->type != C_VIEW && c->floating && c->floating->length > 0) { | 457 | if (c->type != C_VIEW && c->floating) { |
458 | for (i = 0; i < c->floating->length; ++i) { | 458 | for (i = 0; i < c->floating->length; ++i) { |
459 | json_object_array_add(floating, ipc_json_describe_container_recursive(c->floating->items[i])); | 459 | swayc_t *item = c->floating->items[i]; |
460 | json_object_array_add(floating, ipc_json_describe_container_recursive(item)); | ||
460 | } | 461 | } |
461 | } | 462 | } |
462 | json_object_object_add(object, "floating_nodes", floating); | 463 | json_object_object_add(object, "floating_nodes", floating); |
463 | 464 | ||
464 | json_object *children = json_object_new_array(); | 465 | json_object *children = json_object_new_array(); |
465 | if (c->type != C_VIEW && c->children && c->children->length > 0) { | 466 | if (c->type != C_VIEW && c->children) { |
466 | for (i = 0; i < c->children->length; ++i) { | 467 | for (i = 0; i < c->children->length; ++i) { |
467 | json_object_array_add(children, ipc_json_describe_container_recursive(c->children->items[i])); | 468 | json_object_array_add(children, ipc_json_describe_container_recursive(c->children->items[i])); |
468 | } | 469 | } |
469 | } | 470 | } |
470 | json_object_object_add(object, "nodes", children); | 471 | json_object_object_add(object, "nodes", children); |
471 | 472 | ||
473 | json_object *focus = json_object_new_array(); | ||
474 | if (c->type != C_VIEW) { | ||
475 | if (c->focused) { | ||
476 | json_object_array_add(focus, json_object_new_double(c->focused->id)); | ||
477 | } | ||
478 | if (c->floating) { | ||
479 | for (i = 0; i < c->floating->length; ++i) { | ||
480 | swayc_t *item = c->floating->items[i]; | ||
481 | if (item == c->focused) { | ||
482 | continue; | ||
483 | } | ||
484 | |||
485 | json_object_array_add(focus, json_object_new_double(item->id)); | ||
486 | } | ||
487 | } | ||
488 | if (c->children) { | ||
489 | for (i = 0; i < c->children->length; ++i) { | ||
490 | swayc_t *item = c->children->items[i]; | ||
491 | if (item == c->focused) { | ||
492 | continue; | ||
493 | } | ||
494 | |||
495 | json_object_array_add(focus, json_object_new_double(item->id)); | ||
496 | } | ||
497 | } | ||
498 | } | ||
499 | json_object_object_add(object, "focus", focus); | ||
500 | |||
472 | if (c->type == C_ROOT) { | 501 | if (c->type == C_ROOT) { |
473 | json_object *scratchpad_json = json_object_new_array(); | 502 | json_object *scratchpad_json = json_object_new_array(); |
474 | if (scratchpad->length > 0) { | 503 | if (scratchpad->length > 0) { |