+ * Moves the given container to the closest output in the given direction if
+ * such an output exists.
+ *
+ */
+static void move_to_output_directed(Con *con, direction_t direction) {
+ Con *old_ws = con_get_workspace(con);
+ Output *current_output = get_output_for_con(con);
+ Output *output = get_output_next(direction, current_output, CLOSEST_OUTPUT);
+
+ if (!output) {
+ DLOG("No output in this direction found. Not moving.\n");
+ return;
+ }
+
+ Con *ws = NULL;
+ GREP_FIRST(ws, output_get_content(output->con), workspace_is_visible(child));
+
+ if (!ws) {
+ DLOG("No workspace on output in this direction found. Not moving.\n");
+ return;
+ }
+
+ attach_to_workspace(con, ws, direction);
+
+ /* fix the focus stack */
+ con_focus(con);
+
+ /* force re-painting the indicators */
+ FREE(con->deco_render_params);
+
+ tree_flatten(croot);
+
+ ipc_send_workspace_event("focus", ws, old_ws);
+}
+
+/*
+ * Moves the given container in the given direction (D_LEFT, D_RIGHT,