aewl

diff client.c @ 52:d18f6dd0cf23

fixed several things, nearly feature complete
author Anselm R. Garbe <garbeam@wmii.de>
date Thu, 13 Jul 2006 20:28:19 +0200
parents 035617ee18d1
children 529901e6a227
line diff
     1.1 --- a/client.c	Thu Jul 13 19:55:07 2006 +0200
     1.2 +++ b/client.c	Thu Jul 13 20:28:19 2006 +0200
     1.3 @@ -52,7 +52,7 @@
     1.4  	sel->w = sw - 2 * sel->border;
     1.5  	sel->h = sh - 2 * sel->border;
     1.6  	craise(sel);
     1.7 -	resize(sel);
     1.8 +	resize(sel, False);
     1.9  	discard_events(EnterWindowMask);
    1.10  }
    1.11  
    1.12 @@ -100,7 +100,7 @@
    1.13  	arrange = floating;
    1.14  	for(c = clients; c; c = c->next) {
    1.15  		if(c->tags[tsel])
    1.16 -			resize(c);
    1.17 +			resize(c, True);
    1.18  		else
    1.19  			ban_client(c);
    1.20  	}
    1.21 @@ -125,29 +125,29 @@
    1.22  		if(c->tags[tsel])
    1.23  			n++;
    1.24  
    1.25 -	h = (n > 2) ? sh / (n - 2) : sh;
    1.26 +	h = (n > 1) ? sh / (n - 1) : sh;
    1.27  
    1.28  	for(i = 0, c = clients; c; c = c->next) {
    1.29  		if(c->tags[tsel]) {
    1.30  			if(n == 1) {
    1.31  				c->x = sx;
    1.32  				c->y = sy;
    1.33 -				c->w = sw;
    1.34 -				c->h = sh;
    1.35 +				c->w = sw - 2 * c->border;
    1.36 +				c->h = sh - 2 * c->border;
    1.37  			}
    1.38 -			else if(i == 1) {
    1.39 +			else if(i == 0) {
    1.40  				c->x = sx;
    1.41  				c->y = sy;
    1.42 -				c->w = mw;
    1.43 -				c->h = sh;
    1.44 +				c->w = mw - 2 * c->border;
    1.45 +				c->h = sh - 2 * c->border;
    1.46  			}
    1.47  			else {
    1.48  				c->x = sx + mw;
    1.49 -				c->y = sy + (i - 2) * h;
    1.50 -				c->w = w;
    1.51 -				c->h = h;
    1.52 +				c->y = sy + (i - 1) * h;
    1.53 +				c->w = w - 2 * c->border;
    1.54 +				c->h = h - 2 * c->border;
    1.55  			}
    1.56 -			resize(c);
    1.57 +			resize(c, False);
    1.58  			i++;
    1.59  		}
    1.60  		else
    1.61 @@ -304,14 +304,11 @@
    1.62  void
    1.63  focus(Client *c)
    1.64  {
    1.65 -	if(sel && sel != c) {
    1.66 -		XSetWindowBorder(dpy, sel->win, dc.bg);
    1.67 -		XMapWindow(dpy, sel->title);
    1.68 -		draw_client(sel);
    1.69 -	}
    1.70 +	Client *old = sel;
    1.71 +
    1.72  	sel = c;
    1.73 -	XUnmapWindow(dpy, c->title);
    1.74 -	XSetWindowBorder(dpy, c->win, dc.fg);
    1.75 +	if(old && old != c)
    1.76 +		draw_client(old);
    1.77  	draw_client(c);
    1.78  	XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
    1.79  	XFlush(dpy);
    1.80 @@ -463,14 +460,16 @@
    1.81  
    1.82  
    1.83  void
    1.84 -resize(Client *c)
    1.85 +resize(Client *c, Bool inc)
    1.86  {
    1.87  	XConfigureEvent e;
    1.88  
    1.89 -	if(c->incw)
    1.90 -		c->w -= (c->w - c->basew) % c->incw;
    1.91 -	if(c->inch)
    1.92 -		c->h -= (c->h - c->baseh) % c->inch;
    1.93 +	if(inc) {
    1.94 +		if(c->incw)
    1.95 +			c->w -= (c->w - c->basew) % c->incw;
    1.96 +		if(c->inch)
    1.97 +			c->h -= (c->h - c->baseh) % c->inch;
    1.98 +	}
    1.99  	if(c->minw && c->w < c->minw)
   1.100  		c->w = c->minw;
   1.101  	if(c->minh && c->h < c->minh)
   1.102 @@ -554,8 +553,14 @@
   1.103  draw_client(Client *c)
   1.104  {
   1.105  	int i;
   1.106 -	if(c == sel)
   1.107 +	if(c == sel) {
   1.108 +		XUnmapWindow(dpy, c->title);
   1.109 +		XSetWindowBorder(dpy, c->win, dc.fg);
   1.110  		return;
   1.111 +	}
   1.112 +
   1.113 +	XSetWindowBorder(dpy, c->win, dc.bg);
   1.114 +	XMapWindow(dpy, c->title);
   1.115  
   1.116  	dc.x = dc.y = 0;
   1.117  	dc.h = c->th;