*
*/
bool tree_restore(const char *path, xcb_get_geometry_reply_t *geometry) {
+ bool result = false;
char *globbed = resolve_tilde(path);
+ char *buf = NULL;
if (!path_exists(globbed)) {
LOG("%s does not exist, not restoring tree\n", globbed);
- free(globbed);
- return false;
+ goto out;
+ }
+
+ ssize_t len;
+ if ((len = slurp(globbed, &buf)) < 0) {
+ /* slurp already logged an error. */
+ goto out;
}
/* TODO: refactor the following */
geometry->height};
focused = croot;
- tree_append_json(focused, globbed, NULL);
- free(globbed);
+ tree_append_json(focused, buf, len, NULL);
DLOG("appended tree, using new root\n");
croot = TAILQ_FIRST(&(croot->nodes_head));
}
restore_open_placeholder_windows(croot);
+ result = true;
- return true;
+out:
+ free(globbed);
+ free(buf);
+ return result;
}
/*
* will be mapped when i3 closes its connection (e.g. when
* restarting). This is not what we want, since some apps keep
* unmapped windows around and don’t expect them to suddenly be
- * mapped. See http://bugs.i3wm.org/1617 */
+ * mapped. See https://bugs.i3wm.org/1617 */
xcb_change_save_set(conn, XCB_SET_MODE_DELETE, con->window->id);
/* Ignore X11 errors for the ReparentWindow request.