foo-wm

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

commit bca161cf9dc17bc15a52b624ffbfb1e064845831
parent 9d622e03936028f4189d341d69bcd4a6ce2a1415
Author: Miles Sandlar <miles.sandlar@gmail.com>
Date:   Sat,  7 Jul 2012 23:39:06 -0400

removeLookupEntry correctly removes and frees
Minor other related  changes

Diffstat:
Msrc/events.c | 7+------
Msrc/lookup.c | 29+++++++++++++++++++++++------
Msrc/lookup.h | 2+-
Msrc/tree.c | 2++
4 files changed, 27 insertions(+), 13 deletions(-)

diff --git a/src/events.c b/src/events.c @@ -49,10 +49,8 @@ void eMapRequest(XEvent *event) { } - focusNode(newNode); - - //Add a lookup entry addLookupEntry(newNode, &newNode -> window); + focusNode(newNode); } void eDestroyNotify(XEvent *event) { @@ -61,10 +59,7 @@ void eDestroyNotify(XEvent *event) { Node *n = getNodeByWindow(&(event -> xdestroywindow.window)); if (n == NULL) { return; } - focusedNode = getClosestClient(n); destroyNode(n); - - //Update view placeNode( viewNode, rootX, rootY, rootWidth, rootHeight); } diff --git a/src/lookup.c b/src/lookup.c @@ -1,5 +1,7 @@ #include <X11/Xlib.h> #include <stdlib.h> +#include <stdio.h> + #include "fifo-wm.h" #include "util.h" @@ -7,19 +9,34 @@ //Returns the client associated with given windowv Node * getNodeByWindow(Window * window) { Lookup *entry; - for (entry = lookup; entry != NULL; entry = entry -> previous) { - if (((int) *window) == entry -> window) + for (entry = lookup; entry != NULL; entry = entry -> previous) + if (((int) *window) == entry -> window) return entry -> node; - } return NULL; } -Node * removeLookupEntry(Window * window) { +void removeLookupEntry(Window * window) { + Lookup *cut; Lookup *entry; - for (entry = lookup; entry != NULL; entry = entry -> previous) { + + //Removing last entry in list + if (lookup -> window == (int) *window) { + entry = lookup -> previous; + free(lookup); + lookup = entry; + return; + } + + //Rmove any other entry in list + for (entry = lookup; entry -> previous != NULL; entry = entry -> previous) { + if ((int)*window == entry -> previous -> window) { + cut = entry -> previous; + entry -> previous = entry -> previous -> previous; + free(cut); + return; + } } - return NULL; } void addLookupEntry( Node * node, Window * window) { diff --git a/src/lookup.h b/src/lookup.h @@ -1,3 +1,3 @@ Node * getNodeByWindow(Window * window); -Node * removeLookupEntry(Window * window); +void removeLookupEntry(Window * window); void addLookupEntry( Node * node, Window * window); diff --git a/src/tree.c b/src/tree.c @@ -4,6 +4,7 @@ #include "fifo-wm.h" #include "tree.h" +#include "lookup.h" #include "util.h" #include "window.h" @@ -100,6 +101,7 @@ void destroyNode(Node * n) { dumpTree(); //Recursivly unmap 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);