foo-wm

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

commit 46cee08e49ca7f150a4fed030c3684ed2ffa9c25
parent 2d1ad07d04870a60ae15901172e5712c60edae59
Author: = <miles.sandlar@gmail.com>
Date:   Mon, 17 Sep 2012 21:53:04 -0400

Minor fixes for crashing

Diffstat:
Mconfig/.xbindkeysrc | 2+-
Msrc/commands.c | 7+++----
Msrc/lookup.c | 4++--
Msrc/tree.c | 14+++++++++-----
Msrc/util.c | 1+
5 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/config/.xbindkeysrc b/config/.xbindkeysrc @@ -108,7 +108,7 @@ # Dumps the Tree -"foo-wm-c /tmp/foo-wm.socket 'dump tree'" +"foo-wm-c /tmp/foo-wm.socket 'get tree'" m:0x40 + c:28 Mod4 + t diff --git a/src/commands.c b/src/commands.c @@ -147,11 +147,10 @@ void kill(void) { focusedNode -> parent -> parent : focusedNode -> parent; } - destroyNode(focusedNode); - dumpTree(); - - /* Give the closeset client of destroyed node focus and rerender */ + Node *oldFocus = focusedNode; focusNode(newFocus, NULL, True, True); + destroyNode(oldFocus); + rePlaceNode(viewNode); } } diff --git a/src/lookup.c b/src/lookup.c @@ -17,8 +17,8 @@ Node * getNodeByWindow(Window * window) { } void removeLookupEntry(Window * window) { - Lookup *cut; - Lookup *entry; + Lookup *cut = NULL; + Lookup *entry = NULL; //Removing last entry in list if (lookupTail -> window == (int) *window) { diff --git a/src/tree.c b/src/tree.c @@ -80,6 +80,7 @@ char * crawlNode(Node * node, int level) { sprintf(nodeInfo, "Client (%p)", node); returnString = stringAppend(returnString, nodeInfo); + if (node == rootNode) { returnString = stringAppend(returnString, " [Root]"); } if (node == focusedNode) { returnString = stringAppend(returnString, " [Focused]"); } if (node == viewNode) { returnString = stringAppend(returnString, " [View]"); } returnString = stringAppend(returnString, "\n"); @@ -134,7 +135,7 @@ long getBorderColor(Node * node, Bool focusPath) { * Node Returns * -------------------------------------------------------------------------- */ Node * getBrother(Node * node, int delta) { - fprintf(stderr, "Getting the brother node"); + if (!node) return NULL; while (delta > 0) { if (node -> next) @@ -244,10 +245,14 @@ void destroyNode(Node * n) { unparentNode(n); fprintf(stderr, "Made it here"); + if (n == focusedNode) focusedNode = NULL; + fprintf(stderr, "n is %p", n); + //Recursivly unmap down all children of the node if (isClient(n)) { removeLookupEntry(&n -> window); XDestroyWindow(display, n -> window); + free(n); } else if (n) { Node *destroy = n -> child; Node *next = NULL; do { @@ -257,11 +262,10 @@ void destroyNode(Node * n) { } else { next = NULL; } } while (next); + //if (n -> parent && n -> parent -> focus == n) n -> parent -> child = NULL; + free(n); } - //Set Focused Node if we just destroyed the focus, and free - if (n == focusedNode) focusedNode = NULL; - free(n); } @@ -494,6 +498,6 @@ void unparentNode(Node *node) { //Set our parent to NULL Node * oldParent = node -> parent; node -> parent = NULL; node -> next = NULL; node -> previous = NULL; - if (oldParent -> child == NULL) + if (!oldParent -> child) destroyNode(oldParent); } diff --git a/src/util.c b/src/util.c @@ -98,5 +98,6 @@ char * stringAppend(char * originalString, char * appendContent) { return returnString; */ + fprintf(stderr, "%s", appendContent); return originalString; }