foo-wm

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

commit 751f75c12245c05fffcf51438774fcdffc9302a2
parent c952ad69f6245a50c0349a96e6cb828a716e0f5c
Author: Miles Sandlar <miles.sandlar@gmail.com>
Date:   Fri,  6 Jul 2012 18:54:58 -0400

Rename activeNode to focusedNode, add selectedNode

Diffstat:
Msrc/commands.c | 60++++++++++++++++++++++++++++++++++++++----------------------
Msrc/events.c | 20++++++++++----------
Msrc/fifo-wm.h | 7++++---
Msrc/tree.c | 17+++++++++++------
Msrc/tree.h | 1+
5 files changed, 64 insertions(+), 41 deletions(-)

diff --git a/src/commands.c b/src/commands.c @@ -11,7 +11,7 @@ void focus(int direction) { /* //Direction: 0 - Left, 1 - Up, 2 - Right, 3 - Down - switch (activeNode -> parent -> layout) { + switch (focusedNode -> parent -> layout) { //Vertical Container case 0: @@ -70,16 +70,16 @@ void handleCommand(char* request) { } else if (!strcmp(tokens[0], "layout")) { fprintf(stderr, "Setting layout to: %s", tokens[1]); if (!strcmp(tokens[1], "vertical")) { - activeNode -> parent -> layout = 0; + focusedNode -> parent -> layout = 0; } else if (!strcmp(tokens[1], "horizontal")) { - activeNode -> parent -> layout = 1; + focusedNode -> parent -> layout = 1; } else if (!strcmp(tokens[1], "grid")) { - activeNode -> parent -> layout = 2; + focusedNode -> parent -> layout = 2; } - placeNode(activeNode -> parent, - (activeNode -> parent) -> x, (activeNode -> parent) -> y, - (activeNode -> parent) -> width, (activeNode -> parent) -> height); + placeNode(focusedNode -> parent, + (focusedNode -> parent) -> x, (focusedNode -> parent) -> y, + (focusedNode -> parent) -> width, (focusedNode -> parent) -> height); } else if (!strcmp(tokens[0], "focus")) { if (!strcmp(tokens[1], "left")) @@ -90,27 +90,42 @@ void handleCommand(char* request) { focus(2); else if (!strcmp(tokens[1], "down")) focus(3); + + } else if (!strcmp(tokens[0], "select")) { + if (!strcmp(tokens[1], "parent")) { + if (selectedNode == NULL) { + selectNode(focusedNode -> parent); + } else { + if (selectedNode -> parent != NULL) { + selectNode(selectedNode); + } + } + } else if (!strcmp(tokens[1], "next")) { + + } else if (!strcmp(tokens[1], "previous")) { + + } } else if (!strcmp(tokens[0], "containerize")) { if (!strcmp(tokens[1], "client")) { - if (!(activeNode -> previous == NULL && activeNode -> next == NULL)) { + if (!(focusedNode -> previous == NULL && focusedNode -> next == NULL)) { fprintf(stderr,"Containerizing"); Node * newContainer = allocateNode(); - Node * nodeParent = activeNode -> parent; + newContainer -> layout = layout; /* Save a node and position to insert for when we reparent */ Node *insertNode; int insertPosition; - if (activeNode -> previous != NULL) { - insertNode = activeNode -> previous; insertPosition = 1; - } else if (activeNode -> next != NULL) { - insertNode = activeNode -> next; insertPosition = 0; + if (focusedNode -> previous != NULL) { + insertNode = focusedNode -> previous; insertPosition = 1; + } else if (focusedNode -> next != NULL) { + insertNode = focusedNode -> next; insertPosition = 0; } - //Unparents activeNode and reparents into newContainer - parentNode(activeNode, newContainer); + //Unparents focusedNode and reparents into newContainer + parentNode(focusedNode, newContainer); brotherNode(newContainer, insertNode, insertPosition); - activeNode = newContainer -> child; + focusedNode = newContainer -> child; //Rerender the viewnode placeNode(viewNode, rootX, rootY, rootWidth, rootHeight); @@ -121,6 +136,7 @@ void handleCommand(char* request) { } } + } else if (!strcmp(tokens[0], "view")) { if (!strcmp(tokens[1], "parent")) { @@ -132,8 +148,8 @@ void handleCommand(char* request) { } else if (!strcmp(tokens[1], "child")) { - if (activeNode != viewNode) { - Node *n = activeNode; + if (focusedNode != viewNode) { + Node *n = focusedNode; while (n -> parent != viewNode && n != NULL) { n = n -> parent; } unmapNode(viewNode); @@ -144,10 +160,10 @@ void handleCommand(char* request) { } else if (!strcmp(tokens[0], "kill")) { if (!strcmp(tokens[1], "client")) { dumpTree(); - fprintf(stderr, "Destroy Client %p\n", activeNode); + fprintf(stderr, "Destroy Client %p\n", focusedNode); - if (isClient(activeNode)) { - destroyNode(activeNode); + if (isClient(focusedNode)) { + destroyNode(focusedNode); dumpTree(); @@ -158,7 +174,7 @@ void handleCommand(char* request) { } } else if (!strcmp(tokens[1], "container")) { dumpTree(); - fprintf(stderr, "Destroy Container %p\n", activeNode -> parent); + fprintf(stderr, "Destroy Container %p\n", focusedNode -> parent); //destroyContainer(currentContainer); dumpTree(); } diff --git a/src/events.c b/src/events.c @@ -16,25 +16,25 @@ void eMapRequest(XEvent *event) { Node *newNode = allocateNode(); newNode -> window = event -> xmaprequest.window; - if (activeNode == NULL || !isClient(activeNode)) { + if (focusedNode == NULL || !isClient(focusedNode)) { parentNode(newNode, viewNode); } else { - parentNode(newNode, activeNode -> parent); + brotherNode(newNode, focusedNode, 1); } - fprintf(stderr, "The focused node (BEFORE) is %p\n", activeNode); + fprintf(stderr, "The focused node (BEFORE) is %p\n", focusedNode); focusNode(newNode); - fprintf(stderr, "The focused node (AFTER) is %p\n", activeNode); + fprintf(stderr, "The focused node (AFTER) is %p\n", focusedNode); //Update the view - placeNode( activeNode -> parent, - (activeNode -> parent) -> x, - (activeNode -> parent) -> y, - (activeNode -> parent) -> width, - (activeNode -> parent) -> height); + placeNode( focusedNode -> parent, + (focusedNode -> parent) -> x, + (focusedNode -> parent) -> y, + (focusedNode -> parent) -> width, + (focusedNode -> parent) -> height); @@ -53,7 +53,7 @@ void eDestroyNotify(XEvent *event) { Node *n = getNodeByWindow(&(event -> xdestroywindow.window)); if (n == NULL) { return; } - activeNode = getClosestClient(n); + focusedNode = getClosestClient(n); destroyNode(n); //Update view diff --git a/src/fifo-wm.h b/src/fifo-wm.h @@ -8,7 +8,6 @@ Lookup * lookup; int screen, activeScreen; int padding; int layout; -int spawn; int border; Display *display; Window root; @@ -18,8 +17,10 @@ long focusedColor; int rootX, rootY, rootWidth, rootHeight; -Node *activeNode; //Active Input / New clients launch as brother -Node *viewNode; // Currently viewed node on the screen +/* focusedNode :: Currently focused client node (recieves input) + * selectedNode :: Currently selected node (for containerize, move, etc....) + * viewNode :: Currently viewed node (screenspace) */ +Node *focusedNode, *selectedNode, *viewNode; void handleCommand(char* request); void handleEvents(); diff --git a/src/tree.c b/src/tree.c @@ -12,7 +12,7 @@ void crawlNode(Node * node, int level) { if (isClient(node)) { fprintf(stderr, "Client (%p)", node); - if (node == activeNode) { fprintf(stderr, " [FOCUS]"); } + if (node == focusedNode) { fprintf(stderr, " [FOCUS]"); } fprintf(stderr, "\n"); } else { @@ -40,22 +40,27 @@ void dumpTree() { //Will only work on nodes with windows for now void focusNode(Node * n) { - if (activeNode == n) { return; } + if (focusedNode == n) { return; } if (!isClient(n)) { fprintf(stderr, "Trying to focus a node thats not a client !\n"); return; } - if (isClient(activeNode)) { - XSetWindowBorder(display, activeNode -> window, unfocusedColor); + if (isClient(focusedNode)) { + XSetWindowBorder(display, focusedNode -> window, unfocusedColor); } - activeNode = n; + focusedNode = n; XRaiseWindow(display, n -> window); XSetInputFocus(display, n -> window, RevertToPointerRoot, CurrentTime); XSetWindowBorder(display, n -> window, focusedColor); centerPointer(&n -> window); } +void selectNode(Node * n) { + +} + + void destroyNode(Node * n) { fprintf(stderr, "PRE DESTROY\n"); @@ -180,7 +185,7 @@ void placeNode(Node * node, int x, int y, int width, int height) { width - (border*2), height - (border *2)); XSetWindowBorderWidth(display, node -> window, border); - if (activeNode == node) { + if (focusedNode == node) { XSetWindowBorder(display, node -> window, focusedColor); focusNode(node); } else { diff --git a/src/tree.h b/src/tree.h @@ -5,6 +5,7 @@ void unparentNode(Node * node); void brotherNode(Node *node, Node * brother, int position); void parentNode(Node * node, Node * parent); void focusNode(Node * node); +void selectNode(Node * n); void unmapNode(Node * node); void placeNode(Node * node, int x, int y, int width, int height); Node * getBrotherClient(Node * node, int direction);