foo-wm

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

commit f1253311bde3ec026d8de671a2f2c551c3b5bff1
parent e06f8a2a5685b34789be5f8df50f578e61360340
Author: Miles Sandlar <miles.sandlar@gmail.com>
Date:   Fri, 29 Jun 2012 18:20:45 -0400

DestroyNotify X Event Response. destroyClient()

Diffstat:
Msrc/events.c | 15+++++++++++++++
Msrc/tree.c | 40++++++++++++++++++++++++++++------------
2 files changed, 43 insertions(+), 12 deletions(-)

diff --git a/src/events.c b/src/events.c @@ -37,6 +37,20 @@ void eMapRequest(XEvent *event) { lookup = entry; } +void eDestroyNotify(XEvent *event) { + fprintf(stderr, "DESTROY NOTIFY RECIEVED"); + + Client *c = getClientByWindow(&(event -> xdestroywindow.window)); + destroyClient(c); + + //Update view + placeContainer( + rootContainer, 0, 0, + DisplayWidth (display, activeScreen), + DisplayHeight (display, activeScreen) + ); +} + void eConfigureRequest(XEvent *event) { fprintf(stderr, "Receiveced a Resize Request EVENT\n"); Client *c = getClientByWindow(&(event -> xconfigurerequest.window)); @@ -64,6 +78,7 @@ void eButtonPress(XEvent *event) { void handleXEvent(XEvent *event) { switch (event -> type) { case MapRequest: eMapRequest(event); break; + case DestroyNotify: eDestroyNotify(event); break; case ConfigureRequest: eConfigureRequest(event); break; case ButtonPress: eButtonPress(event); break; default: break; diff --git a/src/tree.c b/src/tree.c @@ -39,24 +39,40 @@ void dumpTree() { crawlContainer(rootContainer, 0); } +void unparentClient(Client *c) { + if (c -> parent != NULL) { + c -> parent = NULL; -int parentClient(Client * child, Container * parent) { - /* First client to be added to container */ - if (parent == NULL) { return 0; } - - //Moving the client - if (child -> parent != NULL) { - child -> parent = NULL; - - if (child -> next != NULL) { - (child -> next) -> previous = child -> previous; + if (c -> next != NULL) { + (c -> next) -> previous = c -> previous; } - if (child -> previous != NULL) { - (child -> previous) -> next = child -> next; + if (c -> previous != NULL) { + (c -> previous) -> next = c -> next; } } +} + +void destroyContainer(Container *c) { + +} + +void destroyClient(Client *c) { + if (c != NULL) { + fprintf(stderr, "Destorying %p\n", c); + unparentClient(c); + free(c); + } +} + + +int parentClient(Client * child, Container * parent) { + /* First client to be added to container */ + if (parent == NULL) { return 0; } + + //Moving the client + unparentClient(child); child -> parent = parent; if (parent -> client == NULL) {