foo-wm

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

commit 4e53634a047229441875058d6da6865d9961c2d5
parent 06648669aae3e2311ac749a0bdd86c2d2c682a3b
Author: = <miles.sandlar@gmail.com>
Date:   Sat, 28 Jul 2012 18:12:09 -0400

Bug fixes

Diffstat:
Msrc/commands.c | 10++++++----
Msrc/config.h | 6++++--
Msrc/events.c | 4++--
Msrc/fifo-wm.c | 1+
Msrc/fifo-wm.h | 2+-
Msrc/tree.c | 55++++++++++++++++++++++++++++---------------------------
Msrc/tree.h | 2+-
7 files changed, 43 insertions(+), 37 deletions(-)

diff --git a/src/commands.c b/src/commands.c @@ -65,7 +65,7 @@ void move(int amount) { Node *swapNode = getBrother(startNode, amount); swapNodes(startNode, swapNode); - focusNode(focusedNode, NULL, True); + focusNode(focusedNode, NULL, True, True); } @@ -77,7 +77,7 @@ void zoom(int level) { viewNode = viewNode -> parent; } else { return; } placeNode(viewNode, rootX, rootY, rootWidth, rootHeight); - focusNode(focusedNode, NULL, True); + focusNode(focusedNode, NULL, True, True); level++; } while (level > 0) { @@ -112,7 +112,7 @@ void focus(char * brotherOrPc, int delta) { (focusedNode -> focus ? focusedNode -> focus : focusedNode -> child); } - focusNode(newFocus, NULL, True); + focusNode(newFocus, NULL, True, True); delta = delta + ( delta > 0 ? -1 : 1); } } @@ -123,6 +123,8 @@ void containerize() { if (isOnlyChild(focusedNode -> child)) return; Node *insertNode, * newContainer = allocateNode(); int insertPosition; + if (focusedNode -> parent -> focus == focusedNode) + focusedNode -> parent -> focus = newContainer; if (focusedNode -> previous) { insertNode = focusedNode -> previous; insertPosition = NEXT; } else { @@ -154,7 +156,7 @@ void kill() { dumpTree(); /* Give the closeset client of destroyed node focus and rerender */ - focusNode(newFocus, NULL, True); + focusNode(newFocus, NULL, True, True); placeNode(viewNode, viewNode -> x, viewNode -> y, viewNode -> width, viewNode -> height); } diff --git a/src/config.h b/src/config.h @@ -12,8 +12,10 @@ #define CONTAINER_PADDING (8) // Windows -#define CLIENT_FOCUSED_COLOR "rgb:AB/DB/F5" -#define CLIENT_UNFOCUSED_COLOR "rgb:54/54/54" +#define CLIENT_FOCUSED_COLOR "rgb:AB/DB/F5" +#define CLIENT_FOCUSED_INACTIVE_COLOR "rgb:d9/ff/00" +#define CLIENT_UNFOCUSED_COLOR "rgb:54/54/54" + #define CLIENT_SELECTED_COLOR "rgb:FF/00/00" #define CLIENT_BORDER_WIDTH (10) #define CLIENT_PADDING (1) diff --git a/src/events.c b/src/events.c @@ -52,7 +52,7 @@ void eMapRequest(XEvent *event) { addLookupEntry(newNode, &newNode -> window); fprintf(stderr, "added the lookup entry\n"); - focusNode(newNode, NULL, True); + focusNode(newNode, NULL, True, True); fprintf(stderr, "done with the map request\n"); } @@ -105,7 +105,7 @@ void eButtonPress(XEvent *event) { if (event -> xbutton.window == None) return; // Click to Focus - focusNode(getNodeByWindow(&(event -> xbutton.window)), event, True); + focusNode(getNodeByWindow(&(event -> xbutton.window)), event, True, True); } void handleXEvent(XEvent *event) { diff --git a/src/fifo-wm.c b/src/fifo-wm.c @@ -67,6 +67,7 @@ void setup(void) { // Setup Clients Defaults border = CLIENT_BORDER_WIDTH; focusedColor = getColor(CLIENT_FOCUSED_COLOR); + focusedInactiveColor = getColor(CLIENT_FOCUSED_INACTIVE_COLOR); selectedColor = getColor(CLIENT_SELECTED_COLOR); unfocusedColor = getColor(CLIENT_UNFOCUSED_COLOR); diff --git a/src/fifo-wm.h b/src/fifo-wm.h @@ -19,7 +19,7 @@ Lookup * lookup; //Customizations int clientPadding, containerPadding; int defaultLayout, border; -long unfocusedColor, focusedColor, selectedColor; +long unfocusedColor, focusedColor, focusedInactiveColor, selectedColor; void handleCommand(char* request); diff --git a/src/tree.c b/src/tree.c @@ -81,54 +81,54 @@ Bool unfocusNode(Node * n, Bool focusPath) { //This should focus OR select -void focusNode(Node * n, XEvent * event, Bool setFocused) { +void focusNode(Node * n, XEvent * event, Bool setFocused, Bool focusPath) { if (!n || n == focusedNode) return; fprintf(stderr, "Focusing %p", n); - Bool setView = unfocusNode(focusedNode, True); + Bool setView = False; //Wether the viewNode needs to be moved + if (focusPath) { + fprintf(stderr, "\n\nNode %p, is in the focus patho\n\n", n); + setView = unfocusNode(focusedNode, True); + if (n -> parent) n -> parent -> focus = n; + } + if (setFocused) focusedNode = n; if (setView) viewNode = n; - if (n -> parent) n -> parent -> focus = n; + // Are we at the bottom level if (isClient(n)) { if (n -> parent) { n -> parent -> focus = n; - //if (focusedNode -> parent -> layout == MAX) placeNode(n -> parent, n -> parent -> x, n -> parent -> y, n -> parent -> width, n -> parent -> height); } - // Set the Input focus, and ungrab the window (no longer point to click - XSetInputFocus(display, n -> window, RevertToParent, CurrentTime); - XUngrabButton(display, AnyButton, AnyModifier, n ->window); - XSetWindowBorder(display, n -> window, focusedColor); - XRaiseWindow(display, n -> window); - - //Passed an event - if (event) { - fprintf(stderr, "Focuing a node with an event\n"); - XSendEvent(display, n -> window, True, ButtonPressMask, event); + // Set the Input focus, and ungrab the window (no longer point to click) + if (focusPath) { + XSetInputFocus(display, n -> window, RevertToParent, CurrentTime); + XUngrabButton(display, AnyButton, AnyModifier, n ->window); + XRaiseWindow(display, n -> window); + XSetWindowBorder(display, n -> window, focusedColor); + if (event) { + XSendEvent(display, n -> window, True, ButtonPressMask, event); + } else { + centerPointer(&n -> window); + } } else { - fprintf(stderr, "Focuing a node without an event\n"); - centerPointer(&n -> window); + XSetWindowBorder(display, n -> window, focusedInactiveColor); } } else { - fprintf(stderr, "focus claled ona ctaonerin"); - Node *i; - for (i = n -> child; i; i = i -> next) { - if (i == n) { //The Focused node requested thats a container - focusNode(n, NULL, False); - } else if (isClient(i)) { //Must dehigh these clients, unfocused_inactive - XSetWindowBorder(display, i->window, selectedColor); - } else { - //We have a container as a child of the focusedNode BUT not in the path - //to focusing... ned a function to set unfocused_inactive OR in placeNode - } + fprintf(stderr, "focus called on a container"); + Node *i; for (i = n -> child; i; i = i -> next) { + focusNode(i, NULL, False, //Recall Focusnode + i -> parent -> focus == i ? True : False); } } if (setView) placeNode(viewNode, rootX, rootY, rootWidth, rootHeight); } + + void destroyNode(Node * n) { if (!n) return; @@ -205,6 +205,7 @@ void parentNode(Node *node, Node *parent) { unparentNode(node); //Unparent then set the parent to new parent node -> parent = parent; + if (!parent -> focus) parent -> focus = node; //Find last in children of parent, add to end if (parent -> child) { diff --git a/src/tree.h b/src/tree.h @@ -5,7 +5,7 @@ void unparentNode(Node * node); void brotherNode(Node *node, Node * brother, int position); void parentNode(Node * node, Node * parent); Bool unfocusNode(Node * n, Bool focusPath); -void focusNode(Node * node, XEvent * event, Bool setFocused); +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);