aboutsummaryrefslogtreecommitdiff
path: root/sway/ipc-json.c
diff options
context:
space:
mode:
authorTony Crisci <tony@dubstepdish.com>2018-04-05 22:50:10 -0400
committerTony Crisci <tony@dubstepdish.com>2018-04-05 22:50:10 -0400
commit6b308dbeb7a1f2b26279481c001c15434d2468cb (patch)
tree2ea7f5de363a900f415c9e0ef2e18880f1fc10cc /sway/ipc-json.c
parent235798ff8e9e60d919cbb671f7c399ff97c164d5 (diff)
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 @@
#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;
-
+ return "splitv";
case L_HORIZ:
- layout = "splith";
- break;
-
+ return "splith";
case L_TABBED:
- layout = "tabbed";
- break;
-
+ return "tabbed";
case L_STACKED:
- layout = "stacked";
- break;
-
+ return "stacked";
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";
+ return "floating";
+ case L_NONE:
+ case L_LAYOUTS:
break;
}
-
- return layout;
+ return "none";
}
json_object *ipc_json_get_version() {
@@ -149,9 +134,8 @@ static void ipc_json_describe_output(struct sway_container *container, json_obje
json_object_new_int(mode->refresh));
json_object_array_add(modes_array, mode_object);
}
- json_object_object_add(object, "modes", modes_array);
-
+ json_object_object_add(object, "modes", modes_array);
json_object_object_add(object, "layout", json_object_new_string("output"));
}
@@ -166,8 +150,7 @@ static void ipc_json_describe_workspace(struct sway_container *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));
+ json_object_object_add(object, "layout", json_object_new_string(layout));
}
static 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
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";
+ enum sway_container_layout layout = (c->parent->type == C_CONTAINER) ?
+ c->parent->layout : c->layout;
+
json_object_object_add(object, "layout",
- (strcmp(layout, "null") == 0) ? NULL : json_object_new_string(layout));
+ json_object_new_string(ipc_json_layout_description(layout)));
}
}