summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2017-10-08 10:48:33 -0400
committerLibravatar Drew DeVault <sir@cmpwn.com>2017-10-08 10:48:33 -0400
commit46e5aeac5016f336aa1184b2752146c04ece21d9 (patch)
tree7be076200e4e870e3b8edf53ff867fc34942fdc0
parentMerge pull request #1387 from lbonn/ipc-work (diff)
downloadsway-46e5aeac5016f336aa1184b2752146c04ece21d9.tar.gz
sway-46e5aeac5016f336aa1184b2752146c04ece21d9.tar.zst
sway-46e5aeac5016f336aa1184b2752146c04ece21d9.zip
Fix crash on swaygrab with scratchpad populated
Fixes #1217
-rw-r--r--sway/ipc-json.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/sway/ipc-json.c b/sway/ipc-json.c
index 94768aa4..6ab63c75 100644
--- a/sway/ipc-json.c
+++ b/sway/ipc-json.c
@@ -155,22 +155,11 @@ static const char *ipc_json_get_scratchpad_state(swayc_t *c) {
155 155
156static void ipc_json_describe_view(swayc_t *c, json_object *object) { 156static void ipc_json_describe_view(swayc_t *c, json_object *object) {
157 json_object *props = json_object_new_object(); 157 json_object *props = json_object_new_object();
158 const char *layout = (c->parent->type == C_CONTAINER) ?
159 ipc_json_layout_description(c->parent->layout) : "none";
160 const char *last_layout = (c->parent->type == C_CONTAINER) ?
161 ipc_json_layout_description(c->parent->prev_layout) : "none";
162 wlc_handle parent = wlc_view_get_parent(c->handle);
163
164 json_object_object_add(object, "type", json_object_new_string((c->is_floating) ? "floating_con" : "con")); 158 json_object_object_add(object, "type", json_object_new_string((c->is_floating) ? "floating_con" : "con"));
165 159
160 wlc_handle parent = wlc_view_get_parent(c->handle);
166 json_object_object_add(object, "scratchpad_state", 161 json_object_object_add(object, "scratchpad_state",
167 json_object_new_string(ipc_json_get_scratchpad_state(c))); 162 json_object_new_string(ipc_json_get_scratchpad_state(c)));
168 json_object_object_add(object, "layout",
169 (strcmp(layout, "null") == 0) ? NULL : json_object_new_string(layout));
170 json_object_object_add(object, "last_split_layout",
171 (strcmp(last_layout, "null") == 0) ? NULL : json_object_new_string(last_layout));
172 json_object_object_add(object, "workspace_layout",
173 json_object_new_string(ipc_json_layout_description(swayc_parent_by_type(c, C_WORKSPACE)->workspace_layout)));
174 163
175 json_object_object_add(object, "name", (c->name) ? json_object_new_string(c->name) : NULL); 164 json_object_object_add(object, "name", (c->name) ? json_object_new_string(c->name) : NULL);
176 165
@@ -189,6 +178,19 @@ static void ipc_json_describe_view(swayc_t *c, json_object *object) {
189 c->is_floating ? "auto_on" : "auto_off")); // we can't state the cause 178 c->is_floating ? "auto_on" : "auto_off")); // we can't state the cause
190 179
191 json_object_object_add(object, "app_id", c->app_id ? json_object_new_string(c->app_id) : NULL); 180 json_object_object_add(object, "app_id", c->app_id ? json_object_new_string(c->app_id) : NULL);
181
182 if (c->parent) {
183 const char *layout = (c->parent->type == C_CONTAINER) ?
184 ipc_json_layout_description(c->parent->layout) : "none";
185 const char *last_layout = (c->parent->type == C_CONTAINER) ?
186 ipc_json_layout_description(c->parent->prev_layout) : "none";
187 json_object_object_add(object, "layout",
188 (strcmp(layout, "null") == 0) ? NULL : json_object_new_string(layout));
189 json_object_object_add(object, "last_split_layout",
190 (strcmp(last_layout, "null") == 0) ? NULL : json_object_new_string(last_layout));
191 json_object_object_add(object, "workspace_layout",
192 json_object_new_string(ipc_json_layout_description(swayc_parent_by_type(c, C_WORKSPACE)->workspace_layout)));
193 }
192} 194}
193 195
194static void ipc_json_describe_root(swayc_t *c, json_object *object) { 196static void ipc_json_describe_root(swayc_t *c, json_object *object) {