diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-10-28 02:20:10 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-28 02:20:10 +0200 |
commit | 2ccf511cbadd9eef476d42234874d0cf008311e4 (patch) | |
tree | 2d6389b38447d4bc8617f4922edce52663f09114 /sway | |
parent | e3a0e3322b4fd45ead0ec908eefd4cd6e41eadc1 (diff) | |
parent | 03ca8596d6bcec0a83567d9b51a71ccc7db197e5 (diff) |
Merge pull request #3006 from Snaipe/remove-class
ipc: make json for view match i3's output more closely
Diffstat (limited to 'sway')
-rw-r--r-- | sway/ipc-json.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/sway/ipc-json.c b/sway/ipc-json.c index 2cd0cb2d..5c9b3e5a 100644 --- a/sway/ipc-json.c +++ b/sway/ipc-json.c @@ -229,10 +229,6 @@ static void ipc_json_describe_view(struct sway_container *c, json_object *object json_object_object_add(object, "app_id", app_id ? json_object_new_string(app_id) : NULL); - const char *class = view_get_class(c->view); - json_object_object_add(object, "class", - class ? json_object_new_string(class) : NULL); - json_object *marks = json_object_new_array(); list_t *view_marks = c->view->marks; for (int i = 0; i < view_marks->length; ++i) { @@ -269,13 +265,17 @@ static void ipc_json_describe_view(struct sway_container *c, json_object *object json_object *window_props = json_object_new_object(); - json_object_object_add(window_props, "class", - class ? json_object_new_string(class) : NULL); + const char *class = view_get_class(c->view); + if (class) { + json_object_object_add(window_props, "class", json_object_new_string(class)); + } const char *instance = view_get_instance(c->view); - json_object_object_add(window_props, "instance", - instance ? json_object_new_string(instance) : NULL); - json_object_object_add(window_props, "title", - c->title ? json_object_new_string(c->title) : NULL); + if (instance) { + json_object_object_add(window_props, "instance", json_object_new_string(instance)); + } + if (c->title) { + json_object_object_add(window_props, "title", json_object_new_string(c->title)); + } // the transient_for key is always present in i3's output uint32_t parent_id = view_get_x11_parent_id(c->view); @@ -284,8 +284,7 @@ static void ipc_json_describe_view(struct sway_container *c, json_object *object const char *role = view_get_window_role(c->view); if (role) { - json_object_object_add(window_props, "window_role", - json_object_new_string(role)); + json_object_object_add(window_props, "window_role", json_object_new_string(role)); } json_object_object_add(object, "window_properties", window_props); |