foo-wm

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

commit aad9d5db066c587eec1775e30b268076e1e69081
parent 4f7e45e17aa05e5168a66260d2886df90f5bede9
Author: = <miles.sandlar@gmail.com>
Date:   Wed, 15 Aug 2012 22:07:04 -0400

Bugfixes for directional focusing

Diffstat:
Msrc/foo-wm.c | 1-
Msrc/tree.c | 17++++++++++-------
Msrc/util.c | 2++
3 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/foo-wm.c b/src/foo-wm.c @@ -58,7 +58,6 @@ void handleEvents(void) { socketFd, (struct sockaddr*)&returnAddress, &returnAddressSize); - fprintf(stderr, "\n\nthe socket return FD IS %d\n\n", socketReturnFd); if (socketReturnFd != -1) { if ((commandsLength = recv(socketReturnFd, commands, sizeof(commands), 0)) > 1) { commands[commandsLength] = '\0'; diff --git a/src/tree.c b/src/tree.c @@ -194,8 +194,8 @@ void brotherNode(Node *node, Node * brother, int position) { //Shift previous pointer node -> previous = brother -> previous; if (node -> previous) node -> previous -> next = node; - brother -> previous = node; } + brother -> previous = node; } else if (position == 1) { node -> previous = brother; node -> next = brother -> next; @@ -391,6 +391,7 @@ Node * getClientByDirection(Node * originNode, int direction) { int c = 0; Node *returnNode = NULL; + while (!returnNode) { returnNode = getBrotherByDirection(originNode, direction); if (!returnNode) { @@ -425,6 +426,7 @@ Node * getBrotherByDirection(Node * node, int direction) { } + fprintf(stderr, "Getting grid dems for %d, Layout = %d\n", parentChildren, node -> parent -> layout); // Get the dimensions of the current grid int rows = 0, cols = 0; switch (node -> parent -> layout) { @@ -439,6 +441,8 @@ Node * getBrotherByDirection(Node * node, int direction) { break; } + + int dest; //Determine the brother switch (direction) { @@ -452,22 +456,21 @@ Node * getBrotherByDirection(Node * node, int direction) { break; case UP: dest = nodePosition - cols; - if (dest >= 0) { + if (dest > 0) { n = node; if (!node -> next && cols != 1 && isPrime(parentChildren)) dest++; - while (dest != nodePosition) { + while (dest != nodePosition) n = n -> previous; dest++; - } return n; } break; case DOWN: dest = nodePosition + cols; - if (dest <= parentChildren) { + if (rows == 1) { break; + } else if (dest <= parentChildren) { n = node; - while (dest != nodePosition) { + while (dest != nodePosition) n = n -> next; dest--; - } return n; } else if (dest <= parentChildren + 1 && isPrime(parentChildren)) { n = node; // Prime odd case diff --git a/src/util.c b/src/util.c @@ -34,6 +34,8 @@ Node * allocateNode() { } void gridDimensions(int children, int * rows, int * cols) { + if (children == 2) { *rows = 1; *cols = 2; return; } /* Edgecase */ + int square = (int) sqrt(children); int r = square;