+ free(val);
+ RESTORE_INT(topPadding, &d->top_padding)
+ RESTORE_INT(rightPadding, &d->right_padding)
+ RESTORE_INT(bottomPadding, &d->bottom_padding)
+ RESTORE_INT(leftPadding, &d->left_padding)
+ RESTORE_INT(windowGap, &d->window_gap)
+ RESTORE_UINT(borderWidth, &d->border_width)
+ } else if (keyeq("focusedNodeId", *t, json)) {
+ (*t)++;
+ sscanf(json + (*t)->start, "%u", &focusedNodeId);
+ } else if (keyeq("root", *t, json)) {
+ (*t)++;
+ d->root = restore_node(t, json);
+ continue;
+ } else {
+ warn("Restore desktop: unknown key: '%.*s'.\n", (*t)->end - (*t)->start, json + (*t)->start);
+ (*t)++;
+ }
+ (*t)++;
+ }
+
+ if (focusedNodeId != XCB_NONE) {
+ d->focus = find_by_id_in(d->root, focusedNodeId);
+ }
+
+ return d;
+}
+
+node_t *restore_node(jsmntok_t **t, char *json)
+{
+ if ((*t)->type == JSMN_PRIMITIVE) {
+ (*t)++;
+ return NULL;
+ } else {
+ int s = (*t)->size;
+ (*t)++;
+ /* hack to prevent a new ID from being generated */
+ node_t *n = make_node(UINT32_MAX);
+
+ for (int i = 0; i < s; i++) {
+ if (keyeq("id", *t, json)) {
+ (*t)++;
+ sscanf(json + (*t)->start, "%u", &n->id);
+ RESTORE_ANY(splitType, &n->split_type, parse_split_type)
+ RESTORE_DOUBLE(splitRatio, &n->split_ratio)
+ RESTORE_INT(birthRotation, &n->birth_rotation)
+ RESTORE_BOOL(vacant, &n->vacant)
+ RESTORE_BOOL(sticky, &n->sticky)
+ RESTORE_BOOL(private, &n->private)
+ RESTORE_BOOL(locked, &n->locked)
+ } else if (keyeq("presel", *t, json)) {
+ (*t)++;
+ n->presel = restore_presel(t, json);
+ continue;
+ } else if (keyeq("rectangle", *t, json)) {
+ (*t)++;
+ restore_rectangle(&n->rectangle, t, json);
+ continue;
+ } else if (keyeq("firstChild", *t, json)) {
+ (*t)++;
+ node_t *fc = restore_node(t, json);
+ n->first_child = fc;
+ if (fc != NULL) {
+ fc->parent = n;
+ }
+ continue;
+ } else if (keyeq("secondChild", *t, json)) {
+ (*t)++;
+ node_t *sc = restore_node(t, json);
+ n->second_child = sc;
+ if (sc != NULL) {
+ sc->parent = n;
+ }
+ continue;
+ } else if (keyeq("client", *t, json)) {
+ (*t)++;
+ n->client = restore_client(t, json);