diff options
| author | Anselm R Garbe <garbeam@gmail.com> | 2008-02-21 10:14:42 +0000 |
|---|---|---|
| committer | Anselm R Garbe <garbeam@gmail.com> | 2008-02-21 10:14:42 +0000 |
| commit | 2e8e5509d9cad9229d2d79a1de75038d94032cfb (patch) | |
| tree | cbb421a3b5d5d296fcdde5eb8235c96d5805b693 /dwm.c | |
| parent | applied Jukka's zoom-patch (diff) | |
| download | dwm-2e8e5509d9cad9229d2d79a1de75038d94032cfb.tar.gz dwm-2e8e5509d9cad9229d2d79a1de75038d94032cfb.zip | |
changed arrange functions to contain the Monitor as first argument
Diffstat (limited to '')
| -rw-r--r-- | dwm.c | 100 |
1 files changed, 49 insertions, 51 deletions
| @@ -99,9 +99,10 @@ typedef struct { | |||
| 99 | const char *arg; | 99 | const char *arg; |
| 100 | } Key; | 100 | } Key; |
| 101 | 101 | ||
| 102 | typedef struct Monitor Monitor; | ||
| 102 | typedef struct { | 103 | typedef struct { |
| 103 | const char *symbol; | 104 | const char *symbol; |
| 104 | void (*arrange)(void); | 105 | void (*arrange)(Monitor *); |
| 105 | } Layout; | 106 | } Layout; |
| 106 | 107 | ||
| 107 | typedef struct { | 108 | typedef struct { |
| @@ -116,14 +117,16 @@ typedef struct { | |||
| 116 | regex_t *tagregex; | 117 | regex_t *tagregex; |
| 117 | } Regs; | 118 | } Regs; |
| 118 | 119 | ||
| 119 | typedef struct { | 120 | struct Monitor { |
| 120 | Window barwin; | 121 | unsigned int id; |
| 121 | int sx, sy, sw, sh, wax, way, wah, waw; | 122 | int sx, sy, sw, sh, wax, way, wah, waw; |
| 123 | double mwfact; | ||
| 122 | Bool *seltags; | 124 | Bool *seltags; |
| 123 | Bool *prevtags; | 125 | Bool *prevtags; |
| 124 | Layout *layout; | 126 | Layout *layout; |
| 125 | double mwfact; | 127 | Window barwin; |
| 126 | } Monitor; | 128 | }; |
| 129 | |||
| 127 | 130 | ||
| 128 | /* function declarations */ | 131 | /* function declarations */ |
| 129 | void applyrules(Client *c); | 132 | void applyrules(Client *c); |
| @@ -148,7 +151,7 @@ void *emallocz(unsigned int size); | |||
| 148 | void enternotify(XEvent *e); | 151 | void enternotify(XEvent *e); |
| 149 | void eprint(const char *errstr, ...); | 152 | void eprint(const char *errstr, ...); |
| 150 | void expose(XEvent *e); | 153 | void expose(XEvent *e); |
| 151 | void floating(void); /* default floating layout */ | 154 | void floating(Monitor *m); /* default floating layout */ |
| 152 | void focus(Client *c); | 155 | void focus(Client *c); |
| 153 | void focusin(XEvent *e); | 156 | void focusin(XEvent *e); |
| 154 | void focusnext(const char *arg); | 157 | void focusnext(const char *arg); |
| @@ -188,7 +191,7 @@ void spawn(const char *arg); | |||
| 188 | void tag(const char *arg); | 191 | void tag(const char *arg); |
| 189 | unsigned int textnw(const char *text, unsigned int len); | 192 | unsigned int textnw(const char *text, unsigned int len); |
| 190 | unsigned int textw(const char *text); | 193 | unsigned int textw(const char *text); |
| 191 | void tile(void); | 194 | void tile(Monitor *m); |
| 192 | void togglebar(const char *arg); | 195 | void togglebar(const char *arg); |
| 193 | void togglefloating(const char *arg); | 196 | void togglefloating(const char *arg); |
| 194 | void toggletag(const char *arg); | 197 | void toggletag(const char *arg); |
| @@ -304,7 +307,7 @@ arrange(void) { | |||
| 304 | else | 307 | else |
| 305 | ban(c); | 308 | ban(c); |
| 306 | 309 | ||
| 307 | monitors[selmonitor].layout->arrange(); | 310 | monitors[selmonitor].layout->arrange(&monitors[selmonitor]); |
| 308 | focus(NULL); | 311 | focus(NULL); |
| 309 | restack(); | 312 | restack(); |
| 310 | } | 313 | } |
| @@ -719,12 +722,12 @@ expose(XEvent *e) { | |||
| 719 | } | 722 | } |
| 720 | 723 | ||
| 721 | void | 724 | void |
| 722 | floating(void) { /* default floating layout */ | 725 | floating(Monitor *m) { /* default floating layout */ |
| 723 | Client *c; | 726 | Client *c; |
| 724 | 727 | ||
| 725 | domwfact = dozoom = False; | 728 | domwfact = dozoom = False; |
| 726 | for(c = clients; c; c = c->next) | 729 | for(c = clients; c; c = c->next) |
| 727 | if(isvisible(c, selmonitor)) | 730 | if(isvisible(c, m->id)) |
| 728 | resize(c, c->x, c->y, c->w, c->h, True); | 731 | resize(c, c->x, c->y, c->w, c->h, True); |
| 729 | } | 732 | } |
| 730 | 733 | ||
| @@ -1598,6 +1601,7 @@ setup(void) { | |||
| 1598 | for(i = 0; i < mcount; i++) { | 1601 | for(i = 0; i < mcount; i++) { |
| 1599 | /* init geometry */ | 1602 | /* init geometry */ |
| 1600 | m = &monitors[i]; | 1603 | m = &monitors[i]; |
| 1604 | m->id = i; | ||
| 1601 | 1605 | ||
| 1602 | if (mcount != 1 && isxinerama) { | 1606 | if (mcount != 1 && isxinerama) { |
| 1603 | m->sx = info[i].x_org; | 1607 | m->sx = info[i].x_org; |
| @@ -1714,56 +1718,50 @@ textw(const char *text) { | |||
| 1714 | } | 1718 | } |
| 1715 | 1719 | ||
| 1716 | void | 1720 | void |
| 1717 | tile(void) { | 1721 | tile(Monitor *m) { |
| 1718 | unsigned int i, j, n, nx, ny, nw, nh, mw, th; | 1722 | unsigned int i, n, nx, ny, nw, nh, mw, th; |
| 1719 | Client *c, *mc; | 1723 | Client *c, *mc; |
| 1720 | 1724 | ||
| 1721 | domwfact = dozoom = True; | 1725 | domwfact = dozoom = True; |
| 1722 | 1726 | ||
| 1723 | nx = ny = nw = 0; /* gcc stupidity requires this */ | 1727 | nx = ny = nw = 0; /* gcc stupidity requires this */ |
| 1724 | 1728 | ||
| 1725 | for (i = 0; i < mcount; i++) { | 1729 | for(n = 0, c = nexttiled(clients, m->id); c; c = nexttiled(c->next, m->id)) |
| 1726 | Monitor *m = &monitors[i]; | 1730 | n++; |
| 1727 | 1731 | ||
| 1728 | for(n = 0, c = nexttiled(clients, i); c; c = nexttiled(c->next, i)) | 1732 | /* window geoms */ |
| 1729 | n++; | 1733 | mw = (n == 1) ? m->waw : m->mwfact * m->waw; |
| 1730 | 1734 | th = (n > 1) ? m->wah / (n - 1) : 0; | |
| 1731 | /* window geoms */ | 1735 | if(n > 1 && th < bh) |
| 1732 | mw = (n == 1) ? m->waw : m->mwfact * m->waw; | 1736 | th = m->wah; |
| 1733 | th = (n > 1) ? m->wah / (n - 1) : 0; | 1737 | |
| 1734 | if(n > 1 && th < bh) | 1738 | for(i = 0, c = mc = nexttiled(clients, m->id); c; c = nexttiled(c->next, m->id)) { |
| 1735 | th = m->wah; | 1739 | if(i == 0) { /* master */ |
| 1736 | 1740 | nx = m->wax; | |
| 1737 | for(j = 0, c = mc = nexttiled(clients, i); c; c = nexttiled(c->next, i)) { | 1741 | ny = m->way; |
| 1738 | if(j == 0) { /* master */ | 1742 | nw = mw - 2 * c->border; |
| 1739 | nx = m->wax; | 1743 | nh = m->wah - 2 * c->border; |
| 1744 | } | ||
| 1745 | else { /* tile window */ | ||
| 1746 | if(i == 1) { | ||
| 1740 | ny = m->way; | 1747 | ny = m->way; |
| 1741 | nw = mw - 2 * c->border; | 1748 | nx += mc->w + 2 * mc->border; |
| 1742 | nh = m->wah - 2 * c->border; | 1749 | nw = m->waw - mw - 2 * c->border; |
| 1743 | } | ||
| 1744 | else { /* tile window */ | ||
| 1745 | if(j == 1) { | ||
| 1746 | ny = m->way; | ||
| 1747 | nx += mc->w + 2 * mc->border; | ||
| 1748 | nw = m->waw - mw - 2 * c->border; | ||
| 1749 | } | ||
| 1750 | if(j + 1 == n) /* remainder */ | ||
| 1751 | nh = (m->way + m->wah) - ny - 2 * c->border; | ||
| 1752 | else | ||
| 1753 | nh = th - 2 * c->border; | ||
| 1754 | } | 1750 | } |
| 1755 | fprintf(stderr, "tile(%d, %d, %d, %d)\n", nx, ny, nw, nh); | 1751 | if(i + 1 == n) /* remainder */ |
| 1756 | resize(c, nx, ny, nw, nh, RESIZEHINTS); | 1752 | nh = (m->way + m->wah) - ny - 2 * c->border; |
| 1757 | if((RESIZEHINTS) && ((c->h < bh) || (c->h > nh) || (c->w < bh) || (c->w > nw))) | 1753 | else |
| 1758 | /* client doesn't accept size constraints */ | 1754 | nh = th - 2 * c->border; |
| 1759 | resize(c, nx, ny, nw, nh, False); | ||
| 1760 | if(n > 1 && th != m->wah) | ||
| 1761 | ny = c->y + c->h + 2 * c->border; | ||
| 1762 | |||
| 1763 | j++; | ||
| 1764 | } | 1755 | } |
| 1756 | resize(c, nx, ny, nw, nh, RESIZEHINTS); | ||
| 1757 | if((RESIZEHINTS) && ((c->h < bh) || (c->h > nh) || (c->w < bh) || (c->w > nw))) | ||
| 1758 | /* client doesn't accept size constraints */ | ||
| 1759 | resize(c, nx, ny, nw, nh, False); | ||
| 1760 | if(n > 1 && th != m->wah) | ||
| 1761 | ny = c->y + c->h + 2 * c->border; | ||
| 1762 | |||
| 1763 | i++; | ||
| 1765 | } | 1764 | } |
| 1766 | fprintf(stderr, "done\n"); | ||
| 1767 | } | 1765 | } |
| 1768 | void | 1766 | void |
| 1769 | togglebar(const char *arg) { | 1767 | togglebar(const char *arg) { |
| @@ -2045,7 +2043,7 @@ selectmonitor(const char *arg) { | |||
| 2045 | int | 2043 | int |
| 2046 | main(int argc, char *argv[]) { | 2044 | main(int argc, char *argv[]) { |
| 2047 | if(argc == 2 && !strcmp("-v", argv[1])) | 2045 | if(argc == 2 && !strcmp("-v", argv[1])) |
| 2048 | eprint("dwm-"VERSION", © 2006-2007 Anselm R. Garbe, Sander van Dijk, " | 2046 | eprint("dwm-"VERSION", © 2006-2008 Anselm R. Garbe, Sander van Dijk, " |
| 2049 | "Jukka Salmi, Premysl Hruby, Szabolcs Nagy, Christof Musik\n"); | 2047 | "Jukka Salmi, Premysl Hruby, Szabolcs Nagy, Christof Musik\n"); |
| 2050 | else if(argc != 1) | 2048 | else if(argc != 1) |
| 2051 | eprint("usage: dwm [-v]\n"); | 2049 | eprint("usage: dwm [-v]\n"); |
