168 void setup(void); |
168 void setup(void); |
169 void spawn(const void *arg); |
169 void spawn(const void *arg); |
170 void tag(const void *arg); |
170 void tag(const void *arg); |
171 uint textnw(const char *text, uint len); |
171 uint textnw(const char *text, uint len); |
172 void tile(void); |
172 void tile(void); |
173 void tileresize(Client *c, int x, int y, int w, int h); |
|
174 void togglebar(const void *arg); |
173 void togglebar(const void *arg); |
175 void togglefloating(const void *arg); |
174 void togglefloating(const void *arg); |
176 void togglelayout(const void *arg); |
175 void togglelayout(const void *arg); |
177 void togglemax(const void *arg); |
176 void togglemax(const void *arg); |
178 void toggletag(const void *arg); |
177 void toggletag(const void *arg); |
1121 y = sh - h - 2 * c->bw; |
1120 y = sh - h - 2 * c->bw; |
1122 if(x + w + 2 * c->bw < sx) |
1121 if(x + w + 2 * c->bw < sx) |
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; |
1129 c->y = wc.y = y; |
1132 c->y = wc.y = y; |
1130 c->w = wc.width = w; |
1133 c->w = wc.width = w; |
1433 return XTextWidth(dc.font.xfont, text, len); |
1436 return XTextWidth(dc.font.xfont, text, len); |
1434 } |
1437 } |
1435 |
1438 |
1436 void |
1439 void |
1437 tile(void) { |
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 uint i, n; |
1442 uint i, n; |
1440 Client *c; |
1443 Client *c; |
1441 |
1444 |
1442 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next), n++); |
1445 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next), n++); |
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 } |
|
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 void |
1473 void |
1496 togglebar(const void *arg) { |
1474 togglebar(const void *arg) { |
1497 showbar = !showbar; |
1475 showbar = !showbar; |