+
+ /* 5: keep focus on the current workspace */
+ con_focus(focus_next);
+}
+
+/*
+ * Returns the orientation of the given container (for stacked containers,
+ * vertical orientation is used regardless of the actual orientation of the
+ * container).
+ *
+ */
+int con_orientation(Con *con) {
+ /* stacking containers behave like they are in vertical orientation */
+ if (con->layout == L_STACKED)
+ return VERT;
+
+ return con->orientation;
+}
+
+/*
+ * Returns the container which will be focused next when the given container
+ * is not available anymore. Called in tree_close and con_move_to_workspace
+ * to properly restore focus.
+ *
+ */
+Con *con_next_focused(Con *con) {
+ Con *next;
+ /* floating containers are attached to a workspace, so we focus either the
+ * next floating container (if any) or the workspace itself. */
+ if (con->type == CT_FLOATING_CON) {
+ next = TAILQ_NEXT(con, floating_windows);
+ if (next == TAILQ_END(&(parent->floating_head)))
+ next = con_get_workspace(con);
+ return next;
+ }
+
+ /* try to focus the next container on the same level as this one */
+ next = TAILQ_NEXT(con, focused);
+
+ /* if that was not possible, go up to its parent */
+ if (next == TAILQ_END(&(parent->nodes_head)))
+ next = con->parent;
+
+ /* now go down the focus stack as far as
+ * possible, excluding the current container */
+ while (!TAILQ_EMPTY(&(next->focus_head)) &&
+ TAILQ_FIRST(&(next->focus_head)) != con)
+ next = TAILQ_FIRST(&(next->focus_head));
+
+ return next;
+}
+
+/*
+ * Returns a "relative" Rect which contains the amount of pixels that need to
+ * be added to the original Rect to get the final position (obviously the
+ * amount of pixels for normal, 1pixel and borderless are different).
+ *
+ */
+Rect con_border_style_rect(Con *con) {
+ switch (con_border_style(con)) {
+ case BS_NORMAL:
+ return (Rect){2, 0, -(2 * 2), -2};
+
+ case BS_1PIXEL:
+ return (Rect){1, 1, -2, -2};
+
+ case BS_NONE:
+ return (Rect){0, 0, 0, 0};
+
+ default:
+ assert(false);
+ }
+}
+
+/*
+ * Use this function to get a container’s border style. This is important
+ * because when inside a stack, the border style is always BS_NORMAL.
+ * For tabbed mode, the same applies, with one exception: when the container is
+ * borderless and the only element in the tabbed container, the border is not
+ * rendered.
+ *
+ */
+int con_border_style(Con *con) {
+ if (con->parent->layout == L_STACKED)
+ return BS_NORMAL;
+
+ return con->border_style;