foo-wm

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

commit 6a64a8849ff5db83920cb7e9c0deff1ae5e475bd
parent 07c9fff8a6cc31715cdf5b2e063b16e5f97ce6bf
Author: Miles Sandlar <miles.sandlar@gmail.com>
Date:   Tue, 17 Jul 2012 12:21:54 -0400

Fix logic destroyNode recursivly killing children
Previously the last child would linger

Diffstat:
Msrc/events.c | 14++++++++------
Msrc/tree.c | 28+++++++++++-----------------
2 files changed, 19 insertions(+), 23 deletions(-)

diff --git a/src/events.c b/src/events.c @@ -23,7 +23,7 @@ void eMapRequest(XEvent *event) { True, ButtonPressMask | ButtonReleaseMask, GrabModeAsync, GrabModeSync, None, None); - if (selectedNode != NULL) { + if (selectedNode) { fprintf(stderr,"Mapping based on selectedNode\n"); parentNode(newNode, selectedNode); @@ -32,7 +32,7 @@ void eMapRequest(XEvent *event) { selectedNode -> width, selectedNode -> height); - } else if (focusedNode != NULL) { + } else if (focusedNode) { fprintf(stderr,"Mapping based on focusedNode\n"); if (focusedNode == viewNode && isClient(viewNode)) { fprintf(stderr, "Just viewing a single client"); @@ -53,15 +53,18 @@ void eMapRequest(XEvent *event) { focusedNode -> parent -> height); } - } else { + } else if (viewNode) { //All we have to map on is the view node fprintf(stderr,"Mapping based on viewNode\n"); + parentNode(newNode, viewNode); placeNode( viewNode, viewNode -> x, viewNode -> y, viewNode -> width, viewNode -> height); + } else { + fprintf(stderr, "This shouldn't be possible...\n"); } addLookupEntry(newNode, &newNode -> window); @@ -72,15 +75,14 @@ void eDestroyNotify(XEvent *event) { fprintf(stderr, "DESTROY NOTIFY RECIEVED"); Node *n = getNodeByWindow(&(event -> xdestroywindow.window)); - if (n == NULL) { return; } + if (n == NULL) return; if (n == viewNode) { viewNode = n -> parent; fprintf(stderr, "Equals view node\n"); } destroyNode(n); - placeNode( viewNode, rootX, rootY, rootWidth, rootHeight); - + placeNode(viewNode, rootX, rootY, rootWidth, rootHeight); } void eConfigureRequest(XEvent *e) { diff --git a/src/tree.c b/src/tree.c @@ -113,17 +113,12 @@ void selectNode(Node * n, Bool setSelected) { void destroyNode(Node * n) { - fprintf(stderr, "PRE DESTROY\n"); - dumpTree(); - if (n == NULL) return; - if (n -> parent == NULL) return; - //Asking to destroy a node who once disowned would leave an empty node - //Recall destroyNode on parent - if ( n -> next == NULL && n -> parent -> child == n && - n -> previous == NULL && n -> parent -> parent != NULL) { - fprintf(stderr, "Calling destroy node on parent\n"); + //Recursvily unmap up any lone parents + if ( n -> parent && !n -> next && !n -> previous && + n -> parent -> child == n && n -> parent -> parent + && n -> parent != viewNode) { destroyNode(n -> parent); return; } @@ -131,21 +126,20 @@ void destroyNode(Node * n) { //Unparent the node unparentNode(n); - //Recursivly unmap all children of the node + //Recursivly unmap down all children of the node if (isClient(n)) { removeLookupEntry(&n -> window); XDestroyWindow(display, n -> window); } else { - fprintf(stderr, "The child is %p\n", n -> child); - if (n -> child -> next != NULL) { - Node * child; - for (child = n -> child; child != NULL; child = child -> next) { - destroyNode(child); - } - } + Node *destroy = n -> child; Node *next = NULL; + do { + next = destroy -> next; + destroyNode(destroy); + } while (next); } + //Set Focused Node if we just destroyed the focus, and free if (n == focusedNode) focusedNode = NULL; free(n); }