]> git.sur5r.net Git - i3/i3/blobdiff - src/move.c
Set non-git version to 4.16.1-non-git.
[i3/i3] / src / move.c
index 58ce488d9d29e6a9f1b0541f6744f68e77150f9c..e28a91c6ff04e260bd7eb87f3edd66150f8e6832 100644 (file)
@@ -178,9 +178,7 @@ void insert_con_into(Con *con, Con *target, position_t position) {
  */
 static void attach_to_workspace(Con *con, Con *ws, direction_t direction) {
     con_detach(con);
-    con_fix_percent(con->parent);
-    CALL(con->parent, on_remove_child);
-
+    Con *old_parent = con->parent;
     con->parent = ws;
 
     if (direction == D_RIGHT || direction == D_DOWN) {
@@ -195,6 +193,9 @@ static void attach_to_workspace(Con *con, Con *ws, direction_t direction) {
      * does not make sense anyways. */
     con->percent = 0.0;
     con_fix_percent(ws);
+
+    con_fix_percent(old_parent);
+    CALL(old_parent, on_remove_child);
 }
 
 /*
@@ -298,9 +299,10 @@ void tree_move(Con *con, int direction) {
 
         /* easy case: the move is within this container */
         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)))) {
+            Con *swap = (direction == D_LEFT || direction == D_UP)
+                            ? TAILQ_PREV(con, nodes_head, nodes)
+                            : TAILQ_NEXT(con, nodes);
+            if (swap) {
                 if (!con_is_leaf(swap)) {
                     DLOG("Moving into our bordering branch\n");
                     target = con_descend_direction(swap, direction);
@@ -312,17 +314,15 @@ void tree_move(Con *con, int direction) {
                     insert_con_into(con, target, position);
                     goto end;
                 }
-                if (direction == D_LEFT || direction == D_UP)
+
+                DLOG("Swapping with sibling.\n");
+                if (direction == D_LEFT || direction == D_UP) {
                     TAILQ_SWAP(swap, con, &(swap->parent->nodes_head), nodes);
-                else
+                } 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);
-
-                DLOG("Swapped.\n");
                 ipc_send_window_event("move", con);
-                ewmh_update_wm_desktop();
                 return;
             }