foo-wm

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

commit 3bad82b43f6652c97753deb392a3ebcda625be8e
parent c54f08bb6e77b68b550d51bcd365221395b302dc
Author: = <miles.sandlar@gmail.com>
Date:   Fri, 12 Oct 2012 04:56:07 -0400

Added index/id to struct Node{}

Diffstat:
Msrc/responses.c | 3++-
Msrc/structs.h | 1+
Msrc/util.c | 7++++++-
3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/responses.c b/src/responses.c @@ -63,8 +63,9 @@ char * jsonTree(Node * node, int level) { /* Print to the buffer */ sprintf(buffer, /* Type (Pointer) (?Layout) (?R/V/F) (?ChildFocus) */ - "{\"node\":\"%p\",\"type\":\"%s\"%s%s%s%s%s,\"children\":[%s]}\0", + "{\"node\":\"%p\",\"id\":\"%d\"\"type\":\"%s\"%s%s%s%s%s,\"children\":[%s]}\0", node, + node -> id, isClient(node) ? "client" : "container", label, node == rootNode ? ",\"root\":\"true\"" : "", diff --git a/src/structs.h b/src/structs.h @@ -8,6 +8,7 @@ typedef struct Node Node; struct Node { int layout; int x, y, width, height; + int id; Node *parent; Node *next; diff --git a/src/util.c b/src/util.c @@ -8,6 +8,8 @@ #include "foo-wm.h" #include "util.h" +int totalNodes = 0; + //Thank you DWM ;) unsigned long getColor(const char *colstr) { @@ -25,12 +27,15 @@ int xError(XErrorEvent *e) { } Node * allocateNode() { + totalNodes++; + Node *n = malloc(sizeof(Node)); n -> previous = NULL; n -> next = NULL; n -> parent = NULL; n -> child = NULL; - n -> focus = NULL; + n -> focus = NULL; n -> window = (Window) NULL; n -> layout = defaultLayout; + n -> id = totalNodes; return n; }