diff options
-rw-r--r-- | sway/ipc-json.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/sway/ipc-json.c b/sway/ipc-json.c index 5d1393bc..5c9b3e5a 100644 --- a/sway/ipc-json.c +++ b/sway/ipc-json.c | |||
@@ -266,13 +266,16 @@ static void ipc_json_describe_view(struct sway_container *c, json_object *object | |||
266 | json_object *window_props = json_object_new_object(); | 266 | json_object *window_props = json_object_new_object(); |
267 | 267 | ||
268 | const char *class = view_get_class(c->view); | 268 | const char *class = view_get_class(c->view); |
269 | json_object_object_add(window_props, "class", | 269 | if (class) { |
270 | class ? json_object_new_string(class) : NULL); | 270 | json_object_object_add(window_props, "class", json_object_new_string(class)); |
271 | } | ||
271 | const char *instance = view_get_instance(c->view); | 272 | const char *instance = view_get_instance(c->view); |
272 | json_object_object_add(window_props, "instance", | 273 | if (instance) { |
273 | instance ? json_object_new_string(instance) : NULL); | 274 | json_object_object_add(window_props, "instance", json_object_new_string(instance)); |
274 | json_object_object_add(window_props, "title", | 275 | } |
275 | c->title ? json_object_new_string(c->title) : NULL); | 276 | if (c->title) { |
277 | json_object_object_add(window_props, "title", json_object_new_string(c->title)); | ||
278 | } | ||
276 | 279 | ||
277 | // the transient_for key is always present in i3's output | 280 | // the transient_for key is always present in i3's output |
278 | uint32_t parent_id = view_get_x11_parent_id(c->view); | 281 | uint32_t parent_id = view_get_x11_parent_id(c->view); |
@@ -281,8 +284,7 @@ static void ipc_json_describe_view(struct sway_container *c, json_object *object | |||
281 | 284 | ||
282 | const char *role = view_get_window_role(c->view); | 285 | const char *role = view_get_window_role(c->view); |
283 | if (role) { | 286 | if (role) { |
284 | json_object_object_add(window_props, "window_role", | 287 | json_object_object_add(window_props, "window_role", json_object_new_string(role)); |
285 | json_object_new_string(role)); | ||
286 | } | 288 | } |
287 | 289 | ||
288 | json_object_object_add(object, "window_properties", window_props); | 290 | json_object_object_add(object, "window_properties", window_props); |