]> git.sur5r.net Git - i3/i3/blobdiff - src/move.c
format **/*.c with clang-format-3.5
[i3/i3] / src / move.c
index 284c4f38726314415884c3369ad90058ac789f3b..42510d520823ec98e4dfcbb0edd116bb282ca444 100644 (file)
@@ -11,7 +11,8 @@
  */
 #include "all.h"
 
-typedef enum { BEFORE, AFTER } position_t;
+typedef enum { BEFORE,
+               AFTER } position_t;
 
 /*
  * This function detaches 'con' from its parent and inserts it either before or
@@ -99,6 +100,7 @@ static void attach_to_workspace(Con *con, Con *ws, direction_t direction) {
  *
  */
 static void move_to_output_directed(Con *con, direction_t direction) {
+    Con *old_ws = con_get_workspace(con);
     Con *current_output_con = con_get_output(con);
     Output *current_output = get_output_by_name(current_output_con->name);
     Output *output = get_output_next(direction, current_output, CLOSEST_OUTPUT);
@@ -117,6 +119,16 @@ static void move_to_output_directed(Con *con, direction_t direction) {
     }
 
     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_focus_event(ws, old_ws);
 }
 
 /*
@@ -141,7 +153,7 @@ void tree_move(int direction) {
     if (con->parent->type == CT_WORKSPACE && con_num_children(con->parent) == 1) {
         /* This is the only con on this workspace */
         move_to_output_directed(con, direction);
-        goto end;
+        return;
     }
 
     orientation_t o = (direction == D_LEFT || direction == D_RIGHT ? HORIZ : VERT);
@@ -173,22 +185,22 @@ void tree_move(int direction) {
         if (same_orientation == con->parent) {
             DLOG("We are in the same container\n");
             Con *swap;
-            if ((swap = (direction == D_LEFT || direction == D_UP ?
-                          TAILQ_PREV(con, nodes_head, nodes) :
-                          TAILQ_NEXT(con, nodes)))) {
+            if ((swap = (direction == D_LEFT || direction == D_UP ? TAILQ_PREV(con, nodes_head, nodes) : TAILQ_NEXT(con, nodes)))) {
                 if (!con_is_leaf(swap)) {
                     DLOG("Moving into our bordering branch\n");
                     target = con_descend_direction(swap, direction);
                     position = (con_orientation(target->parent) != o ||
-                            direction == D_UP ||
-                            direction == D_LEFT ?
-                            AFTER : BEFORE);
+                                        direction == D_UP ||
+                                        direction == D_LEFT
+                                    ? AFTER
+                                    : BEFORE);
                     insert_con_into(con, target, position);
                     goto end;
                 }
                 if (direction == D_LEFT || direction == D_UP)
                     TAILQ_SWAP(swap, con, &(swap->parent->nodes_head), nodes);
-                else TAILQ_SWAP(con, swap, &(swap->parent->nodes_head), nodes);
+                else
+                    TAILQ_SWAP(con, swap, &(swap->parent->nodes_head), nodes);
 
                 TAILQ_REMOVE(&(con->parent->focus_head), con, focused);
                 TAILQ_INSERT_HEAD(&(swap->parent->focus_head), con, focused);
@@ -201,7 +213,7 @@ void tree_move(int direction) {
                 /*  If we couldn't find a place to move it on this workspace,
                  *  try to move it to a workspace on a different output */
                 move_to_output_directed(con, direction);
-                goto end;
+                return;
             }
 
             /* If there was no con with which we could swap the current one,
@@ -225,17 +237,16 @@ void tree_move(int direction) {
 
     DLOG("above = %p\n", above);
 
-    Con *next = (direction == D_UP || direction == D_LEFT ?
-            TAILQ_PREV(above, nodes_head, nodes) :
-            TAILQ_NEXT(above, nodes));
+    Con *next = (direction == D_UP || direction == D_LEFT ? TAILQ_PREV(above, nodes_head, nodes) : TAILQ_NEXT(above, nodes));
 
     if (next && !con_is_leaf(next)) {
         DLOG("Moving into the bordering branch of our adjacent container\n");
         target = con_descend_direction(next, direction);
         position = (con_orientation(target->parent) != o ||
-                direction == D_UP ||
-                direction == D_LEFT ?
-                AFTER : BEFORE);
+                            direction == D_UP ||
+                            direction == D_LEFT
+                        ? AFTER
+                        : BEFORE);
         insert_con_into(con, target, position);
     } else {
         DLOG("Moving into container above\n");