]> git.sur5r.net Git - i3/i3/blobdiff - src/tree.c
Restore placeholder windows after restarting (Thanks Airblader).
[i3/i3] / src / tree.c
index bbd5e6a472f39f736ccf8a61c10534335ec1c666..b40ba2a2879203b503d7640937184fae91f3ea13 100644 (file)
@@ -76,7 +76,7 @@ bool tree_restore(const char *path, xcb_get_geometry_reply_t *geometry) {
 
     /* TODO: refactor the following */
     croot = con_new(NULL, NULL);
-    croot->rect = (Rect) {
+    croot->rect = (Rect){
         geometry->x,
         geometry->y,
         geometry->width,
@@ -104,6 +104,8 @@ bool tree_restore(const char *path, xcb_get_geometry_reply_t *geometry) {
         TAILQ_INSERT_HEAD(&(croot->nodes_head), __i3, nodes);
     }
 
+    restore_open_placeholder_windows(croot);
+
     return true;
 }
 
@@ -118,7 +120,7 @@ void tree_init(xcb_get_geometry_reply_t *geometry) {
     croot->name = "root";
     croot->type = CT_ROOT;
     croot->layout = L_SPLITH;
-    croot->rect = (Rect) {
+    croot->rect = (Rect){
         geometry->x,
         geometry->y,
         geometry->width,
@@ -237,7 +239,7 @@ bool tree_close(Con *con, kill_window_t kill_window, bool dont_kill_parent, bool
              * unmap the window,
              * then reparent it to the root window. */
             xcb_change_window_attributes(conn, con->window->id,
-                                         XCB_CW_EVENT_MASK, (uint32_t[]) {XCB_NONE});
+                                         XCB_CW_EVENT_MASK, (uint32_t[]){XCB_NONE});
             xcb_unmap_window(conn, con->window->id);
             cookie = xcb_reparent_window(conn, con->window->id, root, 0, 0);
 
@@ -407,8 +409,7 @@ void tree_split(Con *con, orientation_t orientation) {
     Con *parent = con->parent;
 
     /* Force re-rendering to make the indicator border visible. */
-    FREE(con->deco_render_params);
-    FREE(parent->deco_render_params);
+    con_force_split_parents_redraw(con);
 
     /* if we are in a container whose parent contains only one
      * child (its split functionality is unused so far), we just change the
@@ -599,33 +600,38 @@ static bool _tree_next(Con *con, char way, orientation_t orientation, bool wrap)
     Con *parent = con->parent;
 
     if (con->type == CT_FLOATING_CON) {
+        if (orientation != HORIZ)
+            return false;
+
         /* left/right focuses the previous/next floating container */
-        if (orientation == HORIZ) {
-            Con *next;
+        Con *next;
+        if (way == 'n')
+            next = TAILQ_NEXT(con, floating_windows);
+        else
+            next = TAILQ_PREV(con, floating_head, floating_windows);
+
+        /* If there is no next/previous container, wrap */
+        if (!next) {
             if (way == 'n')
-                next = TAILQ_NEXT(con, floating_windows);
+                next = TAILQ_FIRST(&(parent->floating_head));
             else
-                next = TAILQ_PREV(con, floating_head, floating_windows);
-
-            /* If there is no next/previous container, wrap */
-            if (!next) {
-                if (way == 'n')
-                    next = TAILQ_FIRST(&(parent->floating_head));
-                else
-                    next = TAILQ_LAST(&(parent->floating_head), floating_head);
-            }
-
-            /* Still no next/previous container? bail out */
-            if (!next)
-                return false;
+                next = TAILQ_LAST(&(parent->floating_head), floating_head);
+        }
 
-            con_focus(con_descend_focused(next));
-            return true;
-        } else {
-            /* up/down cycles through the Z-index */
-            /* TODO: implement cycling through the z-index */
+        /* Still no next/previous container? bail out */
+        if (!next)
             return false;
+
+        /* Raise the floating window on top of other windows preserving
+         * relative stack order */
+        while (TAILQ_LAST(&(parent->floating_head), floating_head) != next) {
+            Con *last = TAILQ_LAST(&(parent->floating_head), floating_head);
+            TAILQ_REMOVE(&(parent->floating_head), last, floating_windows);
+            TAILQ_INSERT_HEAD(&(parent->floating_head), last, floating_windows);
         }
+
+        con_focus(con_descend_focused(next));
+        return true;
     }
 
     /* If the orientation does not match or there is no other con to focus, we