foo-wm

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

commit 7c377994da804b672e3a88748211631d5cd02b73
parent 6e78e14106d19888b70a734b2a02691c798fbfb9
Author: Miles Sandlar <miles.sandlar@gmail.com>
Date:   Sat,  7 Jul 2012 14:50:27 -0400

More reliable containerize() function.
Semi-stable

Diffstat:
Msrc/commands.c | 211+++++++++++++++++++++++++++++++++++++++++--------------------------------------
1 file changed, 110 insertions(+), 101 deletions(-)

diff --git a/src/commands.c b/src/commands.c @@ -54,140 +54,149 @@ void focus(int direction) { void containerize() { - if (selectedNode != NULL) { - + Node * newContainer = allocateNode(); - } else if (focusedNode != NULL) { /* Working iwth a focused Client */ - Node * newContainer = allocateNode(); - /* Containerizing a client that is one of many in an existing container */ - if (focusedNode -> previous != NULL || focusedNode -> next != NULL) { + if (selectedNode != NULL) { + if (selectedNode -> previous != NULL || selectedNode -> next != NULL) { Node *insertNode; int insertPosition; - fprintf(stderr, "Containerizing, using some ref brother\n"); - if (focusedNode -> previous != NULL) { - insertNode = focusedNode -> previous; insertPosition = 1; + if (selectedNode -> previous != NULL) { + insertNode = selectedNode -> previous; insertPosition = 1; } else if (focusedNode -> next != NULL) { - insertNode = focusedNode -> next; insertPosition = 0; + insertNode = selectedNode -> next; insertPosition = 0; } - parentNode(focusedNode, newContainer); - - dumpTree(); - fprintf(stderr, "Going to brother %p %d", insertNode, insertPosition); - + parentNode(selectedNode, newContainer); brotherNode(newContainer, insertNode, insertPosition); - placeNode(viewNode, rootX, rootY, rootWidth, rootHeight); + } + + + } else if (focusedNode != NULL) { /* Working iwth a focused Client */ + /* Containerizing a client that is one of many in an existing container */ + if (focusedNode -> previous != NULL || focusedNode -> next != NULL) { + Node *insertNode; int insertPosition; + fprintf(stderr, "Containerizing, using some ref brother\n"); + if (focusedNode -> previous != NULL) { + insertNode = focusedNode -> previous; insertPosition = 1; + } else if (focusedNode -> next != NULL) { + insertNode = focusedNode -> next; insertPosition = 0; + } - } else { /* Containerizing client that is alone in container */ + parentNode(focusedNode, newContainer); + brotherNode(newContainer, insertNode, insertPosition); + placeNode(viewNode, rootX, rootY, rootWidth, rootHeight); + + } else { /* Containerizing client that is alone in container */ + + } + } else { + //Defaulted with just a view node } - } else { - //Defaulted with just a view node } -} -void kill() { - dumpTree(); - fprintf(stderr, "Destroying Client %p\n", focusedNode); + void kill() { + dumpTree(); + fprintf(stderr, "Destroying Client %p\n", focusedNode); - if (isClient(focusedNode)) { + if (isClient(focusedNode)) { - /* Save closest client and destroy node */ - Node *newFocus = getClosestClient(focusedNode); - destroyNode(focusedNode); + /* Save closest client and destroy node */ + Node *newFocus = getClosestClient(focusedNode); + destroyNode(focusedNode); - dumpTree(); + dumpTree(); - /* Give the closeset client of destroyed node focus and rerender */ - focusNode(newFocus); - placeNode(viewNode, - viewNode -> x, viewNode -> y, - viewNode -> width, viewNode -> height); + /* Give the closeset client of destroyed node focus and rerender */ + focusNode(newFocus); + placeNode(viewNode, + viewNode -> x, viewNode -> y, + viewNode -> width, viewNode -> height); + } } -} -void handleCommand(char* request) { - fprintf(stderr, "Recv from FIFO: %s", request); + void handleCommand(char* request) { + fprintf(stderr, "Recv from FIFO: %s", request); - //Array to contain pointers to tokens, max of 5 tokens - char *tokens[5]; + //Array to contain pointers to tokens, max of 5 tokens + char *tokens[5]; - int counter = 0; - char *lastToken, *token; - for ( token = strtok_r(request, " ", &lastToken); token; token = strtok_r(NULL, " ", &lastToken)) { - tokens[counter++] = token; - fprintf(stderr, "Adding Token %s\n", token); - } + int counter = 0; + char *lastToken, *token; + for ( token = strtok_r(request, " ", &lastToken); token; token = strtok_r(NULL, " ", &lastToken)) { + tokens[counter++] = token; + fprintf(stderr, "Adding Token %s\n", token); + } - if (!strcmp(tokens[0], "dump")) { - 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; - placeNode(focusedNode -> parent, - (focusedNode -> parent) -> x, (focusedNode -> parent) -> y, - (focusedNode -> parent) -> width, (focusedNode -> parent) -> height); - - } else if (!strcmp(tokens[0], "focus")) { - if (!strcmp(tokens[1], "left")) focus(0); - else if (!strcmp(tokens[1], "up")) focus(1); - else if (!strcmp(tokens[1], "right")) focus(2); - else if (!strcmp(tokens[1], "down")) focus(3); - - } else if (!strcmp(tokens[0], "select")) { - if (!strcmp(tokens[1], "parent")) { - fprintf(stderr, "Selecting parent node\n"); - if (selectedNode == NULL) { - fprintf(stderr, "Selected Node is NULL\n"); - selectNode(focusedNode -> parent, True); - } else { - if (selectedNode -> parent != NULL) { - fprintf(stderr, "Selecting from Parent\n"); - selectNode(selectedNode -> parent, True); + if (!strcmp(tokens[0], "dump")) { + 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; + placeNode(focusedNode -> parent, + (focusedNode -> parent) -> x, (focusedNode -> parent) -> y, + (focusedNode -> parent) -> width, (focusedNode -> parent) -> height); + + } else if (!strcmp(tokens[0], "focus")) { + if (!strcmp(tokens[1], "left")) focus(0); + else if (!strcmp(tokens[1], "up")) focus(1); + else if (!strcmp(tokens[1], "right")) focus(2); + else if (!strcmp(tokens[1], "down")) focus(3); + + } else if (!strcmp(tokens[0], "select")) { + if (!strcmp(tokens[1], "parent")) { + fprintf(stderr, "Selecting parent node\n"); + if (selectedNode == NULL) { + fprintf(stderr, "Selected Node is NULL\n"); + selectNode(focusedNode -> parent, True); + } else { + if (selectedNode -> parent != NULL) { + fprintf(stderr, "Selecting from Parent\n"); + selectNode(selectedNode -> parent, True); + } } - } - } else if (!strcmp(tokens[1], "next")) { + } else if (!strcmp(tokens[1], "next")) { - } else if (!strcmp(tokens[1], "previous")) { + } else if (!strcmp(tokens[1], "previous")) { - } + } - } else if (!strcmp(tokens[0], "containerize")) { + } else if (!strcmp(tokens[0], "containerize")) { - if (!strcmp(tokens[1], "client")) containerize(); + if (!strcmp(tokens[1], "client")) containerize(); - } else if (!strcmp(tokens[0], "view")) { + } else if (!strcmp(tokens[0], "view")) { - if (!strcmp(tokens[1], "parent")) { - if (viewNode -> parent != NULL) { - unmapNode(viewNode); - viewNode = viewNode -> parent; - placeNode(viewNode, rootX, rootY, rootWidth, rootHeight); - } + if (!strcmp(tokens[1], "parent")) { + if (viewNode -> parent != NULL) { + unmapNode(viewNode); + viewNode = viewNode -> parent; + placeNode(viewNode, rootX, rootY, rootWidth, rootHeight); + } - } else if (!strcmp(tokens[1], "child")) { + } else if (!strcmp(tokens[1], "child")) { - if (focusedNode != viewNode) { - Node *n = focusedNode; - while (n -> parent != viewNode && n != NULL) { n = n -> parent; } + if (focusedNode != viewNode) { + Node *n = focusedNode; + while (n -> parent != viewNode && n != NULL) { n = n -> parent; } - unmapNode(viewNode); - viewNode = n; - placeNode(viewNode, rootX, rootY, rootWidth, rootHeight); + unmapNode(viewNode); + viewNode = n; + placeNode(viewNode, rootX, rootY, rootWidth, rootHeight); + } + } + } else if (!strcmp(tokens[0], "kill")) { + if (!strcmp(tokens[1], "client")) { + kill(); + } else if (!strcmp(tokens[1], "container")) { + dumpTree(); + fprintf(stderr, "Destroy Container %p\n", focusedNode -> parent); + //destroyContainer(currentContainer); + dumpTree(); } - } - } else if (!strcmp(tokens[0], "kill")) { - if (!strcmp(tokens[1], "client")) { - kill(); - } else if (!strcmp(tokens[1], "container")) { - dumpTree(); - fprintf(stderr, "Destroy Container %p\n", focusedNode -> parent); - //destroyContainer(currentContainer); - dumpTree(); } } -}