summaryrefslogtreecommitdiff
path: root/sway/ipc-json.c
diff options
context:
space:
mode:
authorDrew DeVault <[email protected]>2018-09-15 11:15:09 -0400
committerGitHub <[email protected]>2018-09-15 11:15:09 -0400
commit9f985f1f1cabf65b1c8349d9320a3031f959ec5a (patch)
treea05b996b9f513e008f8879fab5604462853e156b /sway/ipc-json.c
parentb47f4f5fd4b8dc3852c5958f3e6ec70de448ff2d (diff)
parent34dbbb1314af16e388c7517aec6427baa00fb179 (diff)
Merge pull request #2634 from ianyfan/ipc
ipc: add focus information to root node
Diffstat (limited to 'sway/ipc-json.c')
-rw-r--r--sway/ipc-json.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/sway/ipc-json.c b/sway/ipc-json.c
index 8b786145..52278be2 100644
--- a/sway/ipc-json.c
+++ b/sway/ipc-json.c
@@ -314,9 +314,24 @@ struct focus_inactive_data {
static void focus_inactive_children_iterator(struct sway_node *node,
void *_data) {
struct focus_inactive_data *data = _data;
- if (node_get_parent(node) == data->node) {
- json_object_array_add(data->object, json_object_new_int(node->id));
+ json_object *focus = data->object;
+ if (data->node == &root->node) {
+ struct sway_output *output = node_get_output(node);
+ if (output == NULL) {
+ return;
+ }
+ size_t id = output->node.id;
+ int len = json_object_array_length(focus);
+ for (int i = 0; i < len; ++i) {
+ if ((size_t) json_object_get_int(json_object_array_get_idx(focus, i)) == id) {
+ return;
+ }
+ }
+ node = &output->node;
+ } else if (node_get_parent(node) != data->node) {
+ return;
}
+ json_object_array_add(focus, json_object_new_int(node->id));
}
json_object *ipc_json_describe_node(struct sway_node *node) {