foo-wm

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

commit a63c347a050852e9a6b7d71c5612d445f13cc511
parent f4ed770edc27fa6c28ac5e718ce9aa6616b9c27f
Author: = <miles.sandlar@gmail.com>
Date:   Thu, 26 Jul 2012 14:22:50 -0400

Minor bug fixes in selectNode

Diffstat:
Msrc/commands.c | 30++++++++++++++++++------------
Msrc/tree.c | 19+++++++++++++------
2 files changed, 31 insertions(+), 18 deletions(-)

diff --git a/src/commands.c b/src/commands.c @@ -36,18 +36,16 @@ void handleCommand(char* request) { dumpTree(); } else if (!strcmp(tokens[0], "layout")) { fprintf(stderr, "Setting layout to: %s", tokens[1]); + Node *setNode = selectedNode && selectedNode -> parent ? + selectedNode -> parent : focusedNode -> parent; + int newLayout = 0; + if (!strcmp(tokens[1], "vertical")) newLayout = VERTICAL; + else if (!strcmp(tokens[1], "horizontal")) newLayout = HORIZONTAL; + else if (!strcmp(tokens[1], "grid")) newLayout = GRID; + else if (!strcmp(tokens[1], "max")) newLayout = MAX; - Node *setNode = selectedNode && selectedNode -> parent ? selectedNode -> parent : focusedNode -> parent; - if (!strcmp(tokens[1], "vertical")) - setNode -> layout = VERTICAL; - else if (!strcmp(tokens[1], "horizontal")) - setNode -> layout = HORIZONTAL; - else if (!strcmp(tokens[1], "grid")) - setNode -> layout = GRID; - else if (!strcmp(tokens[1], "max")) - setNode -> layout = MAX; - + setNode -> layout = newLayout; placeNode(setNode, setNode -> x, setNode -> y, setNode -> width, setNode -> height); @@ -149,7 +147,6 @@ void zoom(int level) { * depending, there may be a new selectedNode & focusNode OR * just a new focusNode and no selectedNode */ void cycleFocus(int direction) { - if (direction != PREVIOUS && direction != NEXT) return; Node * newSelect = NULL; @@ -164,10 +161,19 @@ void cycleFocus(int direction) { newFocus = (newFocus -> focus) ? newFocus -> focus : newFocus -> child; } + fprintf(stderr, "The new focus will be: %p\n", newFocus); + fprintf(stderr, "The new selected will be: %p\n", newSelect); + + if ((newFocus && newFocus -> parent -> layout == MAX) || + (newSelect && newSelect -> parent -> layout == MAX)) { + fprintf(stderr, "\n\nRerender\n\n"); + } focusNode(newFocus, NULL); selectNode(newSelect, True); - if (!selectedNode) focusNode(newFocus, NULL); + + placeNode(viewNode, viewNode -> x, viewNode -> y, + viewNode -> width, viewNode -> height); } diff --git a/src/tree.c b/src/tree.c @@ -27,7 +27,7 @@ void crawlNode(Node * node, int level) { case 3: label = "Max"; break; } - fprintf(stderr, "Container (%p) %s", node, label); + fprintf(stderr, "Container (%p) %s (focus=%p)", node, label, node -> focus); if (node == selectedNode) fprintf(stderr, " [Selected]"); if (node == viewNode) fprintf(stderr, " [View]"); //fprintf(stderr, " || N[%p] P[%p]", node -> next, node -> previous); @@ -100,7 +100,10 @@ void focusNode(Node * n, XEvent * event) { void selectNode(Node * n, Bool setSelected) { if (!n) return; - if (setSelected == True) selectedNode = n; + if (setSelected == True) { + selectedNode = n; + if (n -> parent) n -> parent -> focus = n; + } Node *i; for (i = n -> child; i; i = i -> next) @@ -258,11 +261,12 @@ void placeNode(Node * node, int x, int y, int width, int height) { else callPlace = False; } + a -> x = x + (i % cols) * (width/cols) + pad; + a -> y = y + ((int)(i / cols)) * (height/rows) + pad; + a -> width = width / cols - (pad * 2); + a -> height = height / rows - (pad * 2); + if (callPlace) { - a -> x = x + (i % cols) * (width/cols) + pad; - a -> y = y + ((int)(i / cols)) * (height/rows) + pad; - a -> width = width / cols - (pad * 2); - a -> height = height / rows - (pad * 2); if (node -> layout == GRID) { //Two nodes, edge case for formula @@ -271,6 +275,9 @@ void placeNode(Node * node, int x, int y, int width, int height) { if (i + 1 == children) a -> width = x + width - a -> x - (pad * 2); } placeNode(a, a -> x, a -> y, a -> width, a -> height); + } else { + fprintf(stderr, "Going to call unmap on %p\n", a); + unmapNode(a); } } }