removed all defines of geoms, implemented setgeoms() instead, added config.anselm.h to show how I'd like to see that people edit their geoms 95eae7b9
Anselm R Garbe · 2008-03-13 10:11 4 file(s) · +115 −96
Makefile +1 −1
35 35
dist: clean
36 36
	@echo creating dist tarball
37 37
	@mkdir -p dwm-${VERSION}
38 -
	@cp -R LICENSE Makefile README config.def.h config.mk \
38 +
	@cp -R LICENSE Makefile README config.*.h config.mk \
39 39
		dwm.1 ${SRC} dwm-${VERSION}
40 40
	@tar -cf dwm-${VERSION}.tar dwm-${VERSION}
41 41
	@gzip dwm-${VERSION}.tar
config.anselm.h +61 −36
10 10
#define SELBGCOLOR		"#0066ff"
11 11
#define SELFGCOLOR		"#ffffff"
12 12
13 -
/* bar position */
14 -
#define BX 0
15 -
#define BY 0
16 -
#define BW 1280
17 -
18 -
/* window area, including floating windows */
19 -
#define WX 0
20 -
#define WY bh
21 -
#define WW sw
22 -
#define WH sh - bh
23 -
24 -
/* master area */
25 -
#define MX WX
26 -
#define MY bh
27 -
#define MW 1280
28 -
#define MH 800 - bh
29 -
30 -
/* tile area, might be on a different screen */
31 -
#define TX 1280
32 -
#define TY 0
33 -
#define TW 1680
34 -
#define TH 1050
35 -
36 -
/* monocle area, might be restricted to a specific screen */
37 -
#define MOX MX
38 -
#define MOY MY
39 -
#define MOW MW
40 -
#define MOH MH
41 -
42 13
/* tagging */
43 14
const char tags[][MAXTAGLEN] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
44 15
56 27
57 28
Layout layouts[] = {
58 29
	/* symbol		function	isfloating */
59 -
	{ "[]|",		tileh,		False }, /* first entry is default */
60 -
	{ "[]=",		tilev,		False },
30 +
	{ "[]=",		tilev,		False }, /* first entry is default */
31 +
	{ "[]|",		tileh,		False },
61 32
	{ "><>",		floating,	True },
62 33
	{ "[M]",		monocle,	True },
63 34
};
64 35
36 +
void
37 +
setanselmgeoms(void) {
38 +
39 +
	/* screen dimensions */
40 +
	sx = 0;
41 +
	sy = 0;
42 +
	sw = DisplayWidth(dpy, screen);
43 +
	sh = DisplayHeight(dpy, screen);
44 +
45 +
	/* bar position */
46 +
	bx = sx;
47 +
	by = sy;
48 +
	bw = 1280;
49 +
	bh = dc.font.height + 2;
50 +
51 +
	/* window area */
52 +
	wx = sx;
53 +
	wy = sy + bh;
54 +
	ww = sw;
55 +
	wh = sh - bh;
56 +
57 +
	/* master area */
58 +
	mx = wx;
59 +
	my = wy;
60 +
	mw = 1280;
61 +
	mh = 800;
62 +
63 +
	/* tile area */
64 +
	tx = 1280;
65 +
	ty = 0;
66 +
	tw = ww - 1280;
67 +
	th = wh;
68 +
69 +
	/* monocle area */
70 +
	mox = mx;
71 +
	moy = my;
72 +
	mow = mw;
73 +
	moh = mh;
74 +
75 +
	if(dc.drawable != 0)
76 +
		XFreePixmap(dpy, dc.drawable);
77 +
	dc.drawable = XCreatePixmap(dpy, root, bw, bh, DefaultDepth(dpy, screen));
78 +
	XMoveResizeWindow(dpy, barwin, bx, by, bw, bh);
79 +
}
80 +
81 +
void
82 +
anselmgeoms(const char *arg) {
83 +
	setgeoms = setanselmgeoms;
84 +
	arrange();
85 +
}
86 +
87 +
void
88 +
defgeoms(const char *arg) {
89 +
	setgeoms = setdefaultgeoms;
90 +
	arrange();
91 +
}
92 +
65 93
/* key definitions */
66 94
#define MODKEY			Mod1Mask
67 95
Key keys[] = {
68 96
	/* modifier			key		function	argument */
69 -
#if ANSELM_OFFICE
70 97
	{ MODKEY,			XK_p,		spawn,
71 98
		"exec dmenu_run -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGCOLOR"' -sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"' -x 0 -y 0 -w 1280" },
72 -
#else
73 -
	{ MODKEY,			XK_p,		spawn,
74 -
		"exec dmenu_run -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGCOLOR"' -sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"'" },
75 -
#endif
76 99
	{ MODKEY|ShiftMask,		XK_Return,	spawn, "exec uxterm" },
100 +
	{ MODKEY,			XK_a,		anselmgeoms,	NULL },
101 +
	{ MODKEY,			XK_d,		defgeoms,	NULL },
77 102
	{ MODKEY,			XK_j,		focusnext,	NULL },
78 103
	{ MODKEY,			XK_k,		focusprev,	NULL },
79 104
	{ MODKEY,			XK_r,		reapply,	NULL },
config.def.h +0 −34
10 10
#define SELBGCOLOR		"#0066ff"
11 11
#define SELFGCOLOR		"#ffffff"
12 12
13 -
/* bar position */
14 -
#define BX sx
15 -
#define BY sy
16 -
#define BW sw
17 -
18 -
/* window area */
19 -
#define WX 0
20 -
#define WY bh
21 -
#define WW sw
22 -
#define WH sh - bh
23 -
24 -
/* master area */
25 -
#define MX WX
26 -
#define MY WY
27 -
#define MW ((int)(((float)sw) * 0.6))
28 -
#define MH WH
29 -
30 -
/* tile area, might be on a different screen */
31 -
#define TX MX + MW
32 -
#define TY WY
33 -
#define TW WW - MW
34 -
#define TH WH
35 -
36 -
/* monocle area, might be restricted to a specific screen */
37 -
#define MOX WX
38 -
#define MOY WY
39 -
#define MOW WW
40 -
#define MOH WH
41 -
42 13
/* tagging */
43 14
const char tags[][MAXTAGLEN] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
44 15
66 37
#define MODKEY			Mod1Mask
67 38
Key keys[] = {
68 39
	/* modifier			key		function	argument */
69 -
#if ANSELM_OFFICE
70 -
	{ MODKEY,			XK_p,		spawn,
71 -
		"exec dmenu_run -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGCOLOR"' -sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"' -x 0 -y 0 -w 1280" },
72 -
#else
73 40
	{ MODKEY,			XK_p,		spawn,
74 41
		"exec dmenu_run -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGCOLOR"' -sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"'" },
75 -
#endif
76 42
	{ MODKEY|ShiftMask,		XK_Return,	spawn, "exec uxterm" },
77 43
	{ MODKEY,			XK_j,		focusnext,	NULL },
78 44
	{ MODKEY,			XK_k,		focusprev,	NULL },
dwm.c +53 −25
160 160
void run(void);
161 161
void scan(void);
162 162
void setclientstate(Client *c, long state);
163 +
void setdefaultgeoms(void);
163 164
void setlayout(const char *arg);
164 165
void setup(void);
165 166
void spawn(const char *arg);
220 221
DC dc = {0};
221 222
Layout *lt = NULL;
222 223
Window root, barwin;
224 +
void (*setgeoms)(void) = setdefaultgeoms;
223 225
224 226
/* configuration, allows nested code to access above variables */
225 227
#include "config.h"
404 406
	XConfigureEvent *ev = &e->xconfigure;
405 407
406 408
	if(ev->window == root && (ev->width != sw || ev->height != sh)) {
407 -
		sw = ev->width;
408 -
		sh = ev->height;
409 -
		XFreePixmap(dpy, dc.drawable);
410 -
		dc.drawable = XCreatePixmap(dpy, root, bw, bh, DefaultDepth(dpy, screen));
411 -
		XMoveResizeWindow(dpy, barwin, bx, by, bw, bh);
409 +
		setgeoms();
412 410
		arrange();
413 411
	}
414 412
}
1379 1377
}
1380 1378
1381 1379
void
1380 +
setdefaultgeoms(void) {
1381 +
1382 +
	/* screen dimensions */
1383 +
	sx = 0;
1384 +
	sy = 0;
1385 +
	sw = DisplayWidth(dpy, screen);
1386 +
	sh = DisplayHeight(dpy, screen);
1387 +
1388 +
	/* bar position */
1389 +
	bx = sx;
1390 +
	by = sy;
1391 +
	bw = sw;
1392 +
	bh = dc.font.height + 2;
1393 +
1394 +
	/* window area */
1395 +
	wx = sx;
1396 +
	wy = sy + bh;
1397 +
	ww = sw;
1398 +
	wh = sh - bh;
1399 +
1400 +
	/* master area */
1401 +
	mx = wx;
1402 +
	my = wy;
1403 +
	mw = ((float)sw) * 0.55;
1404 +
	mh = wh;
1405 +
1406 +
	/* tile area */
1407 +
	tx = wx;
1408 +
	ty = wy;
1409 +
	tw = ww - mw;
1410 +
	th = wh;
1411 +
1412 +
	/* monocle area */
1413 +
	mox = wx;
1414 +
	moy = wy;
1415 +
	mow = ww;
1416 +
	moh = wh;
1417 +
1418 +
	if(dc.drawable != 0)
1419 +
		XFreePixmap(dpy, dc.drawable);
1420 +
	dc.drawable = XCreatePixmap(dpy, root, bw, bh, DefaultDepth(dpy, screen));
1421 +
	XMoveResizeWindow(dpy, barwin, bx, by, bw, bh);
1422 +
}
1423 +
1424 +
void
1382 1425
setlayout(const char *arg) {
1383 1426
	static Layout *revert = 0;
1384 1427
	unsigned int i;
1410 1453
	/* init screen */
1411 1454
	screen = DefaultScreen(dpy);
1412 1455
	root = RootWindow(dpy, screen);
1413 -
	sx = 0;
1414 -
	sy = 0;
1415 -
	sw = DisplayWidth(dpy, screen);
1416 -
	sh = DisplayHeight(dpy, screen);
1456 +
	initfont(FONT);
1457 +
1458 +
	/* apply default geometries */
1459 +
	setgeoms();
1417 1460
1418 1461
	/* init atoms */
1419 1462
	wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
1436 1479
	dc.sel[ColBG] = getcolor(SELBGCOLOR);
1437 1480
	dc.sel[ColFG] = getcolor(SELFGCOLOR);
1438 1481
	initfont(FONT);
1439 -
	dc.h = bh = dc.font.height + 2;
1482 +
	dc.h = bh;
1440 1483
	dc.drawable = XCreatePixmap(dpy, root, DisplayWidth(dpy, screen), bh, DefaultDepth(dpy, screen));
1441 1484
	dc.gc = XCreateGC(dpy, root, 0, 0);
1442 1485
	XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
1450 1493
1451 1494
	/* init layouts */
1452 1495
	lt = &layouts[0];
1453 -
1454 -
	/* bar position */
1455 -
	bx = BX; by = BY; bw = BW;
1456 -
1457 -
	/* window area */
1458 -
	wx = WX; wy = WY; ww = WW; wh = WH;
1459 -
1460 -
	/* master area */
1461 -
	mx = MX; my = MY; mw = MW; mh = MH;
1462 -
1463 -
	/* tile area */
1464 -
	tx = TX; ty = TY; tw = TW; th = TH;
1465 -
1466 -
	/* monocle area */
1467 -
	mox = MOX; moy = MOY; mow = MOW; moh = MOH;
1468 1496
1469 1497
	/* init bar */
1470 1498
	for(blw = i = 0; i < LENGTH(layouts); i++) {