foo-wm

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

commit 3f5caafe7ddf7e0813f16eab375a262e0095dd41
parent 01b5bd5961525c2e52bd8db73cc125b830a7dcec
Author: Miles Sandlar <miles.sandlar@gmail.com>
Date:   Mon, 16 Jul 2012 13:17:54 -0400

Improved fully functioning cycleFocus
cycleFocus cycles the focus within the current selected/focused node
Replaces old implementation which just delt with clients

Diffstat:
Msrc/commands.c | 58+++++++++++++++-------------------------------------------
1 file changed, 15 insertions(+), 43 deletions(-)

diff --git a/src/commands.c b/src/commands.c @@ -114,40 +114,6 @@ void handleCommand(char* request) { } } -/* Gets the brother client in given direction - * Does not loop */ -Node * getClient (Node *start, int direction) { - Node *n = (direction == 0) ? start -> previous : start -> next; - while (n) - if (isClient(n)) return n; - else if (direction == 0) n = n -> previous; - else if (direction == 1) n = n -> next; - - return n; -} - -/* -void cycleFocus(int direction) { - Node *next = NULL; Node *loopback = NULL; - - if (direction == 0) { - next = getClient(focusedNode, 0); - if (!isClient(next)) { - loopback = focusedNode; - while (loopback -> next != NULL) loopback = loopback-> next; - next = isClient(loopback) ? loopback : getClient(loopback, 0); - } - } else if (direction == 1) { - next = getClient(focusedNode, 1); - if (!isClient(next)) { - loopback = focusedNode -> parent -> child; - next = (isClient(loopback)) ? loopback : getClient(loopback, 1); - } - } - if (next) focusNode(next, NULL); -} -*/ - /* If there is a selectedNode, updates focus * depending, there may be a new selectedNode & focusNode OR * just a new focusNode and no selectedNode */ @@ -155,10 +121,21 @@ void cycleFocus(int direction) { if (direction != 0 && direction != 1) return; Node * newSelect = NULL; - Node * focusOrigin = selectedNode ? - selectedNode : focusedNode; - Node * newFocus = direction == 0 ? - focusOrigin -> previous : focusOrigin -> next; + Node * focusOrigin = selectedNode ? selectedNode : focusedNode; + Node * newFocus = NULL; + //Loopback incase, + //TODO: Could use focused node starting to make faster instead of focusOrigin? + if (direction == 0) { + if (!(newFocus = focusOrigin -> previous)) { + newFocus = focusOrigin; + while (newFocus -> next != NULL) + newFocus = newFocus -> next; + } + } else { + if (!(newFocus = focusOrigin -> next)) { + newFocus = focusOrigin -> parent -> child; + } + } //Alright we have a prvious, now figure out focus & select //First time around and were selecting a container! @@ -168,14 +145,9 @@ void cycleFocus(int direction) { while (!isClient(newFocus)) newFocus = (newFocus -> focus) ? newFocus -> focus : newFocus -> child; - - } else { - //End of the linked list, will need a loopback } - fprintf(stderr, "The New Select is %p\nThe new focus is %p\n", newSelect, newFocus); - focusNode(newFocus, NULL); selectNode(newSelect, True); }