Con *result = con;
while (result != NULL && result->type != CT_WORKSPACE)
result = result->parent;
- assert(result != NULL);
return result;
}
+/*
+ * Searches parenst of the given 'con' until it reaches one with the specified
+ * 'orientation'. Aborts when it comes across a floating_con.
+ *
+ */
Con *con_parent_with_orientation(Con *con, orientation_t orientation) {
DLOG("Searching for parent of Con %p with orientation %d\n", con, orientation);
Con *parent = con->parent;
* borderless and the only element in the tabbed container, the border is not
* rendered.
*
+ * For children of a CT_DOCKAREA, the border style is always none.
+ *
*/
int con_border_style(Con *con) {
Con *fs = con_get_fullscreen_con(con->parent);
if (con->parent->layout == L_TABBED && con->border_style != BS_NORMAL)
return (con_num_children(con->parent) == 1 ? con->border_style : BS_NORMAL);
+ if (con->parent->type == CT_DOCKAREA)
+ return BS_NONE;
+
return con->border_style;
}
con->layout = layout;
}
+/*
+ * Callback which will be called when removing a child from the given con.
+ * Kills the container if it is empty and replaces it with the child if there
+ * is exactly one child.
+ *
+ */
static void con_on_remove_child(Con *con) {
DLOG("on_remove_child\n");
- /* Nothing to do for workspaces */
- if (con->type == CT_WORKSPACE || con->type == CT_OUTPUT || con->type == CT_ROOT) {
+ /* Every container 'above' (in the hierarchy) the workspace content should
+ * not be closed when the last child was removed */
+ if (con->type == CT_WORKSPACE ||
+ con->type == CT_OUTPUT ||
+ con->type == CT_ROOT ||
+ con->type == CT_DOCKAREA) {
DLOG("not handling, type = %d\n", con->type);
return;
}
tree_close(con, false, false);
return;
}
-
- /* If we did not close the container, check if we have only a single child left */
- if (children == 1) {
- Con *child = TAILQ_FIRST(&(con->nodes_head));
- Con *parent = con->parent;
- DLOG("Container has only one child, replacing con %p with child %p\n", con, child);
-
- /* TODO: refactor it into con_swap */
- TAILQ_REPLACE(&(parent->nodes_head), con, child, nodes);
- TAILQ_REPLACE(&(parent->focus_head), con, child, focused);
- if (focused == con)
- focused = child;
- child->parent = parent;
- child->percent = 0.0;
- con_fix_percent(parent);
-
- con->parent = NULL;
- x_con_kill(con);
- free(con->name);
- TAILQ_REMOVE(&all_cons, con, all_cons);
- free(con);
-
- return;
- }
}