diff options
Diffstat (limited to 'sway/ipc-json.c')
-rw-r--r-- | sway/ipc-json.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/sway/ipc-json.c b/sway/ipc-json.c index 54824a36..2c7c7325 100644 --- a/sway/ipc-json.c +++ b/sway/ipc-json.c | |||
@@ -11,6 +11,25 @@ | |||
11 | #include <wlr/types/wlr_output.h> | 11 | #include <wlr/types/wlr_output.h> |
12 | #include "wlr-layer-shell-unstable-v1-protocol.h" | 12 | #include "wlr-layer-shell-unstable-v1-protocol.h" |
13 | 13 | ||
14 | static const char *ipc_json_layout_description(enum sway_container_layout l) { | ||
15 | switch (l) { | ||
16 | case L_VERT: | ||
17 | return "splitv"; | ||
18 | case L_HORIZ: | ||
19 | return "splith"; | ||
20 | case L_TABBED: | ||
21 | return "tabbed"; | ||
22 | case L_STACKED: | ||
23 | return "stacked"; | ||
24 | case L_FLOATING: | ||
25 | return "floating"; | ||
26 | case L_NONE: | ||
27 | case L_LAYOUTS: | ||
28 | break; | ||
29 | } | ||
30 | return "none"; | ||
31 | } | ||
32 | |||
14 | json_object *ipc_json_get_version() { | 33 | json_object *ipc_json_get_version() { |
15 | int major = 0, minor = 0, patch = 0; | 34 | int major = 0, minor = 0, patch = 0; |
16 | json_object *version = json_object_new_object(); | 35 | json_object *version = json_object_new_object(); |
@@ -115,7 +134,9 @@ static void ipc_json_describe_output(struct sway_container *container, json_obje | |||
115 | json_object_new_int(mode->refresh)); | 134 | json_object_new_int(mode->refresh)); |
116 | json_object_array_add(modes_array, mode_object); | 135 | json_object_array_add(modes_array, mode_object); |
117 | } | 136 | } |
137 | |||
118 | json_object_object_add(object, "modes", modes_array); | 138 | json_object_object_add(object, "modes", modes_array); |
139 | json_object_object_add(object, "layout", json_object_new_string("output")); | ||
119 | } | 140 | } |
120 | 141 | ||
121 | static void ipc_json_describe_workspace(struct sway_container *workspace, | 142 | static void ipc_json_describe_workspace(struct sway_container *workspace, |
@@ -127,12 +148,23 @@ static void ipc_json_describe_workspace(struct sway_container *workspace, | |||
127 | json_object_new_string(workspace->parent->name) : NULL); | 148 | json_object_new_string(workspace->parent->name) : NULL); |
128 | json_object_object_add(object, "type", json_object_new_string("workspace")); | 149 | json_object_object_add(object, "type", json_object_new_string("workspace")); |
129 | json_object_object_add(object, "urgent", json_object_new_boolean(false)); | 150 | json_object_object_add(object, "urgent", json_object_new_boolean(false)); |
151 | |||
152 | const char *layout = ipc_json_layout_description(workspace->workspace_layout); | ||
153 | json_object_object_add(object, "layout", json_object_new_string(layout)); | ||
130 | } | 154 | } |
131 | 155 | ||
132 | static void ipc_json_describe_view(struct sway_container *c, json_object *object) { | 156 | static void ipc_json_describe_view(struct sway_container *c, json_object *object) { |
133 | json_object_object_add(object, "name", | 157 | json_object_object_add(object, "name", |
134 | c->name ? json_object_new_string(c->name) : NULL); | 158 | c->name ? json_object_new_string(c->name) : NULL); |
135 | json_object_object_add(object, "type", json_object_new_string("con")); | 159 | json_object_object_add(object, "type", json_object_new_string("con")); |
160 | |||
161 | if (c->parent) { | ||
162 | enum sway_container_layout layout = (c->parent->type == C_CONTAINER) ? | ||
163 | c->parent->layout : c->layout; | ||
164 | |||
165 | json_object_object_add(object, "layout", | ||
166 | json_object_new_string(ipc_json_layout_description(layout))); | ||
167 | } | ||
136 | } | 168 | } |
137 | 169 | ||
138 | json_object *ipc_json_describe_container(struct sway_container *c) { | 170 | json_object *ipc_json_describe_container(struct sway_container *c) { |