aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar lbonn <bonnans.l@gmail.com>2017-10-08 00:00:53 +0200
committerLibravatar lbonn <bonnans.l@gmail.com>2017-10-08 11:51:03 +0200
commitfd7c4bacbda311a8966a7f273dec16ce0ca45205 (patch)
treed8443a4a7ad2327ffb4e5bf7c39973430908c333
parentipc/tree: output mandatory fields for all nodes (diff)
downloadsway-fd7c4bacbda311a8966a7f273dec16ce0ca45205.tar.gz
sway-fd7c4bacbda311a8966a7f273dec16ce0ca45205.tar.zst
sway-fd7c4bacbda311a8966a7f273dec16ce0ca45205.zip
ipc/tree: populate `focus` fields
Ids of children, by order of focus
-rw-r--r--sway/ipc-json.c35
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) {