summaryrefslogtreecommitdiffstats
path: root/dwm.c
diff options
context:
space:
mode:
authorAnselm R Garbe <garbeam@gmail.com>2008-03-13 13:59:40 +0000
committerAnselm R Garbe <garbeam@gmail.com>2008-03-13 13:59:40 +0000
commit831428b00cf0bb6c7830c2178c8d13213f29b2db (patch)
treea6abf32121b64f42247053a160162ec89ad83bf2 /dwm.c
parentminor bugfix (diff)
downloaddwm-831428b00cf0bb6c7830c2178c8d13213f29b2db.tar.gz
dwm-831428b00cf0bb6c7830c2178c8d13213f29b2db.zip
some polishing in tileh/tilev
Diffstat (limited to '')
-rw-r--r--dwm.c102
1 files changed, 50 insertions, 52 deletions
diff --git a/dwm.c b/dwm.c
index 0071379..0894c65 100644
--- a/dwm.c
+++ b/dwm.c
@@ -117,6 +117,7 @@ void cleanup(void);
117void configure(Client *c); 117void configure(Client *c);
118void configurenotify(XEvent *e); 118void configurenotify(XEvent *e);
119void configurerequest(XEvent *e); 119void configurerequest(XEvent *e);
120unsigned int counttiled(void);
120void destroynotify(XEvent *e); 121void destroynotify(XEvent *e);
121void detach(Client *c); 122void detach(Client *c);
122void detachstack(Client *c); 123void detachstack(Client *c);
@@ -170,7 +171,8 @@ unsigned int textnw(const char *text, unsigned int len);
170unsigned int textw(const char *text); 171unsigned int textw(const char *text);
171void tileh(void); 172void tileh(void);
172void tilehstack(unsigned int n); 173void tilehstack(unsigned int n);
173unsigned int tilemaster(void); 174Client *tilemaster(unsigned int n);
175void tileresize(Client *c, int x, int y, int w, int h);
174void tilev(void); 176void tilev(void);
175void tilevstack(unsigned int n); 177void tilevstack(unsigned int n);
176void togglefloating(const char *arg); 178void togglefloating(const char *arg);
@@ -458,6 +460,15 @@ configurerequest(XEvent *e) {
458 XSync(dpy, False); 460 XSync(dpy, False);
459} 461}
460 462
463unsigned int
464counttiled(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
461void 472void
462destroynotify(XEvent *e) { 473destroynotify(XEvent *e) {
463 Client *c; 474 Client *c;
@@ -1579,89 +1590,76 @@ textw(const char *text) {
1579} 1590}
1580 1591
1581void 1592void
1582tileresize(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
1589void
1590tileh(void) { 1593tileh(void) {
1591 tilehstack(tilemaster()); 1594 int x, w;
1592} 1595 unsigned int i, n = counttiled();
1593
1594void
1595tilehstack(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
1620unsigned int 1619Client *
1621tilemaster(void) { 1620tilemaster(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
1636void 1630void
1637tilev(void) { 1631tileresize(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
1641void 1638void
1642tilevstack(unsigned int n) { 1639tilev(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
1667void 1665void