foo-wm

(Archived) Experimental Zooming IPC-based WM
git clone http://milesalan.com/git/foo-wm
Log | Files | Refs | Mirror | README | LICENSE

commit 99d9b59e532f9b76ac9fb25641706a375b08f0c2
parent ebd269c344673863cb76a0c44879c8aba6a4de60
Author: = <miles.sandlar@gmail.com>
Date:   Tue, 23 Oct 2012 20:14:26 -0400

Swap nodes updating parent & child appropriatly

Diffstat:
Msrc/tree.c | 13++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/tree.c b/src/tree.c @@ -407,14 +407,17 @@ void rePlaceNode(Node * node) { void swapNodes(Node * a, Node * b) { if (!a || !b || a == b) return; - - /* First child / start of linked list */ + /* Update Parent / Parent -> Child Pointer */ Node *temp = NULL; - if (a -> parent -> child == a) a -> parent -> child = b; - else if (b -> parent -> child == b) b -> parent -> child = a; + /* Parent Client Server */ + temp = a -> parent; a -> parent = b -> parent; + if (a -> parent && a -> parent -> child == b) a -> parent -> child = a; + b -> parent = temp; + if (b -> parent && b -> parent -> child == a) b -> parent -> child = b; + /* Update Previous Pointer */ - temp = a -> previous; a -> previous = b -> previous; + temp = a -> previous; a -> previous = b -> previous; if (a -> previous) a -> previous -> next = a; b -> previous = temp; if (b -> previous) b -> previous -> next = b;