simplified tile() 9189f7a1
Anselm R Garbe · 2008-05-26 10:10 1 file(s) · +15 −37
dwm.c +15 −37
170 170
void tag(const void *arg);
171 171
uint textnw(const char *text, uint len);
172 172
void tile(void);
173 -
void tileresize(Client *c, int x, int y, int w, int h);
174 173
void togglebar(const void *arg);
175 174
void togglefloating(const void *arg);
176 175
void togglelayout(const void *arg);
1123 1122
		x = sx;
1124 1123
	if(y + h + 2 * c->bw < sy)
1125 1124
		y = sy;
1125 +
	if(h < bh)
1126 +
		h = bh;
1127 +
	if(w < bh)
1128 +
		w = bh;
1126 1129
	if(c->x != x || c->y != y || c->w != w || c->h != h || c->isbanned || c->ismax) {
1127 1130
		c->isbanned = c->ismax = False;
1128 1131
		c->x = wc.x = x;
1435 1438
1436 1439
void
1437 1440
tile(void) {
1438 -
	int x, y, h, w, mx, my, mw, mh, tx, ty, tw, th;
1441 +
	int x, y, h, w, mw;
1439 1442
	uint i, n;
1440 1443
	Client *c;
1441 1444
1443 1446
	if(n == 0)
1444 1447
		return;
1445 1448
1446 -
	/* master area geometry */
1447 -
	mx = wx;
1448 -
	my = wy;
1449 -
	mw = mfact * ww;
1450 -
	mh = wh;
1451 -
1452 -
	/* tile area geometry */
1453 -
	tx = mx + mw;
1454 -
	ty = wy;
1455 -
	tw = ww - mw;
1456 -
	th = wh;
1457 -
1458 1449
	/* master */
1459 1450
	c = nexttiled(clients);
1460 -
1461 -
	if(n == 1)
1462 -
		tileresize(c, wx, wy, ww - 2 * c->bw, wh - 2 * c->bw);
1463 -
	else
1464 -
		tileresize(c, mx, my, mw - 2 * c->bw, mh - 2 * c->bw);
1451 +
	mw = mfact * ww;
1452 +
	resize(c, wx, wy, ((n == 1) ? ww : mw) - 2 * c->bw, wh - 2 * c->bw, resizehints);
1465 1453
1466 1454
	if(--n == 0)
1467 1455
		return;
1468 1456
1469 1457
	/* tile stack */
1470 -
	x = (tx > c->x + c->w) ? c->x + c->w + 2 * c->bw : tw;
1471 -
	y = ty;
1472 -
	w = (tx > c->x + c->w) ? wx + ww - x : tw;
1473 -
	h = th / n;
1458 +
	x = (wx + mw > c->x + c->w) ? c->x + c->w + 2 * c->bw : ww - mw;
1459 +
	y = wy;
1460 +
	w = (wx + mw > c->x + c->w) ? wx + ww - x : ww - mw;
1461 +
	h = wh / n;
1474 1462
	if(h < bh)
1475 -
		h = th;
1463 +
		h = wh;
1476 1464
1477 1465
	for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) {
1478 -
		if(i + 1 == n) /* remainder */
1479 -
			tileresize(c, x, y, w - 2 * c->bw, (ty + th) - y - 2 * c->bw);
1480 -
		else
1481 -
			tileresize(c, x, y, w - 2 * c->bw, h - 2 * c->bw);
1482 -
		if(h != th)
1466 +
		resize(c, x, y, w - 2 * c->bw, /* remainder */ ((i + 1 == n)
1467 +
		       ? (wy + wh) - y : h) - 2 * c->bw, resizehints);
1468 +
		if(h != wh)
1483 1469
			y = c->y + c->h + 2 * c->bw;
1484 1470
	}
1485 -
}
1486 -
1487 -
void
1488 -
tileresize(Client *c, int x, int y, int w, int h) {
1489 -
	resize(c, x, y, w, h, resizehints);
1490 -
	if(resizehints && ((c->h < bh) || (c->h > h) || (c->w < bh) || (c->w > w)))
1491 -
		/* client doesn't accept size constraints */
1492 -
		resize(c, x, y, w, h, False);
1493 1471
}
1494 1472
1495 1473
void