]> git.sur5r.net Git - i3/i3/blobdiff - src/tree.c
tree_restore: Check croot
[i3/i3] / src / tree.c
index 6c6a614e22d46479381e74447fd12f55dd378bb1..5a7c5dfa3c7f37be659b0e4b0a7025ef22fdbef8 100644 (file)
@@ -92,6 +92,10 @@ bool tree_restore(const char *path, xcb_get_geometry_reply_t *geometry) {
 
     DLOG("appended tree, using new root\n");
     croot = TAILQ_FIRST(&(croot->nodes_head));
+    if (!croot) {
+        /* tree_append_json failed. Continuing here would segfault. */
+        goto out;
+    }
     DLOG("new root = %p\n", croot);
     Con *out = TAILQ_FIRST(&(croot->nodes_head));
     DLOG("out = %p\n", out);
@@ -567,9 +571,16 @@ static bool _tree_next(Con *con, char way, orientation_t orientation, bool wrap)
         if (!workspace)
             return false;
 
-        Con *focus = con_descend_tiling_focused(workspace);
-        if (focus == workspace) {
-            focus = con_descend_focused(workspace);
+        /* Use descend_focused first to give higher priority to floating or
+         * tiling fullscreen containers. */
+        Con *focus = con_descend_focused(workspace);
+        if (focus->fullscreen_mode == CF_NONE) {
+            Con *focus_tiling = con_descend_tiling_focused(workspace);
+            /* If descend_tiling returned a workspace then focus is either a
+             * floating container or the same workspace. */
+            if (focus_tiling != workspace) {
+                focus = focus_tiling;
+            }
         }
 
         workspace_show(workspace);