foo-wm

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

commit 995411b826b53b3bee6e1b69d29bf9e5ec530659
parent a92881a6f5c32f4ecb6c56eb8fe5a9741b6e0e8a
Author: = <miles.sandlar@gmail.com>
Date:   Tue,  7 Aug 2012 09:24:46 -0400

Broke getNodeByDirection in a sep fn in tree.c
Used by shift and focus direction

Diffstat:
Msrc/commands.c | 17++---------------
Msrc/tree.c | 14++++++++++++++
Msrc/tree.h | 3+++
3 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/src/commands.c b/src/commands.c @@ -76,26 +76,13 @@ void move(int amount) { void shift(char * directionString) { int direction = directionStringToInt(directionString); - - int c = 0; - Node *insertNode = NULL, *currentNode = focusedNode; - while (!insertNode) { - insertNode = getBrotherByDirection(currentNode, direction); - if (!insertNode) { - if (currentNode -> parent) currentNode = currentNode -> parent; - else break; - } else if (c == 0 && !isClient(insertNode)) { - insertNode = insertNode -> child; - } - c++; - } + Node * insertNode = getBrotherByDirection(focusedNode, direction); if (insertNode) { Node * oldParent = focusedNode -> parent; unparentNode(focusedNode); placeNode(oldParent, oldParent -> x, oldParent -> y, oldParent -> width, oldParent -> height); - brotherNode(focusedNode, insertNode, direction == LEFT || direction == UP ? 0 : 1); placeNode(focusedNode -> parent, focusedNode -> parent -> x, focusedNode -> parent -> y, @@ -104,7 +91,6 @@ void shift(char * directionString) { focusNode(focusedNode, NULL, True, True); } else { - } } @@ -219,3 +205,4 @@ void kill(void) { viewNode -> x, viewNode -> y, viewNode -> width, viewNode -> height); } } + diff --git a/src/tree.c b/src/tree.c @@ -367,6 +367,20 @@ Node * getBrother(Node * node, int delta) { return node; } +/* Runs getBrotherByDirection til we get a client */ +Node * getNodeByDirection(Node * originNode, int direction) { + int c = 0; + Node *returnNode = NULL; + while (!returnNode) { + returnNode = getBrotherByDirection(originNode, direction); + if (!returnNode) { + if (originNode -> parent) originNode = originNode -> parent; + else break; + } else if (c == 0 && !isClient(returnNode)) { returnNode = returnNode-> child; } + c++; + } +} + /* Gets brother in specific direction * If can't get brother in direction, returns NULL * */ diff --git a/src/tree.h b/src/tree.h @@ -9,7 +9,10 @@ void focusNode(Node * node, XEvent * event, Bool setFocused, Bool focusPath); void unmapNode(Node * node); void placeNode(Node * node, int x, int y, int width, int height); void swapNodes(Node * a, Node * b); + Node * getBrother(Node * origin, int delta); +Node * getNodeByDirection(Node * originNode, int direction); +Node * getBrotherByDirection(Node * node, int direction); Node * getBrotherClient(Node * node, int direction); Node * getClosestClient(Node * node);