Merge pull request #2634 from ianyfan/ipc

ipc: add focus information to root node
This commit is contained in:
Drew DeVault 2018-09-15 11:15:09 -04:00 committed by GitHub
commit 9f985f1f1c
Failed to generate hash of commit
2 changed files with 21 additions and 4 deletions

View file

@ -314,9 +314,24 @@ struct focus_inactive_data {
static void focus_inactive_children_iterator(struct sway_node *node, static void focus_inactive_children_iterator(struct sway_node *node,
void *_data) { void *_data) {
struct focus_inactive_data *data = _data; struct focus_inactive_data *data = _data;
if (node_get_parent(node) == data->node) { json_object *focus = data->object;
json_object_array_add(data->object, json_object_new_int(node->id)); 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) { json_object *ipc_json_describe_node(struct sway_node *node) {

View file

@ -74,8 +74,10 @@ void node_get_box(struct sway_node *node, struct wlr_box *box) {
struct sway_output *node_get_output(struct sway_node *node) { struct sway_output *node_get_output(struct sway_node *node) {
switch (node->type) { switch (node->type) {
case N_CONTAINER: case N_CONTAINER: {
return node->sway_container->workspace->output; struct sway_workspace *ws = node->sway_container->workspace;
return ws ? ws->output : NULL;
}
case N_WORKSPACE: case N_WORKSPACE:
return node->sway_workspace->output; return node->sway_workspace->output;
case N_OUTPUT: case N_OUTPUT: