aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
authorIan Fan <ianfan0@gmail.com>2018-09-15 01:51:58 +0100
committerIan Fan <ianfan0@gmail.com>2018-09-15 09:42:49 +0100
commit1c292fd43abf1c3bc86e91bd348f690aea820c85 (patch)
treeb2e929f89de3bafe37908d13e3819db2fe1259c6 /sway
parentb47f4f5fd4b8dc3852c5958f3e6ec70de448ff2d (diff)
ipc: add focus information to root node
Diffstat (limited to 'sway')
-rw-r--r--sway/ipc-json.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/sway/ipc-json.c b/sway/ipc-json.c
index 8b786145..30c0a8e1 100644
--- a/sway/ipc-json.c
+++ b/sway/ipc-json.c
@@ -314,9 +314,21 @@ 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) {
+ int len = json_object_array_length(focus);
+ struct sway_output *output = node_get_output(node);
+ size_t id = output->node.id;
+ 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) {