aboutsummaryrefslogtreecommitdiff
path: root/sway/ipc-json.c
diff options
context:
space:
mode:
authorlbonn <bonnans.l@gmail.com>2017-10-08 00:00:53 +0200
committerlbonn <bonnans.l@gmail.com>2017-10-08 11:51:03 +0200
commitfd7c4bacbda311a8966a7f273dec16ce0ca45205 (patch)
treed8443a4a7ad2327ffb4e5bf7c39973430908c333 /sway/ipc-json.c
parent661625b29edb820a7e6d29f4eafcdd3d9610ef22 (diff)
ipc/tree: populate `focus` fields
Ids of children, by order of focus
Diffstat (limited to 'sway/ipc-json.c')
-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) {
int i;
json_object *floating = json_object_new_array();
- if (c->type != C_VIEW && c->floating && c->floating->length > 0) {
+ if (c->type != C_VIEW && c->floating) {
for (i = 0; i < c->floating->length; ++i) {
- json_object_array_add(floating, ipc_json_describe_container_recursive(c->floating->items[i]));
+ swayc_t *item = c->floating->items[i];
+ json_object_array_add(floating, ipc_json_describe_container_recursive(item));
}
}
json_object_object_add(object, "floating_nodes", floating);
json_object *children = json_object_new_array();
- if (c->type != C_VIEW && c->children && c->children->length > 0) {
+ if (c->type != C_VIEW && c->children) {
for (i = 0; i < c->children->length; ++i) {
json_object_array_add(children, ipc_json_describe_container_recursive(c->children->items[i]));
}
}
json_object_object_add(object, "nodes", children);
+ json_object *focus = json_object_new_array();
+ if (c->type != C_VIEW) {
+ if (c->focused) {
+ json_object_array_add(focus, json_object_new_double(c->focused->id));
+ }
+ if (c->floating) {
+ for (i = 0; i < c->floating->length; ++i) {
+ swayc_t *item = c->floating->items[i];
+ if (item == c->focused) {
+ continue;
+ }
+
+ json_object_array_add(focus, json_object_new_double(item->id));
+ }
+ }
+ if (c->children) {
+ for (i = 0; i < c->children->length; ++i) {
+ swayc_t *item = c->children->items[i];
+ if (item == c->focused) {
+ continue;
+ }
+
+ json_object_array_add(focus, json_object_new_double(item->id));
+ }
+ }
+ }
+ json_object_object_add(object, "focus", focus);
+
if (c->type == C_ROOT) {
json_object *scratchpad_json = json_object_new_array();
if (scratchpad->length > 0) {