diff options
Diffstat (limited to '')
| -rw-r--r-- | dwm.c | 102 |
1 files changed, 50 insertions, 52 deletions
| @@ -117,6 +117,7 @@ void cleanup(void); | |||
| 117 | void configure(Client *c); | 117 | void configure(Client *c); |
| 118 | void configurenotify(XEvent *e); | 118 | void configurenotify(XEvent *e); |
| 119 | void configurerequest(XEvent *e); | 119 | void configurerequest(XEvent *e); |
| 120 | unsigned int counttiled(void); | ||
| 120 | void destroynotify(XEvent *e); | 121 | void destroynotify(XEvent *e); |
| 121 | void detach(Client *c); | 122 | void detach(Client *c); |
| 122 | void detachstack(Client *c); | 123 | void detachstack(Client *c); |
| @@ -170,7 +171,8 @@ unsigned int textnw(const char *text, unsigned int len); | |||
| 170 | unsigned int textw(const char *text); | 171 | unsigned int textw(const char *text); |
| 171 | void tileh(void); | 172 | void tileh(void); |
| 172 | void tilehstack(unsigned int n); | 173 | void tilehstack(unsigned int n); |
| 173 | unsigned int tilemaster(void); | 174 | Client *tilemaster(unsigned int n); |
| 175 | void tileresize(Client *c, int x, int y, int w, int h); | ||
| 174 | void tilev(void); | 176 | void tilev(void); |
| 175 | void tilevstack(unsigned int n); | 177 | void tilevstack(unsigned int n); |
| 176 | void togglefloating(const char *arg); | 178 | void togglefloating(const char *arg); |
| @@ -458,6 +460,15 @@ configurerequest(XEvent *e) { | |||
| 458 | XSync(dpy, False); | 460 | XSync(dpy, False); |
| 459 | } | 461 | } |
| 460 | 462 | ||
| 463 | unsigned int | ||
| 464 | counttiled(void) { | ||
| 465 | unsigned int n; | ||
| 466 | Client *c; | ||
| 467 | |||
| 468 | for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next), n++); | ||
| 469 | return n; | ||
| 470 | } | ||
| 471 | |||
| 461 | void | 472 | void |
| 462 | destroynotify(XEvent *e) { | 473 | destroynotify(XEvent *e) { |
| 463 | Client *c; | 474 | Client *c; |
| @@ -1579,89 +1590,76 @@ textw(const char *text) { | |||
| 1579 | } | 1590 | } |
| 1580 | 1591 | ||
| 1581 | void | 1592 | void |
| 1582 | tileresize(Client *c, int x, int y, int w, int h) { | ||
| 1583 | resize(c, x, y, w, h, RESIZEHINTS); | ||
| 1584 | if((RESIZEHINTS) && ((c->h < bh) || (c->h > h) || (c->w < bh) || (c->w > w))) | ||
| 1585 | /* client doesn't accept size constraints */ | ||
| 1586 | resize(c, x, y, w, h, False); | ||
| 1587 | } | ||
| 1588 | |||
| 1589 | void | ||
| 1590 | tileh(void) { | 1593 | tileh(void) { |
| 1591 | tilehstack(tilemaster()); | 1594 | int x, w; |
| 1592 | } | 1595 | unsigned int i, n = counttiled(); |
| 1593 | |||
| 1594 | void | ||
| 1595 | tilehstack(unsigned int n) { | ||
| 1596 | int i, x, w; | ||
| 1597 | Client *c; | 1596 | Client *c; |
| 1598 | 1597 | ||
| 1599 | if(n == 0) | 1598 | if(n == 0) |
| 1600 | return; | 1599 | return; |
| 1600 | c = tilemaster(n); | ||
| 1601 | if(--n == 0) | ||
| 1602 | return; | ||
| 1601 | 1603 | ||
| 1602 | x = tx; | 1604 | x = tx; |
| 1603 | w = tw / n; | 1605 | w = tw / n; |
| 1604 | if(w < bh) | 1606 | if(w < bh) |
| 1605 | w = tw; | 1607 | w = tw; |
| 1606 | 1608 | ||
| 1607 | for(i = 0, c = nexttiled(clients); c; c = nexttiled(c->next), i++) | 1609 | for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) { |
| 1608 | if(i > 0) { | 1610 | if(i + 1 == n) /* remainder */ |
| 1609 | if(i > 1 && i == n) /* remainder */ | 1611 | tileresize(c, x, ty, (tx + tw) - x - 2 * c->border, th - 2 * c->border); |
| 1610 | tileresize(c, x, ty, (tx + tw) - x - 2 * c->border, | 1612 | else |
| 1611 | th - 2 * c->border); | 1613 | tileresize(c, x, ty, w - 2 * c->border, th - 2 * c->border); |
| 1612 | else | 1614 | if(w != tw) |
| 1613 | tileresize(c, x, ty, w - 2 * c->border, | 1615 | x = c->x + c->w + 2 * c->border; |
| 1614 | th - 2 * c->border); | 1616 | } |
| 1615 | if(w != tw) | ||
| 1616 | x = c->x + c->w + 2 * c->border; | ||
| 1617 | } | ||
| 1618 | } | 1617 | } |
| 1619 | 1618 | ||
| 1620 | unsigned int | 1619 | Client * |
| 1621 | tilemaster(void) { | 1620 | tilemaster(unsigned int n) { |
| 1622 | unsigned int n; | 1621 | Client *c = nexttiled(clients); |
| 1623 | Client *c, *mc; | ||
| 1624 | 1622 | ||
| 1625 | for(n = 0, mc = c = nexttiled(clients); c; c = nexttiled(c->next)) | ||
| 1626 | n++; | ||
| 1627 | if(n == 0) | ||
| 1628 | return 0; | ||
| 1629 | if(n == 1) | 1623 | if(n == 1) |
| 1630 | tileresize(mc, mox, moy, mow - 2 * mc->border, moh - 2 * mc->border); | 1624 | tileresize(c, mox, moy, mow - 2 * c->border, moh - 2 * c->border); |
| 1631 | else | 1625 | else |
| 1632 | tileresize(mc, mx, my, mw - 2 * mc->border, mh - 2 * mc->border); | 1626 | tileresize(c, mx, my, mw - 2 * c->border, mh - 2 * c->border); |
| 1633 | return n - 1; | 1627 | return c; |
| 1634 | } | 1628 | } |
| 1635 | 1629 | ||
| 1636 | void | 1630 | void |
| 1637 | tilev(void) { | 1631 | tileresize(Client *c, int x, int y, int w, int h) { |
| 1638 | tilevstack(tilemaster()); | 1632 | resize(c, x, y, w, h, RESIZEHINTS); |
| 1633 | if((RESIZEHINTS) && ((c->h < bh) || (c->h > h) || (c->w < bh) || (c->w > w))) | ||
| 1634 | /* client doesn't accept size constraints */ | ||
| 1635 | resize(c, x, y, w, h, False); | ||
| 1639 | } | 1636 | } |
| 1640 | 1637 | ||
| 1641 | void | 1638 | void |
| 1642 | tilevstack(unsigned int n) { | 1639 | tilev(void) { |
| 1643 | int i, y, h; | 1640 | int y, h; |
| 1641 | unsigned int i, n = counttiled(); | ||
| 1644 | Client *c; | 1642 | Client *c; |
| 1645 | 1643 | ||
| 1646 | if(n == 0) | 1644 | if(n == 0) |
| 1647 | return; | 1645 | return; |
| 1646 | c = tilemaster(n); | ||
| 1647 | if(--n == 0) | ||
| 1648 | return; | ||
| 1648 | 1649 | ||
| 1649 | y = ty; | 1650 | y = ty; |
| 1650 | h = th / n; | 1651 | h = th / n; |
| 1651 | if(h < bh) | 1652 | if(h < bh) |
| 1652 | h = th; | 1653 | h = th; |
| 1653 | 1654 | ||
| 1654 | for(i = 0, c = nexttiled(clients); c; c = nexttiled(c->next), i++) | 1655 | for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) { |
| 1655 | if(i > 0) { | 1656 | if(i + 1 == n) /* remainder */ |
| 1656 | if(i > 1 && i == n) /* remainder */ | 1657 | tileresize(c, tx, y, tw - 2 * c->border, (ty + th) - y - 2 * c->border); |
| 1657 | tileresize(c, tx, y, tw - 2 * c->border, | 1658 | else |
| 1658 | (ty + th) - y - 2 * c->border); | 1659 | tileresize(c, tx, y, tw - 2 * c->border, h - 2 * c->border); |
| 1659 | else | 1660 | if(h != th) |
| 1660 | tileresize(c, tx, y, tw - 2 * c->border, | 1661 | y = c->y + c->h + 2 * c->border; |
| 1661 | h - 2 * c->border); | 1662 | } |
| 1662 | if(h != th) | ||
| 1663 | y = c->y + c->h + 2 * c->border; | ||
| 1664 | } | ||
| 1665 | } | 1663 | } |
| 1666 | 1664 | ||
| 1667 | void | 1665 | void |
