summaryrefslogtreecommitdiffstats
path: root/dwm.c
diff options
context:
space:
mode:
authorAnselm R Garbe <garbeam@gmail.com>2008-05-26 10:10:33 +0100
committerAnselm R Garbe <garbeam@gmail.com>2008-05-26 10:10:33 +0100
commit9189f7a12dce4e3b38341e0704cca257994ab2ba (patch)
treecf2fe842cb96e40a0ee7752e3738fbcf5dd8176c /dwm.c
parentremoved Layout->updategeom, unnecessary (diff)
downloaddwm-9189f7a12dce4e3b38341e0704cca257994ab2ba.tar.gz
dwm-9189f7a12dce4e3b38341e0704cca257994ab2ba.zip
simplified tile()
Diffstat (limited to 'dwm.c')
-rw-r--r--dwm.c52
1 files changed, 15 insertions, 37 deletions
diff --git a/dwm.c b/dwm.c
index 0e4703e..2fe70e4 100644
--- a/dwm.c
+++ b/dwm.c
@@ -170,7 +170,6 @@ void spawn(const void *arg);
170void tag(const void *arg); 170void tag(const void *arg);
171uint textnw(const char *text, uint len); 171uint textnw(const char *text, uint len);
172void tile(void); 172void tile(void);
173void tileresize(Client *c, int x, int y, int w, int h);
174void togglebar(const void *arg); 173void togglebar(const void *arg);
175void togglefloating(const void *arg); 174void togglefloating(const void *arg);
176void togglelayout(const void *arg); 175void togglelayout(const void *arg);
@@ -1123,6 +1122,10 @@ resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
1123 x = sx; 1122 x = sx;
1124 if(y + h + 2 * c->bw < sy) 1123 if(y + h + 2 * c->bw < sy)
1125 y = sy; 1124 y = sy;
1125 if(h < bh)
1126 h = bh;
1127 if(w < bh)
1128 w = bh;
1126 if(c->x != x || c->y != y || c->w != w || c->h != h || c->isbanned || c->ismax) { 1129 if(c->x != x || c->y != y || c->w != w || c->h != h || c->isbanned || c->ismax) {
1127 c->isbanned = c->ismax = False; 1130 c->isbanned = c->ismax = False;
1128 c->x = wc.x = x; 1131 c->x = wc.x = x;
@@ -1435,7 +1438,7 @@ textnw(const char *text, uint len) {
1435 1438
1436void 1439void
1437tile(void) { 1440tile(void) {
1438 int x, y, h, w, mx, my, mw, mh, tx, ty, tw, th; 1441 int x, y, h, w, mw;
1439 uint i, n; 1442 uint i, n;
1440 Client *c; 1443 Client *c;
1441 1444
@@ -1443,56 +1446,31 @@ tile(void) {
1443 if(n == 0) 1446 if(n == 0)
1444 return; 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 /* master */ 1449 /* master */
1459 c = nexttiled(clients); 1450 c = nexttiled(clients);
1460 1451 mw = mfact * ww;
1461 if(n == 1) 1452 resize(c, wx, wy, ((n == 1) ? ww : mw) - 2 * c->bw, wh - 2 * c->bw, resizehints);
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);
1465 1453
1466 if(--n == 0) 1454 if(--n == 0)
1467 return; 1455 return;
1468 1456
1469 /* tile stack */ 1457 /* tile stack */
1470 x = (tx > c->x + c->w) ? c->x + c->w + 2 * c->bw : tw; 1458 x = (wx + mw > c->x + c->w) ? c->x + c->w + 2 * c->bw : ww - mw;
1471 y = ty; 1459 y = wy;
1472 w = (tx > c->x + c->w) ? wx + ww - x : tw; 1460 w = (wx + mw > c->x + c->w) ? wx + ww - x : ww - mw;
1473 h = th / n; 1461 h = wh / n;
1474 if(h < bh) 1462 if(h < bh)
1475 h = th; 1463 h = wh;
1476 1464
1477 for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) { 1465 for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) {
1478 if(i + 1 == n) /* remainder */ 1466 resize(c, x, y, w - 2 * c->bw, /* remainder */ ((i + 1 == n)
1479 tileresize(c, x, y, w - 2 * c->bw, (ty + th) - y - 2 * c->bw); 1467 ? (wy + wh) - y : h) - 2 * c->bw, resizehints);
1480 else 1468 if(h != wh)
1481 tileresize(c, x, y, w - 2 * c->bw, h - 2 * c->bw);
1482 if(h != th)
1483 y = c->y + c->h + 2 * c->bw; 1469 y = c->y + c->h + 2 * c->bw;
1484 } 1470 }
1485} 1471}
1486 1472
1487void 1473void
1488tileresize(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}
1494
1495void
1496togglebar(const void *arg) { 1474togglebar(const void *arg) {
1497 showbar = !showbar; 1475 showbar = !showbar;
1498 updategeom(); 1476 updategeom();