foo-wm

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

commit 837787b0e0d581467d23206db80ff99c2128e0b6
parent 64fbbfe36f86c6ecd514ff66f6859d7ce0b6de8d
Author: Miles Sandlar <miles.sandlar@gmail.com>
Date:   Mon,  9 Jul 2012 23:18:31 -0400

Addition of a max layout for nodes

Diffstat:
Msrc/commands.c | 12+++++++++---
Msrc/tree.c | 42++++++++++++++++++++++++++++++------------
2 files changed, 39 insertions(+), 15 deletions(-)

diff --git a/src/commands.c b/src/commands.c @@ -36,9 +36,15 @@ void handleCommand(char* request) { dumpTree(); } else if (!strcmp(tokens[0], "layout")) { fprintf(stderr, "Setting layout to: %s", tokens[1]); - if (!strcmp(tokens[1], "vertical")) focusedNode -> parent -> layout = 0; - else if (!strcmp(tokens[1], "horizontal")) focusedNode -> parent -> layout = 1; - else if (!strcmp(tokens[1], "grid")) focusedNode -> parent -> layout = 2; + if (!strcmp(tokens[1], "vertical")) + focusedNode -> parent -> layout = 0; + else if (!strcmp(tokens[1], "horizontal")) + focusedNode -> parent -> layout = 1; + else if (!strcmp(tokens[1], "grid")) + focusedNode -> parent -> layout = 2; + else if (!strcmp(tokens[1], "max")) + focusedNode -> parent -> layout = 3; + placeNode(focusedNode -> parent, (focusedNode -> parent) -> x, (focusedNode -> parent) -> y, (focusedNode -> parent) -> width, (focusedNode -> parent) -> height); diff --git a/src/tree.c b/src/tree.c @@ -1,7 +1,6 @@ #include <X11/Xlib.h> #include <stdio.h> #include <stdlib.h> - #include "fifo-wm.h" #include "tree.h" #include "lookup.h" @@ -24,7 +23,9 @@ void crawlNode(Node * node, int level) { case 0: label = "Vertical"; break; case 1: label = "Horizontal"; break; case 2: label = "Grid"; break; + case 3: label = "Max"; break; } + fprintf(stderr, "Container (%p) %s", node, label); if (node == selectedNode) fprintf(stderr, " [Selected]"); if (node == viewNode) fprintf(stderr, " [View]"); @@ -223,21 +224,38 @@ void placeNode(Node * node, int x, int y, int width, int height) { case 0: cols = children; rows = 1; break; case 1: cols = 1; rows = children; break; case 2: gridDimensions(children, &rows, &cols); break; + case 3: cols = 1; rows = 1; break; } + Bool callPlace; for (a = node -> child; a != NULL; a = a -> next, i++) { - a -> x = x + (i % cols) * (width/cols) + padding; - a -> y = y + ((int)(i / cols)) * (height/rows) + padding; - a -> width = width / cols - (padding * 2); - a -> height = height / rows - (padding * 2); - - if (node -> layout == 2) { - //Two nodes, edge case for formula - if (children == 2) a -> height = height - (padding * 2); - //Strecth the last child - if (i + 1 == children) a -> width = x + width - a -> x - (padding * 2); + fprintf(stderr, "yoyo"); + callPlace = True; + if (node -> layout == 3) { + fprintf(stderr, "MAXED"); + + if (focusedNode == a) { + i = 0; + } else { + fprintf(stderr, "RETURNING?"); + callPlace = False; + } + } + + if (callPlace != False) { + a -> x = x + (i % cols) * (width/cols) + padding; + a -> y = y + ((int)(i / cols)) * (height/rows) + padding; + a -> width = width / cols - (padding * 2); + a -> height = height / rows - (padding * 2); + + if (node -> layout == 2) { + //Two nodes, edge case for formula + if (children == 2) a -> height = height - (padding * 2); + //Strecth the last child + if (i + 1 == children) a -> width = x + width - a -> x - (padding * 2); + } + placeNode(a, a -> x, a -> y, a -> width, a -> height); } - placeNode(a, a -> x, a -> y, a -> width, a -> height); } } }