foo-wm

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

commit af923b94031c011666394f03492d48cccdedc848
parent 8783c40e92225e95077ee7f85c82cb3a24724555
Author: = <miles.sandlar@gmail.com>
Date:   Sun, 19 Aug 2012 17:44:58 -0400

Added mark and jump commands

Diffstat:
Msrc/commands.c | 36++++++++++++++++++++++++++++++++++++
Msrc/commands.h | 2++
Msrc/foo-wm.c | 1-
Msrc/foo-wm.h | 1+
Msrc/structs.h | 7+++++++
5 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/src/commands.c b/src/commands.c @@ -37,6 +37,10 @@ char * handleCommand(char * request) { move(atoi(tokens[1])); else if (!strcmp(tokens[0], "shift")) shift(tokens[1]); + else if (!strcmp(tokens[0], "mark")) + addMark(tokens[1]); + else if(!strcmp(tokens[0], "jump")) + jump(tokens[1]); else if (!strcmp(tokens[0], "containerize")) containerize(); else if (!strcmp(tokens[0], "zoom")) @@ -98,6 +102,38 @@ void shift(char * directionString) { } } +/* Adds the current viewNode as a mark */ +void addMark(char * markName) { + + Mark *m = malloc(sizeof(Mark)); + m -> name = malloc(sizeof(markName)); + strcpy(m -> name, markName); + m -> node = viewNode; + m -> previous = mark; + mark = m; + fprintf(stderr, "Size %d", sizeof(m -> name)); + + fprintf(stderr, "\nAdded the mark:: %s // %s\n", markName, mark -> name); +} + +void jump(char * markName) { + fprintf(stderr, "Finding a node"); + + Mark *n = NULL; + for(n = mark; n; n = n -> previous) { + if (!strcmp(n -> name, markName)) { + fprintf(stderr, "Going to focus mark %p", n -> node); + unmapNode(focusedNode); + viewNode = n -> node; + placeNode(n -> node, rootX, rootY, rootWidth, rootHeight); + focusNode(n -> node, NULL, True, True); + while (!isClient(focusedNode)) { + focus("pc", "1"); + } + } + } +} + /* Updates the viewNode approximating the current focusNode */ void zoom(int level) { diff --git a/src/commands.h b/src/commands.h @@ -2,6 +2,8 @@ char * nextToken(char ** tokenString); char * handleCommand(char * request); void move(int amount); void shift(char * directionString); +void addMark(char * markName); +void jump(char * markName); void layout(char * l); void zoom(int level); void focus(char * argA, char * argB); diff --git a/src/foo-wm.c b/src/foo-wm.c @@ -125,6 +125,5 @@ void setup(void) { int main(void) { setup(); handleEvents(); - return 0; } diff --git a/src/foo-wm.h b/src/foo-wm.h @@ -15,6 +15,7 @@ Node *focusedNode, *viewNode, *rootNode; /* X Window -> Node Lookup Table */ Lookup * lookup; +Mark * mark; //Customizations int clientPadding, containerPadding; diff --git a/src/structs.h b/src/structs.h @@ -30,3 +30,10 @@ struct Lookup { Node *node; Lookup *previous; }; + +typedef struct Mark Mark; +struct Mark { + char *name; + Node * node; + Mark * previous; +};