foo-wm

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

commit 5b245ca2c8a54cab1d5ed55ea579a53ba520dbdb
parent d5899c25974dbee01a24202728dc517362080020
Author: Miles Sandlar <miles.sandlar@gmail.com>
Date:   Mon,  2 Jul 2012 23:32:16 -0400

More reliable client killing with DestroyNotify

Diffstat:
Mconfig/.xbindkeysrc | 8++++----
Msrc/events.c | 6++++--
Msrc/tree.c | 35+++++++++++++++++++++--------------
3 files changed, 29 insertions(+), 20 deletions(-)

diff --git a/config/.xbindkeysrc b/config/.xbindkeysrc @@ -42,12 +42,12 @@ Mod4 + q "echo 'view parent set' > /home/mil/fifos/wm-fifo" - m:0x40 + c:20 - Mod4 + minus + m:0x40 + c:31 + Mod4 + i "echo 'view child set' > /home/mil/fifos/wm-fifo" - m:0x40 + c:21 - Mod4 + equal + m:0x40 + c:30 + Mod4 + u "dmenu-suggestions.rb | dmenu -h 60 -x 100 -y 400 -w 1200 -fn 'Envy Code R-20' -sb '#ffffff' -nf '#00ffd5' -nb '#1f1f1f' -sf '#000000' -b -p 'Command:' | xargs -0 -I INPUT handler INPUT" diff --git a/src/events.c b/src/events.c @@ -53,11 +53,13 @@ void eDestroyNotify(XEvent *event) { Node *n = getNodeByWindow(&(event -> xdestroywindow.window)); if (n == NULL) { return; } + fprintf(stderr," Getting cloest node to %p\n", n); activeNode = getClosestNode(n); - - fprintf(stderr, "Got the cloest node: %p", activeNode); + fprintf(stderr, "Got the cloest node, is: %p\n", activeNode); destroyNode(n); + fprintf(stderr, "Passed the destroyu node\n"); + fprintf(stderr, "Yo my viewnode is %p", viewNode); //Update view placeNode( viewNode, rootX, rootY, rootWidth, rootHeight); diff --git a/src/tree.c b/src/tree.c @@ -10,7 +10,7 @@ void crawlNode(Node * node, int level) { for (j = level; j > 0; j--) { fprintf(stderr, "|\t"); } if (isClient(node)) { - fprintf(stderr, "Client"); + fprintf(stderr, "Client (%p)", node); if (node == activeNode) { fprintf(stderr, " [FOCUS]"); } fprintf(stderr, "\n"); @@ -48,8 +48,8 @@ void focusNode(Node * n) { void destroyNode(Node * n) { if (n == NULL) { return; } - - if (n -> parent -> child == n && n -> previous == NULL) { + if ( n -> next == NULL && + (n -> parent -> child == n && n -> previous == NULL)) { destroyNode(n -> parent); return; } @@ -57,12 +57,8 @@ void destroyNode(Node * n) { //Unparent the node unparentNode(n); + fprintf(stderr, "Sucessfull destroy node\n"); //Recursivly destroy all children of the node - Node * child; - for (child = n -> child; child != NULL; child -> next) { - destroyNode(child); - } - if (n -> window != (Window)NULL) { /* Lookup * entry; @@ -73,13 +69,23 @@ void destroyNode(Node * n) { } */ XUnmapWindow(display, n -> window); + } else { + fprintf(stderr, "The child is %p\n", n -> child); + Node * child; + /* + for (child = n -> child; child != NULL; child = child -> next) { + destroyNode(child); + } + */ + } free(n); + } void unparentNode(Node *node) { - if (node -> parent == NULL) { return; } + if (node == NULL || node -> parent == NULL) { return; } fprintf(stderr, "unparent called"); @@ -101,8 +107,7 @@ void unparentNode(Node *node) { fprintf(stderr, "GOT HERE"); - //Move the node's parent's child if were it to our next node (maybe NULL) - if (node -> parent -> child == node) { + if ((node -> parent) -> child == node) { (node -> parent) -> child = node -> next; } @@ -202,19 +207,21 @@ Node * getNodeByWindow(Window * window) { } Node * getClosestNode(Node * node) { + fprintf(stderr, "\nWITHIN !! GetClosest node called on %p\n", node); Node * previousNode = node; Node * nextNode = node; - while (previousNode != NULL || nextNode != NULL) { + while (previousNode -> previous != NULL || nextNode -> next != NULL) { if (previousNode -> previous != NULL) { previousNode = previousNode -> previous; } if (nextNode -> next != NULL) { nextNode = nextNode -> next; } - if (isClient(nextNode) ) { return nextNode; } - if (isClient(previousNode)) { return previousNode; } + if (isClient(nextNode) && nextNode != node) { return nextNode; } + if (isClient(previousNode) && previousNode != node) { return previousNode; } } //If not returned by here must look for more nodes in the parent, recur + fprintf(stderr,"Calling get on %p\n", node -> parent); return getClosestNode(node -> parent); }