|
|
|
@ -138,7 +138,6 @@ static void ipc_json_describe_workspace(swayc_t *workspace, json_object *object)
|
|
|
|
|
|
|
|
|
|
json_object_object_add(object, "num", json_object_new_int(num));
|
|
|
|
|
json_object_object_add(object, "output", (workspace->parent) ? json_object_new_string(workspace->parent->name) : NULL);
|
|
|
|
|
json_object_object_add(object, "urgent", json_object_new_boolean(false));
|
|
|
|
|
json_object_object_add(object, "type", json_object_new_string("workspace"));
|
|
|
|
|
json_object_object_add(object, "layout", (strcmp(layout, "null") == 0) ? NULL : json_object_new_string(layout));
|
|
|
|
|
}
|
|
|
|
@ -156,7 +155,6 @@ static const char *ipc_json_get_scratchpad_state(swayc_t *c) {
|
|
|
|
|
|
|
|
|
|
static void ipc_json_describe_view(swayc_t *c, json_object *object) {
|
|
|
|
|
json_object *props = json_object_new_object();
|
|
|
|
|
float percent = ipc_json_child_percentage(c);
|
|
|
|
|
const char *layout = (c->parent->type == C_CONTAINER) ?
|
|
|
|
|
ipc_json_layout_description(c->parent->layout) : "none";
|
|
|
|
|
const char *last_layout = (c->parent->type == C_CONTAINER) ?
|
|
|
|
@ -167,9 +165,6 @@ static void ipc_json_describe_view(swayc_t *c, json_object *object) {
|
|
|
|
|
|
|
|
|
|
json_object_object_add(object, "scratchpad_state",
|
|
|
|
|
json_object_new_string(ipc_json_get_scratchpad_state(c)));
|
|
|
|
|
json_object_object_add(object, "percent", (percent > 0) ? json_object_new_double(percent) : NULL);
|
|
|
|
|
// TODO: make urgency actually work once Sway supports it
|
|
|
|
|
json_object_object_add(object, "urgent", json_object_new_boolean(false));
|
|
|
|
|
json_object_object_add(object, "layout",
|
|
|
|
|
(strcmp(layout, "null") == 0) ? NULL : json_object_new_string(layout));
|
|
|
|
|
json_object_object_add(object, "last_split_layout",
|
|
|
|
@ -177,17 +172,8 @@ static void ipc_json_describe_view(swayc_t *c, json_object *object) {
|
|
|
|
|
json_object_object_add(object, "workspace_layout",
|
|
|
|
|
json_object_new_string(ipc_json_layout_description(swayc_parent_by_type(c, C_WORKSPACE)->workspace_layout)));
|
|
|
|
|
|
|
|
|
|
json_object_object_add(object, "border", json_object_new_string(ipc_json_border_description(c)));
|
|
|
|
|
json_object_object_add(object, "current_border_width", json_object_new_int(c->border_thickness));
|
|
|
|
|
|
|
|
|
|
json_object_object_add(object, "rect", ipc_json_create_rect(c));
|
|
|
|
|
json_object_object_add(object, "deco_rect", ipc_json_create_rect_from_geometry(c->title_bar_geometry));
|
|
|
|
|
json_object_object_add(object, "geometry", ipc_json_create_rect_from_geometry(c->cached_geometry));
|
|
|
|
|
json_object_object_add(object, "window_rect", ipc_json_create_rect_from_geometry(c->actual_geometry));
|
|
|
|
|
|
|
|
|
|
json_object_object_add(object, "name", (c->name) ? json_object_new_string(c->name) : NULL);
|
|
|
|
|
|
|
|
|
|
json_object_object_add(object, "window", json_object_new_int(c->handle)); // for the sake of i3 compat
|
|
|
|
|
json_object_object_add(props, "class", c->class ? json_object_new_string(c->class) :
|
|
|
|
|
c->app_id ? json_object_new_string(c->app_id) : NULL);
|
|
|
|
|
json_object_object_add(props, "instance", c->instance ? json_object_new_string(c->instance) :
|
|
|
|
@ -205,7 +191,14 @@ static void ipc_json_describe_view(swayc_t *c, json_object *object) {
|
|
|
|
|
json_object_object_add(object, "app_id", c->app_id ? json_object_new_string(c->app_id) : NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void ipc_json_describe_root(swayc_t *c, json_object *object) {
|
|
|
|
|
json_object_object_add(object, "type", json_object_new_string("root"));
|
|
|
|
|
json_object_object_add(object, "layout", json_object_new_string("splith"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
json_object *ipc_json_describe_container(swayc_t *c) {
|
|
|
|
|
float percent = ipc_json_child_percentage(c);
|
|
|
|
|
|
|
|
|
|
if (!(sway_assert(c, "Container must not be null."))) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
@ -218,9 +211,19 @@ json_object *ipc_json_describe_container(swayc_t *c) {
|
|
|
|
|
json_object_object_add(object, "visible", json_object_new_boolean(c->visible));
|
|
|
|
|
json_object_object_add(object, "focused", json_object_new_boolean(c == current_focus));
|
|
|
|
|
|
|
|
|
|
json_object_object_add(object, "border", json_object_new_string(ipc_json_border_description(c)));
|
|
|
|
|
json_object_object_add(object, "window_rect", ipc_json_create_rect_from_geometry(c->actual_geometry));
|
|
|
|
|
json_object_object_add(object, "deco_rect", ipc_json_create_rect_from_geometry(c->title_bar_geometry));
|
|
|
|
|
json_object_object_add(object, "geometry", ipc_json_create_rect_from_geometry(c->cached_geometry));
|
|
|
|
|
json_object_object_add(object, "percent", (percent > 0) ? json_object_new_double(percent) : NULL);
|
|
|
|
|
json_object_object_add(object, "window", json_object_new_int(c->handle)); // for the sake of i3 compat
|
|
|
|
|
// TODO: make urgency actually work once Sway supports it
|
|
|
|
|
json_object_object_add(object, "urgent", json_object_new_boolean(false));
|
|
|
|
|
json_object_object_add(object, "current_border_width", json_object_new_int(c->border_thickness));
|
|
|
|
|
|
|
|
|
|
switch (c->type) {
|
|
|
|
|
case C_ROOT:
|
|
|
|
|
json_object_object_add(object, "type", json_object_new_string("root"));
|
|
|
|
|
ipc_json_describe_root(c, object);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case C_OUTPUT:
|
|
|
|
@ -451,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) {
|
|
|
|
|