aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
Diffstat (limited to 'sway')
-rw-r--r--sway/ipc-json.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/sway/ipc-json.c b/sway/ipc-json.c
index 54824a36..44828a0d 100644
--- a/sway/ipc-json.c
+++ b/sway/ipc-json.c
@@ -11,6 +11,40 @@
#include <wlr/types/wlr_output.h>
#include "wlr-layer-shell-unstable-v1-protocol.h"
+static const char *ipc_json_layout_description(enum sway_container_layout l) {
+ const char *layout;
+
+ switch (l) {
+ case L_VERT:
+ layout = "splitv";
+ break;
+
+ case L_HORIZ:
+ layout = "splith";
+ break;
+
+ case L_TABBED:
+ layout = "tabbed";
+ break;
+
+ case L_STACKED:
+ layout = "stacked";
+ break;
+
+ case L_FLOATING:
+ layout = "floating";
+ break;
+
+ case L_NONE: // fallthrough
+ case L_LAYOUTS: // fallthrough; this should never happen, I'm just trying to silence compiler warnings
+ default:
+ layout = "null";
+ break;
+ }
+
+ return layout;
+}
+
json_object *ipc_json_get_version() {
int major = 0, minor = 0, patch = 0;
json_object *version = json_object_new_object();
@@ -116,6 +150,9 @@ static void ipc_json_describe_output(struct sway_container *container, json_obje
json_object_array_add(modes_array, mode_object);
}
json_object_object_add(object, "modes", modes_array);
+
+
+ json_object_object_add(object, "layout", json_object_new_string("output"));
}
static void ipc_json_describe_workspace(struct sway_container *workspace,
@@ -127,12 +164,23 @@ static void ipc_json_describe_workspace(struct sway_container *workspace,
json_object_new_string(workspace->parent->name) : NULL);
json_object_object_add(object, "type", json_object_new_string("workspace"));
json_object_object_add(object, "urgent", json_object_new_boolean(false));
+
+ const char *layout = ipc_json_layout_description(workspace->workspace_layout);
+ json_object_object_add(object, "layout", (strcmp(layout, "null") == 0) ?
+ NULL : json_object_new_string(layout));
}
static void ipc_json_describe_view(struct sway_container *c, json_object *object) {
json_object_object_add(object, "name",
c->name ? json_object_new_string(c->name) : NULL);
json_object_object_add(object, "type", json_object_new_string("con"));
+
+ if (c->parent) {
+ const char *layout = (c->parent->type == C_CONTAINER) ?
+ ipc_json_layout_description(c->parent->layout) : "none";
+ json_object_object_add(object, "layout",
+ (strcmp(layout, "null") == 0) ? NULL : json_object_new_string(layout));
+ }
}
json_object *ipc_json_describe_container(struct sway_container *c) {