dwm-meillo

changeset 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 eca09aac3ccc
files client.c dwm.h event.c tag.c
diffstat 4 files changed, 85 insertions(+), 114 deletions(-) [+]
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;
     2.1 --- a/dwm.h	Wed Jul 19 17:42:08 2006 +0200
     2.2 +++ b/dwm.h	Thu Jul 20 07:26:23 2006 +0200
     2.3 @@ -67,10 +67,8 @@
     2.4  	char name[256];
     2.5  	char *tags[TLast];
     2.6  	int proto;
     2.7 -	int *x, *y, *w, *h; /* current geom */
     2.8 -	int bx, by, bw, bh; /* title bar */
     2.9 -	int fx, fy, fw, fh; /* floating geom */
    2.10 -	int tx, ty, tw, th; /* tiled geom */
    2.11 +	int x, y, w, h;
    2.12 +	int tx, ty, tw, th; /* title */
    2.13  	int basew, baseh, incw, inch, maxw, maxh, minw, minh;
    2.14  	int grav;
    2.15  	unsigned int border;
    2.16 @@ -109,7 +107,6 @@
    2.17  extern void maximize(Arg *arg);
    2.18  extern void pop(Client *c);
    2.19  extern void resize(Client *c, Bool inc, Corner sticky);
    2.20 -extern void setgeom(Client *c);
    2.21  extern void setsize(Client *c);
    2.22  extern void settitle(Client *c);
    2.23  extern void unmanage(Client *c);
     3.1 --- a/event.c	Wed Jul 19 17:42:08 2006 +0200
     3.2 +++ b/event.c	Thu Jul 20 07:26:23 2006 +0200
     3.3 @@ -70,8 +70,8 @@
     3.4  	unsigned int dui;
     3.5  	Window dummy;
     3.6  
     3.7 -	ocx = *c->x;
     3.8 -	ocy = *c->y;
     3.9 +	ocx = c->x;
    3.10 +	ocy = c->y;
    3.11  	if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync,
    3.12  				None, cursor[CurMove], CurrentTime) != GrabSuccess)
    3.13  		return;
    3.14 @@ -85,8 +85,8 @@
    3.15  			break;
    3.16  		case MotionNotify:
    3.17  			XSync(dpy, False);
    3.18 -			*c->x = ocx + (ev.xmotion.x - x1);
    3.19 -			*c->y = ocy + (ev.xmotion.y - y1);
    3.20 +			c->x = ocx + (ev.xmotion.x - x1);
    3.21 +			c->y = ocy + (ev.xmotion.y - y1);
    3.22  			resize(c, False, TopLeft);
    3.23  			break;
    3.24  		case ButtonRelease:
    3.25 @@ -103,12 +103,12 @@
    3.26  	int ocx, ocy;
    3.27  	Corner sticky;
    3.28  
    3.29 -	ocx = *c->x;
    3.30 -	ocy = *c->y;
    3.31 +	ocx = c->x;
    3.32 +	ocy = c->y;
    3.33  	if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync,
    3.34  				None, cursor[CurResize], CurrentTime) != GrabSuccess)
    3.35  		return;
    3.36 -	XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, *c->w, *c->h);
    3.37 +	XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h);
    3.38  	for(;;) {
    3.39  		XMaskEvent(dpy, MouseMask | ExposureMask, &ev);
    3.40  		switch(ev.type) {
    3.41 @@ -118,10 +118,10 @@
    3.42  			break;
    3.43  		case MotionNotify:
    3.44  			XSync(dpy, False);
    3.45 -			*c->w = abs(ocx - ev.xmotion.x);
    3.46 -			*c->h = abs(ocy - ev.xmotion.y);
    3.47 -			*c->x = (ocx <= ev.xmotion.x) ? ocx : ocx - *c->w;
    3.48 -			*c->y = (ocy <= ev.xmotion.y) ? ocy : ocy - *c->h;
    3.49 +			c->w = abs(ocx - ev.xmotion.x);
    3.50 +			c->h = abs(ocy - ev.xmotion.y);
    3.51 +			c->x = (ocx <= ev.xmotion.x) ? ocx : ocx - c->w;
    3.52 +			c->y = (ocy <= ev.xmotion.y) ? ocy : ocy - c->h;
    3.53  			if(ocx <= ev.xmotion.x)
    3.54  				sticky = (ocy <= ev.xmotion.y) ? TopLeft : BotLeft;
    3.55  			else
    3.56 @@ -203,13 +203,13 @@
    3.57  	if((c = getclient(ev->window))) {
    3.58  		gravitate(c, True);
    3.59  		if(ev->value_mask & CWX)
    3.60 -			*c->x = ev->x;
    3.61 +			c->x = ev->x;
    3.62  		if(ev->value_mask & CWY)
    3.63 -			*c->y = ev->y;
    3.64 +			c->y = ev->y;
    3.65  		if(ev->value_mask & CWWidth)
    3.66 -			*c->w = ev->width;
    3.67 +			c->w = ev->width;
    3.68  		if(ev->value_mask & CWHeight)
    3.69 -			*c->h = ev->height;
    3.70 +			c->h = ev->height;
    3.71  		if(ev->value_mask & CWBorderWidth)
    3.72  			c->border = 1;
    3.73  		gravitate(c, False);
     4.1 --- a/tag.c	Wed Jul 19 17:42:08 2006 +0200
     4.2 +++ b/tag.c	Thu Jul 20 07:26:23 2006 +0200
     4.3 @@ -53,7 +53,6 @@
     4.4  
     4.5  	arrange = dofloat;
     4.6  	for(c = clients; c; c = c->next) {
     4.7 -		setgeom(c);
     4.8  		if(c->tags[tsel]) {
     4.9  			resize(c, True, TopLeft);
    4.10  		}
    4.11 @@ -87,7 +86,6 @@
    4.12  		h = sh - bh;
    4.13  
    4.14  	for(i = 0, c = clients; c; c = c->next) {
    4.15 -		setgeom(c);
    4.16  		if(c->tags[tsel]) {
    4.17  			if(c->isfloat) {
    4.18  				higher(c);
    4.19 @@ -95,28 +93,28 @@
    4.20  				continue;
    4.21  			}
    4.22  			if(n == 1) {
    4.23 -				*c->x = sx;
    4.24 -				*c->y = sy + bh;
    4.25 -				*c->w = sw - 2 * c->border;
    4.26 -				*c->h = sh - 2 * c->border - bh;
    4.27 +				c->x = sx;
    4.28 +				c->y = sy + bh;
    4.29 +				c->w = sw - 2 * c->border;
    4.30 +				c->h = sh - 2 * c->border - bh;
    4.31  			}
    4.32  			else if(i == 0) {
    4.33 -				*c->x = sx;
    4.34 -				*c->y = sy + bh;
    4.35 -				*c->w = mw - 2 * c->border;
    4.36 -				*c->h = sh - 2 * c->border - bh;
    4.37 +				c->x = sx;
    4.38 +				c->y = sy + bh;
    4.39 +				c->w = mw - 2 * c->border;
    4.40 +				c->h = sh - 2 * c->border - bh;
    4.41  			}
    4.42  			else if(h > bh) {
    4.43 -				*c->x = sx + mw;
    4.44 -				*c->y = sy + (i - 1) * h + bh;
    4.45 -				*c->w = w - 2 * c->border;
    4.46 -				*c->h = h - 2 * c->border;
    4.47 +				c->x = sx + mw;
    4.48 +				c->y = sy + (i - 1) * h + bh;
    4.49 +				c->w = w - 2 * c->border;
    4.50 +				c->h = h - 2 * c->border;
    4.51  			}
    4.52  			else { /* fallback if h < bh */
    4.53 -				*c->x = sx + mw;
    4.54 -				*c->y = sy + bh;
    4.55 -				*c->w = w - 2 * c->border;
    4.56 -				*c->h = sh - 2 * c->border - bh;
    4.57 +				c->x = sx + mw;
    4.58 +				c->y = sy + bh;
    4.59 +				c->w = w - 2 * c->border;
    4.60 +				c->h = sh - 2 * c->border - bh;
    4.61  			}
    4.62  			resize(c, False, TopLeft);
    4.63  			i++;