summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoranselm@anselm1 <unknown>2008-05-19 20:07:12 +0100
committeranselm@anselm1 <unknown>2008-05-19 20:07:12 +0100
commit822101dd5bceadb12351dd5f9084d7745b10ec92 (patch)
treec9ed3b1c3181b4be933c826834688fc510365393
parenttake bar into account (diff)
downloaddwm-822101dd5bceadb12351dd5f9084d7745b10ec92.tar.gz
dwm-822101dd5bceadb12351dd5f9084d7745b10ec92.zip
merged tile.c again into dwm.c
Diffstat (limited to '')
-rw-r--r--config.def.h4
-rw-r--r--dwm.c101
-rw-r--r--tile.c102
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[] = {
25double mfact = 0.55; 25double mfact = 0.55;
26Bool resizehints = True; /* False means respect size hints in tiled resizals */ 26Bool resizehints = True; /* False means respect size hints in tiled resizals */
27 27
28#include "tile.c"
29
30Layout layouts[] = { 28Layout 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 */
diff --git a/dwm.c b/dwm.c
index 16e04b0..235940e 100644
--- a/dwm.c
+++ b/dwm.c
@@ -53,7 +53,6 @@
53#define MOUSEMASK (BUTTONMASK|PointerMotionMask) 53#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
54 54
55/* enums */ 55/* enums */
56enum { BarTop, BarBot, BarOff, BarLast }; /* bar appearance */
57enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ 56enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
58enum { ColBorder, ColFG, ColBG, ColLast }; /* color */ 57enum { ColBorder, ColFG, ColBG, ColLast }; /* color */
59enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */ 58enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */
@@ -165,11 +164,14 @@ void restack(void);
165void run(void); 164void run(void);
166void scan(void); 165void scan(void);
167void setclientstate(Client *c, long state); 166void setclientstate(Client *c, long state);
167void setmfact(const char *arg);
168void setup(void); 168void setup(void);
169void spawn(const char *arg); 169void spawn(const char *arg);
170void tag(const char *arg); 170void tag(const char *arg);
171unsigned int textnw(const char *text, unsigned int len); 171unsigned int textnw(const char *text, unsigned int len);
172unsigned int textw(const char *text); 172unsigned int textw(const char *text);
173void tile(void);
174void tileresize(Client *c, int x, int y, int w, int h);
173void togglebar(const char *arg); 175void togglebar(const char *arg);
174void togglefloating(const char *arg); 176void togglefloating(const char *arg);
175void togglelayout(const char *arg); 177void togglelayout(const char *arg);
@@ -181,6 +183,7 @@ void unmapnotify(XEvent *e);
181void updatebar(void); 183void updatebar(void);
182void updategeom(void); 184void updategeom(void);
183void updatesizehints(Client *c); 185void updatesizehints(Client *c);
186void updatetilegeom(void);
184void updatetitle(Client *c); 187void updatetitle(Client *c);
185void updatewmhints(Client *c); 188void updatewmhints(Client *c);
186void view(const char *arg); 189void view(const char *arg);
@@ -194,6 +197,7 @@ void zoom(const char *arg);
194char stext[256]; 197char stext[256];
195int screen, sx, sy, sw, sh; 198int screen, sx, sy, sw, sh;
196int bx, by, bw, bh, blw, wx, wy, ww, wh; 199int bx, by, bw, bh, blw, wx, wy, ww, wh;
200int mx, my, mw, mh, tx, ty, tw, th;
197int seltags = 0; 201int seltags = 0;
198int (*xerrorxlib)(Display *, XErrorEvent *); 202int (*xerrorxlib)(Display *, XErrorEvent *);
199unsigned int numlockmask = 0; 203unsigned int numlockmask = 0;
@@ -1333,6 +1337,24 @@ setclientstate(Client *c, long state) {
1333} 1337}
1334 1338
1335void 1339void
1340setmfact(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
1357void
1336setup(void) { 1358setup(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
1469void 1491void
1492tile(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
1530void
1531tileresize(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
1538void
1470togglebar(const char *arg) { 1539togglebar(const char *arg) {
1471 showbar = !showbar; 1540 showbar = !showbar;
1472 updategeom(); 1541 updategeom();
@@ -1668,6 +1737,21 @@ updatesizehints(Client *c) {
1668} 1737}
1669 1738
1670void 1739void
1740updatetilegeom(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
1754void
1671updatetitle(Client *c) { 1755updatetitle(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
1820void
1821zoom(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
1736int 1835int
1737main(int argc, char *argv[]) { 1836main(int argc, char *argv[]) {
1738 if(argc == 2 && !strcmp("-v", argv[1])) 1837 if(argc == 2 && !strcmp("-v", argv[1]))
diff --git a/tile.c b/tile.c
deleted file mode 100644
index 8269676..0000000
--- a/tile.c
+++ /dev/null
@@ -1,102 +0,0 @@
1/* See LICENSE file for copyright and license details. */
2int bx, by, bw, bh, blw, mx, my, mw, mh, tx, ty, tw, th, wx, wy, ww, wh;
3
4void setmfact(const char *arg);
5void tile(void);
6void tileresize(Client *c, int x, int y, int w, int h);
7void updatetilegeom(void);
8
9void
10setmfact(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
27void
28tile(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
66void
67tileresize(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
74void
75zoom(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
89void
90updatetilegeom(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}