dwm-meillo

diff client.c @ 115:329fd7dae530

removed c->f{x,y,w,h} and c->t{x,y,w,h} in favor for the new rule handling remembering two kinds of geometries is unnecessary, removed the randomized (x,y) setting on dofloat startup, was kind too random und unpredictable
author arg@10ksloc.org
date Thu, 20 Jul 2006 07:26:23 +0200
parents dfa5cd0969a6
children 61490330e90a
line diff
     1.1 --- a/client.c	Wed Jul 19 17:42:08 2006 +0200
     1.2 +++ b/client.c	Thu Jul 20 07:26:23 2006 +0200
     1.3 @@ -16,19 +16,19 @@
     1.4  {
     1.5  	int i;
     1.6  
     1.7 -	c->bw = 0;
     1.8 +	c->tw = 0;
     1.9  	for(i = 0; i < TLast; i++)
    1.10  		if(c->tags[i])
    1.11 -			c->bw += textw(c->tags[i]);
    1.12 -	c->bw += textw(c->name);
    1.13 -	if(c->bw > *c->w)
    1.14 -		c->bw = *c->w + 2;
    1.15 -	c->bx = *c->x + *c->w - c->bw + 2;
    1.16 -	c->by = *c->y;
    1.17 +			c->tw += textw(c->tags[i]);
    1.18 +	c->tw += textw(c->name);
    1.19 +	if(c->tw > c->w)
    1.20 +		c->tw = c->w + 2;
    1.21 +	c->tx = c->x + c->w - c->tw + 2;
    1.22 +	c->ty = c->y;
    1.23  	if(c->tags[tsel])
    1.24 -		XMoveResizeWindow(dpy, c->title, c->bx, c->by, c->bw, c->bh);
    1.25 +		XMoveResizeWindow(dpy, c->title, c->tx, c->ty, c->tw, c->th);
    1.26  	else
    1.27 -		XMoveResizeWindow(dpy, c->title, c->bx + 2 * sw, c->by, c->bw, c->bh);
    1.28 +		XMoveResizeWindow(dpy, c->title, c->tx + 2 * sw, c->ty, c->tw, c->th);
    1.29  
    1.30  }
    1.31  
    1.32 @@ -43,8 +43,8 @@
    1.33  void
    1.34  ban(Client *c)
    1.35  {
    1.36 -	XMoveWindow(dpy, c->win, *c->x + 2 * sw, *c->y);
    1.37 -	XMoveWindow(dpy, c->title, c->bx + 2 * sw, c->by);
    1.38 +	XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
    1.39 +	XMoveWindow(dpy, c->title, c->tx + 2 * sw, c->ty);
    1.40  }
    1.41  
    1.42  void
    1.43 @@ -128,12 +128,12 @@
    1.44  	case EastGravity:
    1.45  	case CenterGravity:
    1.46  	case WestGravity:
    1.47 -		dy = -(*c->h / 2) + c->border;
    1.48 +		dy = -(c->h / 2) + c->border;
    1.49  		break;
    1.50  	case SouthEastGravity:
    1.51  	case SouthGravity:
    1.52  	case SouthWestGravity:
    1.53 -		dy = -(*c->h);
    1.54 +		dy = -(c->h);
    1.55  		break;
    1.56  	default:
    1.57  		break;
    1.58 @@ -149,12 +149,12 @@
    1.59  	case NorthGravity:
    1.60  	case CenterGravity:
    1.61  	case SouthGravity:
    1.62 -		dx = -(*c->w / 2) + c->border;
    1.63 +		dx = -(c->w / 2) + c->border;
    1.64  		break;
    1.65  	case NorthEastGravity:
    1.66  	case EastGravity:
    1.67  	case SouthEastGravity:
    1.68 -		dx = -(*c->w + c->border);
    1.69 +		dx = -(c->w + c->border);
    1.70  		break;
    1.71  	default:
    1.72  		break;
    1.73 @@ -164,8 +164,8 @@
    1.74  		dx = -dx;
    1.75  		dy = -dy;
    1.76  	}
    1.77 -	*c->x += dx;
    1.78 -	*c->y += dy;
    1.79 +	c->x += dx;
    1.80 +	c->y += dy;
    1.81  }
    1.82  
    1.83  void
    1.84 @@ -203,19 +203,14 @@
    1.85  
    1.86  	c = emallocz(sizeof(Client));
    1.87  	c->win = w;
    1.88 -	c->bx = c->fx = c->tx = wa->x;
    1.89 -	c->by = c->fy = c->ty = wa->y;
    1.90 -	c->bw = c->fw = c->tw = wa->width;
    1.91 -	c->fh = c->th = wa->height;
    1.92 -	c->bh = bh;
    1.93 +	c->x = c->tx = wa->x;
    1.94 +	c->y = c->ty = wa->y;
    1.95 +	c->w = c->tw = wa->width;
    1.96 +	c->h = wa->height;
    1.97 +	c->th = bh;
    1.98  
    1.99 -	diff = sw - c->fw;
   1.100 -	c->fx = random() % (diff ? diff : 1);
   1.101 -	diff = sh - c->fh - bh;
   1.102 -	c->fy = random() % (diff ? diff : 1);
   1.103 -
   1.104 -	if(c->fy < bh)
   1.105 -		c->by = c->fy = c->ty = bh;
   1.106 +	if(c->y < bh)
   1.107 +		c->y = c->ty = bh;
   1.108  
   1.109  	c->border = 1;
   1.110  	c->proto = getproto(c->win);
   1.111 @@ -227,7 +222,7 @@
   1.112  	twa.background_pixmap = ParentRelative;
   1.113  	twa.event_mask = ExposureMask;
   1.114  
   1.115 -	c->title = XCreateWindow(dpy, root, c->bx, c->by, c->bw, c->bh,
   1.116 +	c->title = XCreateWindow(dpy, root, c->tx, c->ty, c->tw, c->th,
   1.117  			0, DefaultDepth(dpy, screen), CopyFromParent,
   1.118  			DefaultVisual(dpy, screen),
   1.119  			CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
   1.120 @@ -251,9 +246,7 @@
   1.121  				(c->maxw == c->minw) && (c->maxh == c->minh));
   1.122  
   1.123  
   1.124 -	setgeom(c);
   1.125  	settitle(c);
   1.126 -
   1.127  	arrange(NULL);
   1.128  
   1.129  	/* mapping the window now prevents flicker */
   1.130 @@ -273,10 +266,10 @@
   1.131  {
   1.132  	if(!sel)
   1.133  		return;
   1.134 -	*sel->x = sx;
   1.135 -	*sel->y = sy + bh;
   1.136 -	*sel->w = sw - 2 * sel->border;
   1.137 -	*sel->h = sh - 2 * sel->border - bh;
   1.138 +	sel->x = sx;
   1.139 +	sel->y = sy + bh;
   1.140 +	sel->w = sw - 2 * sel->border;
   1.141 +	sel->h = sh - 2 * sel->border - bh;
   1.142  	higher(sel);
   1.143  	resize(sel, False, TopLeft);
   1.144  }
   1.145 @@ -297,43 +290,43 @@
   1.146  resize(Client *c, Bool inc, Corner sticky)
   1.147  {
   1.148  	XConfigureEvent e;
   1.149 -	int right = *c->x + *c->w;
   1.150 -	int bottom = *c->y + *c->h;
   1.151 +	int right = c->x + c->w;
   1.152 +	int bottom = c->y + c->h;
   1.153  
   1.154  	if(inc) {
   1.155  		if(c->incw)
   1.156 -			*c->w -= (*c->w - c->basew) % c->incw;
   1.157 +			c->w -= (c->w - c->basew) % c->incw;
   1.158  		if(c->inch)
   1.159 -			*c->h -= (*c->h - c->baseh) % c->inch;
   1.160 +			c->h -= (c->h - c->baseh) % c->inch;
   1.161  	}
   1.162 -	if(*c->x > sw) /* might happen on restart */
   1.163 -		*c->x = sw - *c->w;
   1.164 -	if(*c->y > sh)
   1.165 -		*c->y = sh - *c->h;
   1.166 -	if(c->minw && *c->w < c->minw)
   1.167 -		*c->w = c->minw;
   1.168 -	if(c->minh && *c->h < c->minh)
   1.169 -		*c->h = c->minh;
   1.170 -	if(c->maxw && *c->w > c->maxw)
   1.171 -		*c->w = c->maxw;
   1.172 -	if(c->maxh && *c->h > c->maxh)
   1.173 -		*c->h = c->maxh;
   1.174 +	if(c->x > sw) /* might happen on restart */
   1.175 +		c->x = sw - c->w;
   1.176 +	if(c->y > sh)
   1.177 +		c->y = sh - c->h;
   1.178 +	if(c->minw && c->w < c->minw)
   1.179 +		c->w = c->minw;
   1.180 +	if(c->minh && c->h < c->minh)
   1.181 +		c->h = c->minh;
   1.182 +	if(c->maxw && c->w > c->maxw)
   1.183 +		c->w = c->maxw;
   1.184 +	if(c->maxh && c->h > c->maxh)
   1.185 +		c->h = c->maxh;
   1.186  	if(sticky == TopRight || sticky == BotRight)
   1.187 -		*c->x = right - *c->w;
   1.188 +		c->x = right - c->w;
   1.189  	if(sticky == BotLeft || sticky == BotRight)
   1.190 -		*c->y = bottom - *c->h;
   1.191 +		c->y = bottom - c->h;
   1.192  
   1.193  	resizetitle(c);
   1.194  	XSetWindowBorderWidth(dpy, c->win, 1);
   1.195 -	XMoveResizeWindow(dpy, c->win, *c->x, *c->y, *c->w, *c->h);
   1.196 +	XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
   1.197  
   1.198  	e.type = ConfigureNotify;
   1.199  	e.event = c->win;
   1.200  	e.window = c->win;
   1.201 -	e.x = *c->x;
   1.202 -	e.y = *c->y;
   1.203 -	e.width = *c->w;
   1.204 -	e.height = *c->h;
   1.205 +	e.x = c->x;
   1.206 +	e.y = c->y;
   1.207 +	e.width = c->w;
   1.208 +	e.height = c->h;
   1.209  	e.border_width = c->border;
   1.210  	e.above = None;
   1.211  	e.override_redirect = False;
   1.212 @@ -342,23 +335,6 @@
   1.213  }
   1.214  
   1.215  void
   1.216 -setgeom(Client *c)
   1.217 -{
   1.218 -	if((arrange == dotile) && !c->isfloat) {
   1.219 -		c->x = &c->tx;
   1.220 -		c->y = &c->ty;
   1.221 -		c->w = &c->tw;
   1.222 -		c->h = &c->th;
   1.223 -	}
   1.224 -	else {
   1.225 -		c->x = &c->fx;
   1.226 -		c->y = &c->fy;
   1.227 -		c->w = &c->fw;
   1.228 -		c->h = &c->fh;
   1.229 -	}
   1.230 -}
   1.231 -
   1.232 -void
   1.233  setsize(Client *c)
   1.234  {
   1.235  	XSizeHints size;