aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2017-10-08 10:48:33 -0400
committerDrew DeVault <sir@cmpwn.com>2017-10-08 10:48:33 -0400
commit46e5aeac5016f336aa1184b2752146c04ece21d9 (patch)
tree7be076200e4e870e3b8edf53ff867fc34942fdc0 /sway
parent43161a7e178b59b6bff3f210f46e21e8bf67e066 (diff)
Fix crash on swaygrab with scratchpad populated
Fixes #1217
Diffstat (limited to 'sway')
-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) {
static void ipc_json_describe_view(swayc_t *c, json_object *object) {
json_object *props = json_object_new_object();
- const char *layout = (c->parent->type == C_CONTAINER) ?
- ipc_json_layout_description(c->parent->layout) : "none";
- const char *last_layout = (c->parent->type == C_CONTAINER) ?
- ipc_json_layout_description(c->parent->prev_layout) : "none";
- wlc_handle parent = wlc_view_get_parent(c->handle);
-
json_object_object_add(object, "type", json_object_new_string((c->is_floating) ? "floating_con" : "con"));
+ wlc_handle parent = wlc_view_get_parent(c->handle);
json_object_object_add(object, "scratchpad_state",
json_object_new_string(ipc_json_get_scratchpad_state(c)));
- json_object_object_add(object, "layout",
- (strcmp(layout, "null") == 0) ? NULL : json_object_new_string(layout));
- json_object_object_add(object, "last_split_layout",
- (strcmp(last_layout, "null") == 0) ? NULL : json_object_new_string(last_layout));
- json_object_object_add(object, "workspace_layout",
- json_object_new_string(ipc_json_layout_description(swayc_parent_by_type(c, C_WORKSPACE)->workspace_layout)));
json_object_object_add(object, "name", (c->name) ? json_object_new_string(c->name) : NULL);
@@ -189,6 +178,19 @@ static void ipc_json_describe_view(swayc_t *c, json_object *object) {
c->is_floating ? "auto_on" : "auto_off")); // we can't state the cause
json_object_object_add(object, "app_id", c->app_id ? json_object_new_string(c->app_id) : NULL);
+
+ if (c->parent) {
+ const char *layout = (c->parent->type == C_CONTAINER) ?
+ ipc_json_layout_description(c->parent->layout) : "none";
+ const char *last_layout = (c->parent->type == C_CONTAINER) ?
+ ipc_json_layout_description(c->parent->prev_layout) : "none";
+ json_object_object_add(object, "layout",
+ (strcmp(layout, "null") == 0) ? NULL : json_object_new_string(layout));
+ json_object_object_add(object, "last_split_layout",
+ (strcmp(last_layout, "null") == 0) ? NULL : json_object_new_string(last_layout));
+ json_object_object_add(object, "workspace_layout",
+ json_object_new_string(ipc_json_layout_description(swayc_parent_by_type(c, C_WORKSPACE)->workspace_layout)));
+ }
}
static void ipc_json_describe_root(swayc_t *c, json_object *object) {