foo-wm

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

commit 953898272ac7e58da3c8bd192dec3319964d0271
parent 2aa7197917e7a769327f1965b37f4ad6ac3fd480
Author: Miles Sandlar <miles.sandlar@gmail.com>
Date:   Fri,  6 Jul 2012 16:35:30 -0400

Moved getNodeByWindow to util. Fixed grid bug.
Grid within a container must account for existing x

Diffstat:
Msrc/config.h | 4++--
Msrc/fifo-wm.h | 2++
Msrc/tree.c | 25+++++--------------------
Msrc/tree.h | 1-
Msrc/util.c | 15+++++++++++++++
Msrc/util.h | 1+
6 files changed, 25 insertions(+), 23 deletions(-)

diff --git a/src/config.h b/src/config.h @@ -8,9 +8,9 @@ // Containers #define CONTAINER_DEFAULT_LAYOUT (2) #define CONTAINER_PADDING (1) -#define BORDER_WIDTH (3) +#define BORDER_WIDTH (1) -#define SCREEN_PADDING_TOP (18) +#define SCREEN_PADDING_TOP (20) #define SCREEN_PADDING_LEFT (2) #define SCREEN_PADDING_BOTTOM (2) #define SCREEN_PADDING_RIGHT (2) diff --git a/src/fifo-wm.h b/src/fifo-wm.h @@ -1,6 +1,8 @@ #include <X11/Xlib.h> +#include <sys/time.h> #include "structs.h" + Lookup * lookup; int screen, activeScreen; diff --git a/src/tree.c b/src/tree.c @@ -1,10 +1,10 @@ #include <X11/Xlib.h> #include <stdio.h> #include <stdlib.h> -#include <math.h> #include "fifo-wm.h" #include "tree.h" +#include "util.h" #include "window.h" void crawlNode(Node * node, int level) { @@ -148,8 +148,8 @@ void placeNode(Node * node, int x, int y, int width, int height) { XRaiseWindow(display, node -> window); XMoveResizeWindow(display, node -> window, - x, - y, + (x < 0) ? 0 : x, + (y < 0) ? 0 : y, width - (border*2), height - (border *2)); XSetWindowBorderWidth(display, node -> window, border); @@ -185,10 +185,8 @@ void placeNode(Node * node, int x, int y, int width, int height) { //Two nodes, edge case for formula if (children == 2) { a -> height = height - (padding * 2); } //Scretch the last child - if (i + 1 == children) { a -> width = width - a -> x - (padding * 2); } + if (i + 1 == children) { a -> width = x + width - a -> x - (padding * 2); } } - - fprintf(stderr, "Calling place node with X[%d] and Y[%d]\n", a -> x, a -> y); placeNode(a, a -> x, a -> y, a -> width, a -> height); } } @@ -201,20 +199,6 @@ Bool isClient(Node * node) { } else { return False; } } -//Returns the client associated with given window - -Node * getNodeByWindow(Window * window) { - Lookup *entry; - int win = *window; - for (entry = lookup; entry != NULL; entry = entry -> previous) { - if (win == entry -> window) - return entry -> node; - } - - return NULL; -} - - /* Gets the next brother client to node, in given direction * [Container] - [Client X] - [Container] - [Container] - [Client Y] * Given Client X, function would loop until hitting Client Y @@ -257,4 +241,5 @@ Node * getClosestClient(Node * node) { return returnNode; } } + return NULL; } diff --git a/src/tree.h b/src/tree.h @@ -6,7 +6,6 @@ void parentNode(Node * node, Node * parent); void focusNode(Node * node); void unmapNode(Node * node); void placeNode(Node * node, int x, int y, int width, int height); -Node * getNodeByWindow(Window * window); Node * getBrotherClient(Node * node, int direction); Node * getClosestClient(Node * node); diff --git a/src/util.c b/src/util.c @@ -1,6 +1,8 @@ #include <X11/Xlib.h> #include <stdio.h> #include <stdlib.h> +#include <math.h> + #include "fifo-wm.h" #include "util.h" @@ -41,3 +43,16 @@ void gridDimensions(int children, int * rows, int * cols) { *cols = c; } } + + +//Returns the client associated with given windowv +Node * getNodeByWindow(Window * window) { + Lookup *entry; + int win = *window; + for (entry = lookup; entry != NULL; entry = entry -> previous) { + if (win == entry -> window) + return entry -> node; + } + + return NULL; +} diff --git a/src/util.h b/src/util.h @@ -2,3 +2,4 @@ unsigned long getColor(const char *colstr); int xError(XErrorEvent *e); Node * allocateNode(); void gridDimensions(int children, int * rows, int * cols); +Node * getNodeByWindow(Window * window);