aewl

changeset 505:2c29d74b11dc

first step to a more flexible dotile() algorithm
author Anselm R. Garbe <arg@10kloc.org>
date Fri, 29 Sep 2006 12:38:27 +0200
parents 0cefc169ff67
children b467b5a749db
files config.arg.h config.default.h config.mk dwm.h event.c main.c view.c
diffstat 7 files changed, 52 insertions(+), 35 deletions(-) [+]
line diff
     1.1 --- a/config.arg.h	Thu Sep 28 21:29:20 2006 +0200
     1.2 +++ b/config.arg.h	Fri Sep 29 12:38:27 2006 +0200
     1.3 @@ -6,9 +6,11 @@
     1.4  #define TAGS \
     1.5  const char *tags[] = { "dev", "work", "net", "fnord", NULL };
     1.6  
     1.7 -#define DEFMODE			dotile /* dofloat */
     1.8 +#define DEFMODE			dotile		/* dofloat */
     1.9  #define FLOATSYMBOL		"><>"
    1.10 +#define STACKPOS		StackRight	/* StackLeft, StackBottom */
    1.11  #define TILESYMBOL		"[]="
    1.12 +#define VERTICALSTACK		True		/* False == horizontal stack  */
    1.13  
    1.14  #define FONT			"-*-terminus-medium-*-*-*-12-*-*-*-*-*-iso10646-*"
    1.15  #define NORMBGCOLOR		"#333333"
    1.16 @@ -18,7 +20,7 @@
    1.17  #define STATUSBGCOLOR		"#222222"
    1.18  #define STATUSFGCOLOR		"#9999cc"
    1.19  
    1.20 -#define MASTERW			60 /* percent */
    1.21 +#define MASTER			60 /* percent */
    1.22  #define MODKEY			Mod1Mask
    1.23  
    1.24  #define KEYS \
     2.1 --- a/config.default.h	Thu Sep 28 21:29:20 2006 +0200
     2.2 +++ b/config.default.h	Fri Sep 29 12:38:27 2006 +0200
     2.3 @@ -8,7 +8,9 @@
     2.4  
     2.5  #define DEFMODE			dotile /* dofloat */
     2.6  #define FLOATSYMBOL		"><>"
     2.7 +#define STACKPOS		StackRight	/* StackLeft, StackBottom */
     2.8  #define TILESYMBOL		"[]="
     2.9 +#define VERTICALSTACK		True		/* False == horizontal stack  */
    2.10  
    2.11  #define FONT			"fixed"
    2.12  #define NORMBGCOLOR		"#333366"
    2.13 @@ -18,7 +20,7 @@
    2.14  #define STATUSBGCOLOR		"#dddddd"
    2.15  #define STATUSFGCOLOR		"#222222"
    2.16  
    2.17 -#define MASTERW			60 /* percent */
    2.18 +#define MASTER			60 /* percent */
    2.19  #define MODKEY			Mod1Mask
    2.20  
    2.21  #define KEYS \
     3.1 --- a/config.mk	Thu Sep 28 21:29:20 2006 +0200
     3.2 +++ b/config.mk	Fri Sep 29 12:38:27 2006 +0200
     3.3 @@ -1,5 +1,5 @@
     3.4  # dwm version
     3.5 -VERSION = 1.7.1
     3.6 +VERSION = 1.8
     3.7  
     3.8  # Customize below to fit your system
     3.9  
     4.1 --- a/dwm.h	Thu Sep 28 21:29:20 2006 +0200
     4.2 +++ b/dwm.h	Fri Sep 29 12:38:27 2006 +0200
     4.3 @@ -48,6 +48,10 @@
     4.4  enum { ColFG, ColBG, ColLast };				/* color */
     4.5  
     4.6  typedef enum {
     4.7 +	StackLeft, StackBottom, StackRight
     4.8 +} StackPos; /* stack position*/
     4.9 +
    4.10 +typedef enum {
    4.11  	TopLeft, TopRight, BotLeft, BotRight
    4.12  } Corner; /* window corners */
    4.13  
    4.14 @@ -97,16 +101,18 @@
    4.15  extern const char *tags[];			/* all tags */
    4.16  extern char stext[1024];			/* status text */
    4.17  extern int bx, by, bw, bh, bmw;			/* bar geometry, bar mode label width */
    4.18 -extern int mw, screen, sx, sy, sw, sh;		/* screen geometry, master width */
    4.19 +extern int master, screen, sx, sy, sw, sh;	/* screen geometry, master width */
    4.20  extern unsigned int ntags, numlockmask;		/* number of tags, dynamic lock mask */
    4.21  extern void (*handler[LASTEvent])(XEvent *);	/* event handler */
    4.22  extern void (*arrange)(Arg *);			/* arrange function, indicates mode  */
    4.23  extern Atom wmatom[WMLast], netatom[NetLast];
    4.24  extern Bool running, issel, *seltag;		/* seltag is array of Bool */
    4.25 +extern Bool isvertical;				/* stack direction */
    4.26  extern Client *clients, *sel, *stack;		/* global client list and stack */
    4.27  extern Cursor cursor[CurLast];
    4.28  extern DC dc;					/* global draw context */
    4.29  extern Display *dpy;
    4.30 +extern StackPos stackpos;
    4.31  extern Window root, barwin;
    4.32  
    4.33  /* client.c */
     5.1 --- a/event.c	Thu Sep 28 21:29:20 2006 +0200
     5.2 +++ b/event.c	Fri Sep 29 12:38:27 2006 +0200
     5.3 @@ -176,8 +176,11 @@
     5.4  		else
     5.5  			configure(c);
     5.6  		XSync(dpy, False);
     5.7 -		if(c->isfloat)
     5.8 +		if(c->isfloat) {
     5.9  			resize(c, False, TopLeft);
    5.10 +			if(!isvisible(c))
    5.11 +				ban(c);
    5.12 +		}
    5.13  		else
    5.14  			arrange(NULL);
    5.15  	}
     6.1 --- a/main.c	Thu Sep 28 21:29:20 2006 +0200
     6.2 +++ b/main.c	Fri Sep 29 12:38:27 2006 +0200
     6.3 @@ -19,7 +19,7 @@
     6.4  
     6.5  char stext[1024];
     6.6  Bool *seltag;
     6.7 -int bx, by, bw, bh, bmw, mw, screen, sx, sy, sw, sh;
     6.8 +int bx, by, bw, bh, bmw, master, screen, sx, sy, sw, sh;
     6.9  unsigned int ntags, numlockmask;
    6.10  Atom wmatom[WMLast], netatom[NetLast];
    6.11  Bool running = True;
    6.12 @@ -133,7 +133,7 @@
    6.13  	sx = sy = 0;
    6.14  	sw = DisplayWidth(dpy, screen);
    6.15  	sh = DisplayHeight(dpy, screen);
    6.16 -	mw = (sw * MASTERW) / 100;
    6.17 +	master = ((stackpos == StackBottom ? sh - bh : sw) * MASTER) / 100;
    6.18  
    6.19  	bx = by = 0;
    6.20  	bw = sw;
     7.1 --- a/view.c	Thu Sep 28 21:29:20 2006 +0200
     7.2 +++ b/view.c	Fri Sep 29 12:38:27 2006 +0200
     7.3 @@ -65,6 +65,8 @@
     7.4  /* extern */
     7.5  
     7.6  void (*arrange)(Arg *) = DEFMODE;
     7.7 +Bool isvertical = VERTICALSTACK;
     7.8 +StackPos stackpos = STACKPOS;
     7.9  
    7.10  void
    7.11  detach(Client *c) {
    7.12 @@ -97,35 +99,37 @@
    7.13  
    7.14  /* This algorithm is based on a (M)aster area and a (S)tacking area.
    7.15   * It supports following arrangements:
    7.16 - *
    7.17 - * 	MMMS		MMMM
    7.18 - * 	MMMS		MMMM
    7.19 - * 	MMMS		SSSS
    7.20 - *
    7.21 - * The stacking area can be set to arrange clients vertically or horizontally.
    7.22 - * Through inverting the algorithm it can be used to achieve following setup in
    7.23 - * a dual head environment (due to running two dwm instances concurrently on
    7.24 - * the specific screen):
    7.25 - *
    7.26 - * 	SMM MMS		MMM MMM
    7.27 - * 	SMM MMS		MMM MMM
    7.28 - * 	SMM MMS		SSS SSS
    7.29 - *
    7.30 - * This uses the center of the two screens for master areas.
    7.31 + * 	MMMS		MMMM		SMMM
    7.32 + * 	MMMS		MMMM		SMMM
    7.33 + * 	MMMS		SSSS		SMMM
    7.34   */
    7.35  void
    7.36  dotile(Arg *arg) {
    7.37  	int h, i, n, w;
    7.38  	Client *c;
    7.39  
    7.40 -	w = sw - mw;
    7.41  	for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
    7.42  		n++;
    7.43  
    7.44 -	if(n > 1)
    7.45 -		h = (sh - bh) / (n - 1);
    7.46 -	else
    7.47 -		h = sh - bh;
    7.48 +	if(isvertical) {
    7.49 +		if(stackpos == StackBottom) {
    7.50 +			w = sw;
    7.51 +			if(n > 1)
    7.52 +				h = (sh - bh) / (n - 1);
    7.53 +			else
    7.54 +				h = sh - bh;
    7.55 +		}
    7.56 +		else {
    7.57 +			w = sw - master;
    7.58 +			if(n > 1)
    7.59 +				h = (sh - bh) / (n - 1);
    7.60 +			else
    7.61 +				h = sh - bh;
    7.62 +		}
    7.63 +	}
    7.64 +	else { /* horizontal stack */
    7.65 +
    7.66 +	}
    7.67  
    7.68  	for(i = 0, c = clients; c; c = c->next) {
    7.69  		if(isvisible(c)) {
    7.70 @@ -143,11 +147,11 @@
    7.71  			else if(i == 0) {
    7.72  				c->x = sx;
    7.73  				c->y = sy + bh;
    7.74 -				c->w = mw - 2 * BORDERPX;
    7.75 +				c->w = master - 2 * BORDERPX;
    7.76  				c->h = sh - 2 * BORDERPX - bh;
    7.77  			}
    7.78  			else if(h > bh) {
    7.79 -				c->x = sx + mw;
    7.80 +				c->x = sx + master;
    7.81  				c->y = sy + (i - 1) * h + bh;
    7.82  				c->w = w - 2 * BORDERPX;
    7.83  				if(i + 1 == n)
    7.84 @@ -156,7 +160,7 @@
    7.85  					c->h = h - 2 * BORDERPX;
    7.86  			}
    7.87  			else { /* fallback if h < bh */
    7.88 -				c->x = sx + mw;
    7.89 +				c->x = sx + master;
    7.90  				c->y = sy + bh;
    7.91  				c->w = w - 2 * BORDERPX;
    7.92  				c->h = sh - 2 * BORDERPX - bh;
    7.93 @@ -228,14 +232,14 @@
    7.94  		return;
    7.95  
    7.96  	if(sel == getnext(clients)) {
    7.97 -		if(mw + arg->i > sw - 100 || mw + arg->i < 100)
    7.98 +		if(master + arg->i > sw - 100 || master + arg->i < 100)
    7.99  			return;
   7.100 -		mw += arg->i;
   7.101 +		master += arg->i;
   7.102  	}
   7.103  	else {
   7.104 -		if(mw - arg->i > sw - 100 || mw - arg->i < 100)
   7.105 +		if(master - arg->i > sw - 100 || master - arg->i < 100)
   7.106  			return;
   7.107 -		mw -= arg->i;
   7.108 +		master -= arg->i;
   7.109  	}
   7.110  	arrange(NULL);
   7.111  }