foo-wm

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

commit dbec02bfe9fd6b757ac496493d7c6b062c5d66e3
parent 25301386b868788aea0243c868287d015a68f8a7
Author: Miles Sandlar <miles.sandlar@gmail.com>
Date:   Wed, 18 Jul 2012 22:10:52 -0400

Root node reparented if selected &new window

Diffstat:
Msrc/commands.c | 23+++++++++--------------
Msrc/events.c | 17+++++++++++++----
Msrc/tree.c | 2+-
3 files changed, 23 insertions(+), 19 deletions(-)

diff --git a/src/commands.c b/src/commands.c @@ -83,17 +83,10 @@ void handleCommand(char* request) { if (!n) return; placeNode(viewNode, rootX, rootY, rootWidth, rootHeight); - selectNode(n, True); + if (isClient(n)) focusNode(n, NULL); + else selectNode(n, True); } - /* - if (!selectedNode || !selectedNode -> focus) - return; - else if (isClient(selectedNode -> focus)) - focusNode(selectedNode -> focus, NULL); - else - selectNode(selectedNode -> focus, True); - */ } } else if (!strcmp(tokens[0], "containerize")) { @@ -184,8 +177,8 @@ void containerize() { Node * newContainer = allocateNode(); if (selectedNode) { - if (selectedNode -> previous || selectedNode -> next) { - Node *insertNode; int insertPosition; + //if (selectedNode -> previous || selectedNode -> next) { + Node *insertNode; int insertPosition = -300; if (selectedNode -> previous) { insertNode = selectedNode -> previous; insertPosition = NEXT; } else if (selectedNode -> next) { @@ -193,12 +186,14 @@ void containerize() { } parentNode(selectedNode, newContainer); - brotherNode(newContainer, insertNode, insertPosition); + if (insertPosition != -300) { + brotherNode(newContainer, insertNode, insertPosition); + } placeNode(viewNode, rootX, rootY, rootWidth, rootHeight); - } + //} - } else if (focusedNode != NULL) { /* Working iwth a focused Client */ + } else if (focusedNode) { /* Working iwth a focused Client */ /* Containerizing a client that is one of many in an existing container */ if (focusedNode -> previous || focusedNode -> next) { Node *insertNode; int insertPosition; diff --git a/src/events.c b/src/events.c @@ -25,12 +25,21 @@ void eMapRequest(XEvent *event) { if (selectedNode) { fprintf(stderr,"Mapping based on selectedNode\n"); - parentNode(newNode, selectedNode); - placeNode(selectedNode, - selectedNode -> x, selectedNode -> y, - selectedNode -> width, selectedNode -> height); + if (selectedNode -> parent) { + brotherNode(newNode, selectedNode, 1); + placeNode(selectedNode -> parent, + selectedNode -> parent -> x, selectedNode -> parent -> y, + selectedNode -> parent -> width, selectedNode -> parent -> height); + } else { + fprintf(stderr, "Going to reparent the root node\n"); + + containerize(); + rootNode = viewNode = selectedNode -> parent; + brotherNode(newNode, viewNode -> child, 1); + placeNode(viewNode, rootX, rootY, rootWidth, rootHeight); + } } else if (focusedNode) { fprintf(stderr,"Mapping based on focusedNode\n"); diff --git a/src/tree.c b/src/tree.c @@ -185,7 +185,7 @@ void brotherNode(Node *node, Node * brother, int position) { void parentNode(Node *node, Node *parent) { fprintf(stderr, "Pareting node %p into parent %p\n", node, parent); - if (!parent) return; //Cant add to NULL + if (!node || !parent) return; //Cant add to NULL unparentNode(node); //Unparent then set the parent to new parent node -> parent = parent;