aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sway/ipc-json.c49
1 files changed, 33 insertions, 16 deletions
diff --git a/sway/ipc-json.c b/sway/ipc-json.c
index 745d129a..fc65b5f2 100644
--- a/sway/ipc-json.c
+++ b/sway/ipc-json.c
@@ -79,9 +79,6 @@ static json_object *ipc_json_create_empty_rect(void) {
static void ipc_json_describe_root(struct sway_root *root, 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_object_add(object, "orientation",
- json_object_new_string(ipc_json_orientation_description(L_HORIZ)));
}
static const char *ipc_json_get_output_transform(enum wl_output_transform transform) {
@@ -113,6 +110,8 @@ static void ipc_json_describe_output(struct sway_output *output,
json_object_object_add(object, "active", json_object_new_boolean(true));
json_object_object_add(object, "primary", json_object_new_boolean(false));
json_object_object_add(object, "layout", json_object_new_string("output"));
+ json_object_object_add(object, "orientation",
+ json_object_new_string(ipc_json_orientation_description(L_NONE)));
json_object_object_add(object, "make",
json_object_new_string(wlr_output->make));
json_object_object_add(object, "model",
@@ -145,7 +144,6 @@ static void ipc_json_describe_output(struct sway_output *output,
}
json_object_object_add(object, "modes", modes_array);
- json_object_object_add(object, "layout", json_object_new_string("output"));
struct sway_node *parent = node_get_parent(&output->node);
struct wlr_box parent_box = {0, 0, 0, 0};
@@ -154,10 +152,7 @@ static void ipc_json_describe_output(struct sway_output *output,
node_get_box(parent, &parent_box);
}
- if (parent_box.width == 0 || parent_box.height == 0) {
- json_object_object_add(object, "percent", NULL);
- }
- else {
+ if (parent_box.width != 0 && parent_box.height != 0) {
double percent = (output->width / parent_box.width)
* (output->height / parent_box.height);
json_object_object_add(object, "percent", json_object_new_double(percent));
@@ -261,6 +256,16 @@ static void ipc_json_describe_view(struct sway_container *c, json_object *object
}
json_object_object_add(object, "deco_rect", ipc_json_create_rect(&deco_box));
+
+ struct wlr_box geometry = {0, 0, c->view->natural_width, c->view->natural_height };
+ json_object_object_add(object, "geometry", ipc_json_create_rect(&geometry));
+
+#ifdef HAVE_XWAYLAND
+ if (c->view->type == SWAY_VIEW_XWAYLAND) {
+ json_object_object_add(object, "window",
+ json_object_new_int(view_get_x11_window_id(c->view)));
+ }
+#endif
}
static void ipc_json_describe_container(struct sway_container *c, json_object *object) {
@@ -277,6 +282,7 @@ static void ipc_json_describe_container(struct sway_container *c, json_object *o
bool urgent = c->view ?
view_is_urgent(c->view) : container_has_urgent_child(c);
json_object_object_add(object, "urgent", json_object_new_boolean(urgent));
+ json_object_object_add(object, "sticky", json_object_new_boolean(c->is_sticky));
struct sway_node *parent = node_get_parent(&c->node);
struct wlr_box parent_box = {0, 0, 0, 0};
@@ -285,18 +291,12 @@ static void ipc_json_describe_container(struct sway_container *c, json_object *o
node_get_box(parent, &parent_box);
}
- if (parent_box.width == 0 || parent_box.height == 0) {
- json_object_object_add(object, "percent", NULL);
- }
- else {
+ if (parent_box.width != 0 && parent_box.height != 0) {
double percent = (c->width / parent_box.width)
* (c->height / parent_box.height);
json_object_object_add(object, "percent", json_object_new_double(percent));
}
- json_object_object_add(object, "window_rect", ipc_json_create_empty_rect());
- json_object_object_add(object, "deco_rect", ipc_json_create_empty_rect());
-
json_object_object_add(object, "border",
json_object_new_string(describe_container_border(c->current.border)));
json_object_object_add(object, "current_border_width",
@@ -344,6 +344,23 @@ json_object *ipc_json_describe_node(struct sway_node *node) {
seat_for_each_node(seat, focus_inactive_children_iterator, &data);
json_object_object_add(object, "focus", focus);
+ // set default values to be compatible with i3
+ json_object_object_add(object, "border",
+ json_object_new_string(describe_container_border(B_NONE)));
+ json_object_object_add(object, "current_border_width", json_object_new_int(0));
+ json_object_object_add(object, "layout",
+ json_object_new_string(ipc_json_layout_description(L_HORIZ)));
+ json_object_object_add(object, "orientation",
+ json_object_new_string(ipc_json_orientation_description(L_HORIZ)));
+ json_object_object_add(object, "percent", NULL);
+ json_object_object_add(object, "window_rect", ipc_json_create_empty_rect());
+ json_object_object_add(object, "deco_rect", ipc_json_create_empty_rect());
+ json_object_object_add(object, "geometry", ipc_json_create_empty_rect());
+ json_object_object_add(object, "window", NULL);
+ json_object_object_add(object, "urgent", json_object_new_boolean(false));
+ json_object_object_add(object, "floating_nodes", json_object_new_array());
+ json_object_object_add(object, "sticky", json_object_new_boolean(false));
+
switch (node->type) {
case N_ROOT:
ipc_json_describe_root(root, object);
@@ -352,7 +369,7 @@ json_object *ipc_json_describe_node(struct sway_node *node) {
ipc_json_describe_output(node->sway_output, object);
break;
case N_CONTAINER:
- ipc_json_describe_view(node->sway_container, object);
+ ipc_json_describe_container(node->sway_container, object);
break;
case N_WORKSPACE:
ipc_json_describe_workspace(node->sway_workspace, object);