diff options
| author | anselm@anselm1 <unknown> | 2008-05-19 20:07:12 +0100 |
|---|---|---|
| committer | anselm@anselm1 <unknown> | 2008-05-19 20:07:12 +0100 |
| commit | 822101dd5bceadb12351dd5f9084d7745b10ec92 (patch) | |
| tree | c9ed3b1c3181b4be933c826834688fc510365393 | |
| parent | take bar into account (diff) | |
| download | dwm-822101dd5bceadb12351dd5f9084d7745b10ec92.tar.gz dwm-822101dd5bceadb12351dd5f9084d7745b10ec92.zip | |
merged tile.c again into dwm.c
Diffstat (limited to '')
| -rw-r--r-- | config.def.h | 4 | ||||
| -rw-r--r-- | dwm.c | 101 | ||||
| -rw-r--r-- | tile.c | 102 |
3 files changed, 101 insertions, 106 deletions
diff --git a/config.def.h b/config.def.h index 0619a9e..63c8c06 100644 --- a/config.def.h +++ b/config.def.h | |||
| @@ -25,12 +25,10 @@ Rule rules[] = { | |||
| 25 | double mfact = 0.55; | 25 | double mfact = 0.55; |
| 26 | Bool resizehints = True; /* False means respect size hints in tiled resizals */ | 26 | Bool resizehints = True; /* False means respect size hints in tiled resizals */ |
| 27 | 27 | ||
| 28 | #include "tile.c" | ||
| 29 | |||
| 30 | Layout layouts[] = { | 28 | Layout layouts[] = { |
| 31 | /* symbol arrange geom */ | 29 | /* symbol arrange geom */ |
| 32 | { "[]=", tile, updatetilegeom }, /* first entry is default */ | 30 | { "[]=", tile, updatetilegeom }, /* first entry is default */ |
| 33 | { "><>", NULL, }, /* no layout function means floating behavior */ | 31 | { "><>", NULL, NULL }, /* no layout function means floating behavior */ |
| 34 | }; | 32 | }; |
| 35 | 33 | ||
| 36 | /* key definitions */ | 34 | /* key definitions */ |
| @@ -53,7 +53,6 @@ | |||
| 53 | #define MOUSEMASK (BUTTONMASK|PointerMotionMask) | 53 | #define MOUSEMASK (BUTTONMASK|PointerMotionMask) |
| 54 | 54 | ||
| 55 | /* enums */ | 55 | /* enums */ |
| 56 | enum { BarTop, BarBot, BarOff, BarLast }; /* bar appearance */ | ||
| 57 | enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ | 56 | enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ |
| 58 | enum { ColBorder, ColFG, ColBG, ColLast }; /* color */ | 57 | enum { ColBorder, ColFG, ColBG, ColLast }; /* color */ |
| 59 | enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */ | 58 | enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */ |
| @@ -165,11 +164,14 @@ void restack(void); | |||
| 165 | void run(void); | 164 | void run(void); |
| 166 | void scan(void); | 165 | void scan(void); |
| 167 | void setclientstate(Client *c, long state); | 166 | void setclientstate(Client *c, long state); |
| 167 | void setmfact(const char *arg); | ||
| 168 | void setup(void); | 168 | void setup(void); |
| 169 | void spawn(const char *arg); | 169 | void spawn(const char *arg); |
| 170 | void tag(const char *arg); | 170 | void tag(const char *arg); |
| 171 | unsigned int textnw(const char *text, unsigned int len); | 171 | unsigned int textnw(const char *text, unsigned int len); |
| 172 | unsigned int textw(const char *text); | 172 | unsigned int textw(const char *text); |
| 173 | void tile(void); | ||
| 174 | void tileresize(Client *c, int x, int y, int w, int h); | ||
| 173 | void togglebar(const char *arg); | 175 | void togglebar(const char *arg); |
| 174 | void togglefloating(const char *arg); | 176 | void togglefloating(const char *arg); |
| 175 | void togglelayout(const char *arg); | 177 | void togglelayout(const char *arg); |
| @@ -181,6 +183,7 @@ void unmapnotify(XEvent *e); | |||
| 181 | void updatebar(void); | 183 | void updatebar(void); |
| 182 | void updategeom(void); | 184 | void updategeom(void); |
| 183 | void updatesizehints(Client *c); | 185 | void updatesizehints(Client *c); |
| 186 | void updatetilegeom(void); | ||
| 184 | void updatetitle(Client *c); | 187 | void updatetitle(Client *c); |
| 185 | void updatewmhints(Client *c); | 188 | void updatewmhints(Client *c); |
| 186 | void view(const char *arg); | 189 | void view(const char *arg); |
| @@ -194,6 +197,7 @@ void zoom(const char *arg); | |||
| 194 | char stext[256]; | 197 | char stext[256]; |
| 195 | int screen, sx, sy, sw, sh; | 198 | int screen, sx, sy, sw, sh; |
| 196 | int bx, by, bw, bh, blw, wx, wy, ww, wh; | 199 | int bx, by, bw, bh, blw, wx, wy, ww, wh; |
| 200 | int mx, my, mw, mh, tx, ty, tw, th; | ||
| 197 | int seltags = 0; | 201 | int seltags = 0; |
| 198 | int (*xerrorxlib)(Display *, XErrorEvent *); | 202 | int (*xerrorxlib)(Display *, XErrorEvent *); |
| 199 | unsigned int numlockmask = 0; | 203 | unsigned int numlockmask = 0; |
| @@ -1333,6 +1337,24 @@ setclientstate(Client *c, long state) { | |||
| 1333 | } | 1337 | } |
| 1334 | 1338 | ||
| 1335 | void | 1339 | void |
| 1340 | setmfact(const char *arg) { | ||
| 1341 | double d; | ||
| 1342 | |||
| 1343 | if(!arg || lt->arrange != tile) | ||
| 1344 | return; | ||
| 1345 | else { | ||
| 1346 | d = strtod(arg, NULL); | ||
| 1347 | if(arg[0] == '-' || arg[0] == '+') | ||
| 1348 | d += mfact; | ||
| 1349 | if(d < 0.1 || d > 0.9) | ||
| 1350 | return; | ||
| 1351 | mfact = d; | ||
| 1352 | } | ||
| 1353 | updatetilegeom(); | ||
| 1354 | arrange(); | ||
| 1355 | } | ||
| 1356 | |||
| 1357 | void | ||
| 1336 | setup(void) { | 1358 | setup(void) { |
| 1337 | unsigned int i, w; | 1359 | unsigned int i, w; |
| 1338 | XSetWindowAttributes wa; | 1360 | XSetWindowAttributes wa; |
| @@ -1467,6 +1489,53 @@ textw(const char *text) { | |||
| 1467 | } | 1489 | } |
| 1468 | 1490 | ||
| 1469 | void | 1491 | void |
| 1492 | tile(void) { | ||
| 1493 | int x, y, h, w; | ||
| 1494 | unsigned int i, n; | ||
| 1495 | Client *c; | ||
| 1496 | |||
| 1497 | for(n = 0, c = nextunfloating(clients); c; c = nextunfloating(c->next), n++); | ||
| 1498 | if(n == 0) | ||
| 1499 | return; | ||
| 1500 | |||
| 1501 | /* master */ | ||
| 1502 | c = nextunfloating(clients); | ||
| 1503 | |||
| 1504 | if(n == 1) | ||
| 1505 | tileresize(c, wx, wy, ww - 2 * c->bw, wh - 2 * c->bw); | ||
| 1506 | else | ||
| 1507 | tileresize(c, mx, my, mw - 2 * c->bw, mh - 2 * c->bw); | ||
| 1508 | |||
| 1509 | if(--n == 0) | ||
| 1510 | return; | ||
| 1511 | |||
| 1512 | /* tile stack */ | ||
| 1513 | x = (tx > c->x + c->w) ? c->x + c->w + 2 * c->bw : tw; | ||
| 1514 | y = ty; | ||
| 1515 | w = (tx > c->x + c->w) ? wx + ww - x : tw; | ||
| 1516 | h = th / n; | ||
| 1517 | if(h < bh) | ||
| 1518 | h = th; | ||
| 1519 | |||
| 1520 | for(i = 0, c = nextunfloating(c->next); c; c = nextunfloating(c->next), i++) { | ||
| 1521 | if(i + 1 == n) /* remainder */ | ||
| 1522 | tileresize(c, x, y, w - 2 * c->bw, (ty + th) - y - 2 * c->bw); | ||
| 1523 | else | ||
| 1524 | tileresize(c, x, y, w - 2 * c->bw, h - 2 * c->bw); | ||
| 1525 | if(h != th) | ||
| 1526 | y = c->y + c->h + 2 * c->bw; | ||
| 1527 | } | ||
| 1528 | } | ||
| 1529 | |||
| 1530 | void | ||
| 1531 | tileresize(Client *c, int x, int y, int w, int h) { | ||
| 1532 | resize(c, x, y, w, h, resizehints); | ||
| 1533 | if(resizehints && ((c->h < bh) || (c->h > h) || (c->w < bh) || (c->w > w))) | ||
| 1534 | /* client doesn't accept size constraints */ | ||
| 1535 | resize(c, x, y, w, h, False); | ||
| 1536 | } | ||
| 1537 | |||
| 1538 | void | ||
| 1470 | togglebar(const char *arg) { | 1539 | togglebar(const char *arg) { |
| 1471 | showbar = !showbar; | 1540 | showbar = !showbar; |
| 1472 | updategeom(); | 1541 | updategeom(); |
| @@ -1668,6 +1737,21 @@ updatesizehints(Client *c) { | |||
| 1668 | } | 1737 | } |
| 1669 | 1738 | ||
| 1670 | void | 1739 | void |
| 1740 | updatetilegeom(void) { | ||
| 1741 | /* master area geometry */ | ||
| 1742 | mx = wx; | ||
| 1743 | my = wy; | ||
| 1744 | mw = mfact * ww; | ||
| 1745 | mh = wh; | ||
| 1746 | |||
| 1747 | /* tile area geometry */ | ||
| 1748 | tx = mx + mw; | ||
| 1749 | ty = wy; | ||
| 1750 | tw = ww - mw; | ||
| 1751 | th = wh; | ||
| 1752 | } | ||
| 1753 | |||
| 1754 | void | ||
| 1671 | updatetitle(Client *c) { | 1755 | updatetitle(Client *c) { |
| 1672 | if(!gettextprop(c->win, netatom[NetWMName], c->name, sizeof c->name)) | 1756 | if(!gettextprop(c->win, netatom[NetWMName], c->name, sizeof c->name)) |
| 1673 | gettextprop(c->win, wmatom[WMName], c->name, sizeof c->name); | 1757 | gettextprop(c->win, wmatom[WMName], c->name, sizeof c->name); |
| @@ -1733,6 +1817,21 @@ xerrorstart(Display *dpy, XErrorEvent *ee) { | |||
| 1733 | return -1; | 1817 | return -1; |
| 1734 | } | 1818 | } |
| 1735 | 1819 | ||
| 1820 | void | ||
| 1821 | zoom(const char *arg) { | ||
| 1822 | Client *c = sel; | ||
| 1823 | |||
| 1824 | if(c == nextunfloating(clients)) | ||
| 1825 | if(!c || !(c = nextunfloating(c->next))) | ||
| 1826 | return; | ||
| 1827 | if(lt->arrange == tile && !sel->isfloating) { | ||
| 1828 | detach(c); | ||
| 1829 | attach(c); | ||
| 1830 | focus(c); | ||
| 1831 | } | ||
| 1832 | arrange(); | ||
| 1833 | } | ||
| 1834 | |||
| 1736 | int | 1835 | int |
| 1737 | main(int argc, char *argv[]) { | 1836 | main(int argc, char *argv[]) { |
| 1738 | if(argc == 2 && !strcmp("-v", argv[1])) | 1837 | if(argc == 2 && !strcmp("-v", argv[1])) |
| @@ -1,102 +0,0 @@ | |||
| 1 | /* See LICENSE file for copyright and license details. */ | ||
| 2 | int bx, by, bw, bh, blw, mx, my, mw, mh, tx, ty, tw, th, wx, wy, ww, wh; | ||
| 3 | |||
| 4 | void setmfact(const char *arg); | ||
| 5 | void tile(void); | ||
| 6 | void tileresize(Client *c, int x, int y, int w, int h); | ||
| 7 | void updatetilegeom(void); | ||
| 8 | |||
| 9 | void | ||
| 10 | setmfact(const char *arg) { | ||
| 11 | double d; | ||
| 12 | |||
| 13 | if(!arg || lt->arrange != tile) | ||
| 14 | return; | ||
| 15 | else { | ||
| 16 | d = strtod(arg, NULL); | ||
| 17 | if(arg[0] == '-' || arg[0] == '+') | ||
| 18 | d += mfact; | ||
| 19 | if(d < 0.1 || d > 0.9) | ||
| 20 | return; | ||
| 21 | mfact = d; | ||
| 22 | } | ||
| 23 | updatetilegeom(); | ||
| 24 | arrange(); | ||
| 25 | } | ||
| 26 | |||
| 27 | void | ||
| 28 | tile(void) { | ||
| 29 | int x, y, h, w; | ||
| 30 | unsigned int i, n; | ||
| 31 | Client *c; | ||
| 32 | |||
| 33 | for(n = 0, c = nextunfloating(clients); c; c = nextunfloating(c->next), n++); | ||
| 34 | if(n == 0) | ||
| 35 | return; | ||
| 36 | |||
| 37 | /* master */ | ||
| 38 | c = nextunfloating(clients); | ||
| 39 | |||
| 40 | if(n == 1) | ||
| 41 | tileresize(c, wx, wy, ww - 2 * c->bw, wh - 2 * c->bw); | ||
| 42 | else | ||
| 43 | tileresize(c, mx, my, mw - 2 * c->bw, mh - 2 * c->bw); | ||
| 44 | |||
| 45 | if(--n == 0) | ||
| 46 | return; | ||
| 47 | |||
| 48 | /* tile stack */ | ||
| 49 | x = (tx > c->x + c->w) ? c->x + c->w + 2 * c->bw : tw; | ||
| 50 | y = ty; | ||
| 51 | w = (tx > c->x + c->w) ? wx + ww - x : tw; | ||
| 52 | h = th / n; | ||
| 53 | if(h < bh) | ||
| 54 | h = th; | ||
| 55 | |||
| 56 | for(i = 0, c = nextunfloating(c->next); c; c = nextunfloating(c->next), i++) { | ||
| 57 | if(i + 1 == n) /* remainder */ | ||
| 58 | tileresize(c, x, y, w - 2 * c->bw, (ty + th) - y - 2 * c->bw); | ||
| 59 | else | ||
| 60 | tileresize(c, x, y, w - 2 * c->bw, h - 2 * c->bw); | ||
| 61 | if(h != th) | ||
| 62 | y = c->y + c->h + 2 * c->bw; | ||
| 63 | } | ||
| 64 | } | ||
| 65 | |||
| 66 | void | ||
| 67 | tileresize(Client *c, int x, int y, int w, int h) { | ||
| 68 | resize(c, x, y, w, h, resizehints); | ||
| 69 | if(resizehints && ((c->h < bh) || (c->h > h) || (c->w < bh) || (c->w > w))) | ||
| 70 | /* client doesn't accept size constraints */ | ||
| 71 | resize(c, x, y, w, h, False); | ||
| 72 | } | ||
| 73 | |||
| 74 | void | ||
| 75 | zoom(const char *arg) { | ||
| 76 | Client *c = sel; | ||
| 77 | |||
| 78 | if(c == nextunfloating(clients)) | ||
| 79 | if(!c || !(c = nextunfloating(c->next))) | ||
| 80 | return; | ||
| 81 | if(lt->arrange == tile && !sel->isfloating) { | ||
| 82 | detach(c); | ||
| 83 | attach(c); | ||
| 84 | focus(c); | ||
| 85 | } | ||
| 86 | arrange(); | ||
| 87 | } | ||
| 88 | |||
| 89 | void | ||
| 90 | updatetilegeom(void) { | ||
| 91 | /* master area geometry */ | ||
| 92 | mx = wx; | ||
| 93 | my = wy; | ||
| 94 | mw = mfact * ww; | ||
| 95 | mh = wh; | ||
| 96 | |||
| 97 | /* tile area geometry */ | ||
| 98 | tx = mx + mw; | ||
| 99 | ty = wy; | ||
| 100 | tw = ww - mw; | ||
| 101 | th = wh; | ||
| 102 | } | ||
