foo-wm

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

commit 27315e4f75f6df303734825f9d8a664cd98adfea
parent c17b19a2b5e5d3f6744e5b3ffa3af76f83f3ea16
Author: Miles Sandlar <miles.sandlar@gmail.com>
Date:   Sun,  1 Jul 2012 23:41:59 -0400

Added unmapNode Recur fn, runs prior to placeNode
Makes it so that there aren't lingering windows mapped
Helpful for view command

Diffstat:
Msrc/commands.c | 11+++++++----
Msrc/events.c | 35+++++++++++++++++++++--------------
Msrc/tree.c | 27+++++++++++++++++++++++++++
Msrc/tree.h | 1+
4 files changed, 56 insertions(+), 18 deletions(-)

diff --git a/src/commands.c b/src/commands.c @@ -84,10 +84,13 @@ void handleCommand(char* request) { } else if (!strcmp(tokens[0], "view")) { if (!strcmp(tokens[1], "parent")) { - viewNode = viewNode -> parent; - placeNode(viewNode, 0, 0, - DisplayWidth(display, activeScreen), - DisplayHeight(display, activeScreen)); + if (viewNode -> parent != NULL) { + unmapNode(viewNode); + viewNode = viewNode -> parent; + placeNode(viewNode, 0, 0, + DisplayWidth(display, activeScreen), + DisplayHeight(display, activeScreen)); + } } else if (!strcmp(tokens[1], "child")) { viewNode = activeNode; diff --git a/src/events.c b/src/events.c @@ -18,10 +18,11 @@ void eMapRequest(XEvent *event) { if (activeNode == NULL) { } else { - fprintf(stderr, "The activeNode's layout is %d", activeNode -> layout); parentNode(newNode, activeNode); } + + focusNode(newNode); //Update the view placeNode( viewNode, 0, 0, @@ -44,7 +45,12 @@ void eDestroyNotify(XEvent *event) { Node *n = getNodeByWindow(&(event -> xdestroywindow.window)); if (n == NULL) { return; } fprintf(stderr, "YO it aint null mofo\n"); - destroyNode(n); + if (n -> parent -> child == n && n -> parent -> previous == NULL) { + if (activeNode == n -> parent) { activeNode = n -> parent -> parent; } + destroyNode(n -> parent); + } else { + destroyNode(n); + } //Update view placeNode( @@ -57,31 +63,31 @@ void eDestroyNotify(XEvent *event) { void eConfigureRequest(XEvent *event) { fprintf(stderr, "Receiveced a Resize Request EVENT\n"); - /* - Client *c = getClientByWindow(&(event -> xconfigurerequest.window)); + Node *n = getNodeByWindow(&(event -> xconfigurerequest.window)); + if (n != NULL) { XConfigureRequestEvent *configure = &(event -> xconfigurerequest); XWindowChanges changes = { configure -> x, configure -> y, configure -> width, configure -> height }; - XUnmapWindow(display, c -> window); - XConfigureWindow(display, c -> window, configure -> value_mask, &changes); - XMoveResizeWindow(display, c-> window, c -> x, c -> y, c -> width, c -> height); - XMapWindow(display, c -> window); - - */ + XUnmapWindow(display, n -> window); + XMoveResizeWindow(display, n -> window, n -> x, n -> y, n -> width, n -> height); + XMapWindow(display, n -> window); + } } +void eResizeRequest(XEvent *event) { + +} + void eButtonPress(XEvent *event) { fprintf(stderr, "Button Event Window is %p\n", &(event -> xbutton.subwindow)); //Root Window if (event -> xbutton.subwindow == None) { return; } - /* - Client *c = getClientByWindow(&(event -> xbutton.subwindow)); - focusClient(c); - */ + Node *n = getNodeByWindow(&(event -> xbutton.subwindow)); + focusNode(n); } void handleXEvent(XEvent *event) { @@ -89,6 +95,7 @@ void handleXEvent(XEvent *event) { case MapRequest: eMapRequest(event); break; case DestroyNotify: eDestroyNotify(event); break; case ConfigureRequest: eConfigureRequest(event); break; + case ResizeRequest: eResizeRequest(event); break; case ButtonPress: eButtonPress(event); break; default: break; } diff --git a/src/tree.c b/src/tree.c @@ -26,6 +26,19 @@ void dumpTree() { crawlNode(viewNode, 0); } +//Will only work on nodes with windows for now +void focusNode(Node * n) { + if ((n -> parent) -> focus == n) { return; } + + (n -> parent) -> focus = n; + placeNode(n -> parent, + (n -> parent) -> x, (n -> parent) -> y, + (n -> parent) -> width, (n -> parent) -> height); + + XRaiseWindow(display, n -> window); + XSetInputFocus(display, n -> window, RevertToPointerRoot, CurrentTime); +} + void destroyNode(Node * n) { if (n == NULL) { return; } @@ -48,6 +61,7 @@ void destroyNode(Node * n) { void unparentNode(Node *node) { if (node -> parent == NULL) { return; } + if ((node -> parent) -> focus == node) { if (node-> next != NULL) { (node -> parent) -> focus = node -> next; } if (node-> previous != NULL) { (node -> parent) -> focus = node -> previous; } @@ -55,6 +69,7 @@ void unparentNode(Node *node) { if (node -> next != NULL) { (node -> next) -> previous = node -> previous; + if (node == activeNode) { } } if (node -> previous != NULL) { @@ -84,6 +99,18 @@ void parentNode(Node *node, Node *parent) { } } +void unmapNode(Node * node) { + Node *n; + for (n = node -> child; n != NULL; n = n -> next) { + if (n -> window != (Window) NULL) { + XUnmapWindow(display, n -> window); + } else { + if (n -> child != NULL) { + unmapNode(n -> child); + } + } + } +} void placeNode(Node * node, int x, int y, int width, int height) { node -> x = x; node -> y = y; diff --git a/src/tree.h b/src/tree.h @@ -3,5 +3,6 @@ void dumpTree(); void destroyNode(Node * n); void unparentNode(Node * node); void parentNode(Node * node, Node * parent); +void unmapNode(Node * node); void placeNode(Node * node, int x, int y, int width, int height); Node * getNodeByWindow(Window * window);