aboutsummaryrefslogtreecommitdiffstats
path: root/sway/ipc-json.c
diff options
context:
space:
mode:
authorLibravatar Tony Crisci <tony@dubstepdish.com>2018-04-05 22:50:10 -0400
committerLibravatar Tony Crisci <tony@dubstepdish.com>2018-04-05 22:50:10 -0400
commit6b308dbeb7a1f2b26279481c001c15434d2468cb (patch)
tree2ea7f5de363a900f415c9e0ef2e18880f1fc10cc /sway/ipc-json.c
parentdont send ipc events when there are no listeners (diff)
downloadsway-6b308dbeb7a1f2b26279481c001c15434d2468cb.tar.gz
sway-6b308dbeb7a1f2b26279481c001c15434d2468cb.tar.zst
sway-6b308dbeb7a1f2b26279481c001c15434d2468cb.zip
address feedback
Diffstat (limited to 'sway/ipc-json.c')
-rw-r--r--sway/ipc-json.c44
1 files changed, 14 insertions, 30 deletions
diff --git a/sway/ipc-json.c b/sway/ipc-json.c
index 44828a0d..2c7c7325 100644
--- a/sway/ipc-json.c
+++ b/sway/ipc-json.c
@@ -12,37 +12,22 @@
12#include "wlr-layer-shell-unstable-v1-protocol.h" 12#include "wlr-layer-shell-unstable-v1-protocol.h"
13 13
14static const char *ipc_json_layout_description(enum sway_container_layout l) { 14static const char *ipc_json_layout_description(enum sway_container_layout l) {
15 const char *layout;
16
17 switch (l) { 15 switch (l) {
18 case L_VERT: 16 case L_VERT:
19 layout = "splitv"; 17 return "splitv";
20 break;
21
22 case L_HORIZ: 18 case L_HORIZ:
23 layout = "splith"; 19 return "splith";
24 break;
25
26 case L_TABBED: 20 case L_TABBED:
27 layout = "tabbed"; 21 return "tabbed";
28 break;
29
30 case L_STACKED: 22 case L_STACKED:
31 layout = "stacked"; 23 return "stacked";
32 break;
33
34 case L_FLOATING: 24 case L_FLOATING:
35 layout = "floating"; 25 return "floating";
36 break; 26 case L_NONE:
37 27 case L_LAYOUTS:
38 case L_NONE: // fallthrough
39 case L_LAYOUTS: // fallthrough; this should never happen, I'm just trying to silence compiler warnings
40 default:
41 layout = "null";
42 break; 28 break;
43 } 29 }
44 30 return "none";
45 return layout;
46} 31}
47 32
48json_object *ipc_json_get_version() { 33json_object *ipc_json_get_version() {
@@ -149,9 +134,8 @@ static void ipc_json_describe_output(struct sway_container *container, json_obje
149 json_object_new_int(mode->refresh)); 134 json_object_new_int(mode->refresh));
150 json_object_array_add(modes_array, mode_object); 135 json_object_array_add(modes_array, mode_object);
151 } 136 }
152 json_object_object_add(object, "modes", modes_array);
153
154 137
138 json_object_object_add(object, "modes", modes_array);
155 json_object_object_add(object, "layout", json_object_new_string("output")); 139 json_object_object_add(object, "layout", json_object_new_string("output"));
156} 140}
157 141
@@ -166,8 +150,7 @@ static void ipc_json_describe_workspace(struct sway_container *workspace,
166 json_object_object_add(object, "urgent", json_object_new_boolean(false)); 150 json_object_object_add(object, "urgent", json_object_new_boolean(false));
167 151
168 const char *layout = ipc_json_layout_description(workspace->workspace_layout); 152 const char *layout = ipc_json_layout_description(workspace->workspace_layout);
169 json_object_object_add(object, "layout", (strcmp(layout, "null") == 0) ? 153 json_object_object_add(object, "layout", json_object_new_string(layout));
170 NULL : json_object_new_string(layout));
171} 154}
172 155
173static void ipc_json_describe_view(struct sway_container *c, json_object *object) { 156static void ipc_json_describe_view(struct sway_container *c, json_object *object) {
@@ -176,10 +159,11 @@ static void ipc_json_describe_view(struct sway_container *c, json_object *object
176 json_object_object_add(object, "type", json_object_new_string("con")); 159 json_object_object_add(object, "type", json_object_new_string("con"));
177 160
178 if (c->parent) { 161 if (c->parent) {
179 const char *layout = (c->parent->type == C_CONTAINER) ? 162 enum sway_container_layout layout = (c->parent->type == C_CONTAINER) ?
180 ipc_json_layout_description(c->parent->layout) : "none"; 163 c->parent->layout : c->layout;
164
181 json_object_object_add(object, "layout", 165 json_object_object_add(object, "layout",
182 (strcmp(layout, "null") == 0) ? NULL : json_object_new_string(layout)); 166 json_object_new_string(ipc_json_layout_description(layout)));
183 } 167 }
184} 168}
185 169