foo-wm

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

commit 460139602f7c73b6eaf1d7b1e4706eae5e9a8503
parent b95be5c61e53982f76478460ccc0f59b6b7c4f94
Author: = <miles.sandlar@gmail.com>
Date:   Tue, 21 Aug 2012 14:36:23 -0400

More cleanup and getBorderColor broke into own fnc

Diffstat:
MREADME.md | 12++----------
Mconfig/.xbindkeysrc | 10+++++-----
Msrc/commands.c | 17+++++++++++------
Msrc/commands.h | 2+-
Msrc/tree.c | 38+++++++++++++++++++++-----------------
5 files changed, 40 insertions(+), 39 deletions(-)

diff --git a/README.md b/README.md @@ -68,19 +68,11 @@ Controls the view of the screen. Using zoom with a negative delta will zoom out The focus command switches the node which is currently focused. -### move -**Usage:** -`move brother|pc -+ delta` -`move direction left/up/right/down` - -Moves the currently focused node. This wraps around if you attempt to move to a node that doesn't exist. - -### shift +### shift **Usage:** `shift brother|pc -+ delta` -`shift direction left|up|right|down` -Shift the currently focused node. This is essentially the move command only instead of wrapping, shift will merge the node in the given direction. +Shift the currently focused node. This wraps around if you attempt to move to a node that doesn't exist. Note, shifting to a positive pc won't do anything, shift pc should only be used with a negative delta to shift a client up toward its parent. ### containerize **Usage:** diff --git a/config/.xbindkeysrc b/config/.xbindkeysrc @@ -67,24 +67,24 @@ Mod4 + p # Move Commands -"foo-wm-c /tmp/foo-wm.socket 'shift 1'" +"foo-wm-c /tmp/foo-wm.socket 'shift brother 1'" m:0x41 + c:23 Shift+Mod4 + Tab -"foo-wm-c /tmp/foo-wm.socket 'shift 2'" +"foo-wm-c /tmp/foo-wm.socket 'shift brother 2'" m:0x41 + c:43 Shift+Mod4 + h -"foo-wm-c /tmp/foo-wm.socket 'shift 1'" +"foo-wm-c /tmp/foo-wm.socket 'shift brother 1'" m:0x41 + c:44 Shift+Mod4 + j -"foo-wm-c /tmp/foo-wm.socket 'shift -1'" +"foo-wm-c /tmp/foo-wm.socket 'shift brother -1'" m:0x41 + c:45 Shift+Mod4 + k -"foo-wm-c /tmp/foo-wm.socket 'shift -2'" +"foo-wm-c /tmp/foo-wm.socket 'shift brother -2'" m:0x41 + c:46 Shift+Mod4 + l diff --git a/src/commands.c b/src/commands.c @@ -24,7 +24,6 @@ char * handleCommand(char * request) { dumpTree(); else if (!strcmp(tokens[0], "focus")) focus(tokens[1], tokens[2]); - else if(!strcmp(tokens[0], "jump")) jump(tokens[1]); else if (!strcmp(tokens[0], "kill")) @@ -34,7 +33,7 @@ char * handleCommand(char * request) { else if (!strcmp(tokens[0], "mark")) mark(tokens[1]); else if (!strcmp(tokens[0], "shift")) - shift(atoi(tokens[1])); + shift(tokens[1], atoi(tokens[2])); else if (!strcmp(tokens[0], "zoom")) zoom(atoi(tokens[1])); @@ -185,11 +184,17 @@ void mark(char * markName) { //Moves the current selection given amount -void shift(int amount) { - Node *swapNode = getBrother(focusedNode, amount); +void shift(char * argA, int amount) { + if (!strcmp(argA, "brother")) { + Node *swapNode = getBrother(focusedNode, amount); + swapNodes(focusedNode, swapNode); + focusNode(focusedNode, NULL, True, True); + } else if (!strcmp(argA, "pc")) { + if (amount > 0) return; + if (focusedNode -> parent && focusedNode -> parent -> parent) { - swapNodes(focusedNode, swapNode); - focusNode(focusedNode, NULL, True, True); + } + } } diff --git a/src/commands.h b/src/commands.h @@ -7,5 +7,5 @@ void kill(void); void jump(char * markName); void layout(char * l); void mark(char * markName); -void shift(int amount); +void shift(char * argA, int amount); void zoom(int level); diff --git a/src/tree.c b/src/tree.c @@ -64,6 +64,25 @@ Bool unfocusNode(Node * n, Bool focusPath) { return setView; } + +/* -------------------------------------------------------------------------- + * LongReturns + * -------------------------------------------------------------------------- */ +long getBorderColor(Node * node, Bool focusPath) { + if (focusPath) { + + if (focusedNode == node) + return activeFocusedColor; + else + return node -> parent -> focus == node ? + inactiveFocusedColor : activeUnfocusedColor; + + } else { + return node -> parent -> focus == node ? inactiveFocusedColor: inactiveUnfocusedColor; + } +} + + /* -------------------------------------------------------------------------- * Node Returns * -------------------------------------------------------------------------- */ @@ -340,23 +359,8 @@ void placeNode(Node * node, int x, int y, int width, int height) { if (b == focusedNode) inFocusPath = True; } while (b -> parent); } - if (inFocusPath) { - if (focusedNode == node) { - XSetWindowBorder(display, node -> window, activeFocusedColor); - } else { - if (node -> parent -> focus == node) { - XSetWindowBorder(display, node -> window, inactiveFocusedColor); - } else { - XSetWindowBorder(display, node -> window, activeUnfocusedColor); - } - } - } else { - if (node -> parent -> focus == node) { - XSetWindowBorder(display, node -> window, inactiveFocusedColor); - } else { - XSetWindowBorder(display, node -> window, inactiveUnfocusedColor); - } - } + + XSetWindowBorder(display, node -> window, getBorderColor(node, inFocusPath)); } else { //Count up children prior to loop