implemented the stuff as I discussed on dwm@ 2e958372
Anselm R Garbe · 2008-03-05 18:31 4 file(s) · +124 −225
config.def.h +55 −6
1 1
/* See LICENSE file for copyright and license details. */
2 2
3 3
/* appearance */
4 -
#define BARPOS			BarTop /* BarBot, BarOff */
5 4
#define BORDERPX		1
6 5
#define FONT			"-*-terminus-medium-r-normal-*-14-*-*-*-*-*-*-*"
7 6
#define NORMBORDERCOLOR		"#cccccc"
11 10
#define SELBGCOLOR		"#0066ff"
12 11
#define SELFGCOLOR		"#ffffff"
13 12
13 +
#if WORK
14 +
15 +
/* bar position */
16 +
#define BX 0
17 +
#define BY 0
18 +
#define BW 1280
19 +
20 +
/* master area */
21 +
#define MX 0
22 +
#define MY bh
23 +
#define MW 1280
24 +
#define MH 800 - bh
25 +
26 +
/* tile area, might be on a different screen */
27 +
#define TX 1280
28 +
#define TY 0
29 +
#define TW 1680
30 +
#define TH 1050
31 +
32 +
/* monocle area, might be restricted to a specific screen */
33 +
#define MOX MX
34 +
#define MOY MY
35 +
#define MOW MW
36 +
#define MOH MH
37 +
38 +
#else
39 +
40 +
/* bar position */
41 +
#define BX sx
42 +
#define BY sy
43 +
#define BW sw
44 +
45 +
/* master area */
46 +
#define MX sx
47 +
#define MY sy + bh
48 +
#define MW ((int)(((float)sw) * 0.6))
49 +
#define MH sh - bh
50 +
51 +
/* tile area, might be on a different screen */
52 +
#define TX sx + MW
53 +
#define TY MY
54 +
#define TW sw - MW
55 +
#define TH MH
56 +
57 +
/* monocle area, might be restricted to a specific screen */
58 +
#define MOX sx
59 +
#define MOY MY
60 +
#define MOW sw
61 +
#define MOH MH
62 +
63 +
#endif
64 +
14 65
/* tagging */
15 66
const char tags[][MAXTAGLEN] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
16 67
23 74
};
24 75
25 76
/* layout(s) */
26 -
#define MWFACT			0.6	/* master width factor [0.1 .. 0.9] */
27 77
#define RESIZEHINTS		True	/* False - respect size hints in tiled resizals */
28 78
#define SNAP			32	/* snap pixel */
29 79
41 91
	{ MODKEY,			XK_p,		spawn,
42 92
		"exec dmenu_run -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGCOLOR"' -sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"'" },
43 93
	{ MODKEY|ShiftMask,		XK_Return,	spawn, "exec uxterm" },
44 -
	{ MODKEY,			XK_b,		togglebar,	NULL },
45 94
	{ MODKEY,			XK_j,		focusnext,	NULL },
46 95
	{ MODKEY,			XK_k,		focusprev,	NULL },
47 -
	{ MODKEY,			XK_h,		setmwfact,	"-0.05" },
48 -
	{ MODKEY,			XK_l,		setmwfact,	"+0.05" },
49 96
	{ MODKEY,			XK_r,		reapply,	NULL },
50 97
	{ MODKEY,			XK_Return,	zoom,		NULL },
51 98
	{ MODKEY,			XK_Tab,		viewprevtag,	NULL },
52 -
	{ MODKEY,			XK_space,	setlayout,	NULL },
99 +
	{ MODKEY,			XK_m,		setlayout,	"[M]" },
100 +
	{ MODKEY,			XK_f,		setlayout,	"><>" },
101 +
	{ MODKEY,			XK_t,		setlayout,	"[]=" },
53 102
	{ MODKEY|ShiftMask,		XK_space,	togglefloating,	NULL },
54 103
	{ MODKEY|ShiftMask,		XK_c,		killclient,	NULL },
55 104
	{ MODKEY,			XK_0,		view,		NULL },
config.mk +2 −2
12 12
13 13
# includes and libs
14 14
INCS = -I. -I/usr/include -I${X11INC}
15 -
LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 -lXinerama
15 +
LIBS = -L/usr/lib -lc -L${X11LIB} -lX11
16 16
17 17
# flags
18 18
CFLAGS = -Os ${INCS} -DVERSION=\"${VERSION}\"
19 19
LDFLAGS = -s ${LIBS}
20 -
CFLAGS = -g -std=c99 -pedantic -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\"
20 +
CFLAGS = -g -std=c99 -pedantic -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\" -DWORK
21 21
LDFLAGS = -g ${LIBS}
22 22
23 23
# Solaris
dwm.1 +6 −9
63 63
.B Mod1\-Tab
64 64
Toggles to the previously selected tags.
65 65
.TP
66 -
.B Mod1\-space
67 -
Toggles between layouts.
66 +
.B Mod1\-f
67 +
Apply floating layout.
68 68
.TP
69 -
.B Mod1\-b
70 -
Shows/hides the status bar.
69 +
.B Mod1\-m
70 +
Apply monocle layout.
71 71
.TP
72 -
.B Mod1\-h
73 -
Decreases the master area width about 5% (tiled layout only).
72 +
.B Mod1\-t
73 +
Apply tiled layout.
74 74
.TP
75 75
.B Mod1\-j
76 76
Focus next window.
77 77
.TP
78 78
.B Mod1\-k
79 79
Focus previous window.
80 -
.TP
81 -
.B Mod1\-l
82 -
Increases the master area width about 5% (tiled layout only).
83 80
.TP
84 81
.B Mod1\-r
85 82
Re-applies tagging rules to all windows.
dwm.c +61 −208
40 40
#include <X11/Xlib.h>
41 41
#include <X11/Xproto.h>
42 42
#include <X11/Xutil.h>
43 -
/*
44 -
 * TODO: Idea:
45 -
 * I intend to not provide real Xinerama support, but instead having a Column
46 -
 * tilecols[] array which is used by tile(), and a Column maxcols[] arrays which is used by
47 -
 * monocle(). Those arrays should be initialized in config.h. For simplicity
48 -
 * reasons mwfact should be replaced with a more advanced method which
49 -
 * implements the same, but using the boundary between tilecols[0] and
50 -
 * tilecols[1] instead. Besides this, get rid of BARPOS and use instead the
51 -
 * following mechanism:
52 -
 *
53 -
 * #define BX 0
54 -
 * #define BY 0
55 -
 * #define BW sw
56 -
 * bh is calculated automatically and should be used for the 
57 -
 */
58 -
//#ifdef XINERAMA
59 -
#include <X11/extensions/Xinerama.h>
60 -
//#endif
61 43
62 44
/* macros */
63 45
#define BUTTONMASK		(ButtonPressMask|ButtonReleaseMask)
65 47
#define LENGTH(x)		(sizeof x / sizeof x[0])
66 48
#define MAXTAGLEN		16
67 49
#define MOUSEMASK		(BUTTONMASK|PointerMotionMask)
68 -
69 50
70 51
/* enums */
71 -
enum { BarTop, BarBot, BarOff };			/* bar position */
72 52
enum { CurNormal, CurResize, CurMove, CurLast };	/* cursor */
73 53
enum { ColBorder, ColFG, ColBG, ColLast };		/* color */
74 54
enum { NetSupported, NetWMName, NetLast };		/* EWMH atoms */
79 59
struct Client {
80 60
	char name[256];
81 61
	int x, y, w, h;
62 +
	int rx, ry, rw, rh;
82 63
	int basew, baseh, incw, inch, maxw, maxh, minw, minh;
83 64
	int minax, maxax, minay, maxay;
84 65
	long flags;
90 71
	Client *snext;
91 72
	Window win;
92 73
};
93 -
94 -
typedef struct {
95 -
	int x, y, w, h;
96 -
} Column;
97 74
98 75
typedef struct {
99 76
	int x, y, w, h;
185 162
void scan(void);
186 163
void setclientstate(Client *c, long state);
187 164
void setlayout(const char *arg);
188 -
void setmwfact(const char *arg);
189 165
void setup(void);
190 166
void spawn(const char *arg);
191 167
void tag(const char *arg);
192 168
unsigned int textnw(const char *text, unsigned int len);
193 169
unsigned int textw(const char *text);
194 170
void tile(void);
195 -
void togglebar(const char *arg);
196 171
void togglefloating(const char *arg);
197 172
void toggletag(const char *arg);
198 173
void toggleview(const char *arg);
199 174
void unban(Client *c);
200 175
void unmanage(Client *c);
201 176
void unmapnotify(XEvent *e);
202 -
void updatebarpos(void);
203 177
void updatesizehints(Client *c);
204 178
void updatetitle(Client *c);
205 179
void updatewmhints(Client *c);
214 188
/* variables */
215 189
char stext[256], buf[256];
216 190
double mwfact;
217 -
int screen, sx, sy, sw, sh, wax, way, waw, wah, ncols;
191 +
int screen, sx, sy, sw, sh;
218 192
int (*xerrorxlib)(Display *, XErrorEvent *);
219 193
unsigned int bh, bpos;
220 194
unsigned int blw = 0;
234 208
	[UnmapNotify] = unmapnotify
235 209
};
236 210
Atom wmatom[WMLast], netatom[NetLast];
237 -
Bool domwfact = True;
238 211
Bool dozoom = True;
239 212
Bool otherwm, readin;
240 213
Bool running = True;
243 216
Client *clients = NULL;
244 217
Client *sel = NULL;
245 218
Client *stack = NULL;
246 -
Column *cols = NULL;
247 219
Cursor cursor[CurLast];
248 220
Display *dpy;
249 221
DC dc = {0};
350 322
				return;
351 323
			}
352 324
		}
353 -
		if((ev->x < x + blw) && ev->button == Button1)
354 -
			setlayout(NULL);
355 325
	}
356 326
	else if((c = getclient(ev->window))) {
357 327
		focus(c);
437 407
	XConfigureEvent *ev = &e->xconfigure;
438 408
439 409
	if(ev->window == root && (ev->width != sw || ev->height != sh)) {
440 -
		/* TODO -- use Xinerama dimensions here ? */
441 410
		sw = ev->width;
442 411
		sh = ev->height;
443 412
		XFreePixmap(dpy, dc.drawable);
444 -
		dc.drawable = XCreatePixmap(dpy, root, DisplayWidth(root, screen), bh, DefaultDepth(dpy, screen));
445 -
		XResizeWindow(dpy, barwin, sw, bh);
446 -
		updatebarpos();
413 +
		dc.drawable = XCreatePixmap(dpy, root, BW, bh, DefaultDepth(dpy, screen));
414 +
		XMoveResizeWindow(dpy, barwin, BX, BY, BW, bh);
447 415
		arrange();
448 416
	}
449 417
}
454 422
	XConfigureRequestEvent *ev = &e->xconfigurerequest;
455 423
	XWindowChanges wc;
456 424
457 -
	/* TODO -- consider Xinerama if necessary when centering */
458 425
	if((c = getclient(ev->window))) {
459 426
		if(ev->value_mask & CWBorderWidth)
460 427
			c->border = ev->border_width;
491 458
		XConfigureWindow(dpy, ev->window, ev->value_mask, &wc);
492 459
	}
493 460
	XSync(dpy, False);
494 -
}
495 -
496 -
Bool
497 -
conflicts(Client *c, unsigned int tidx) {
498 -
	unsigned int i;
499 -
500 -
	for(i = 0; i < LENGTH(tags); i++)
501 -
		if(c->tags[i])
502 -
			return True; /* conflict */
503 -
	return False;
504 461
}
505 462
506 463
void
554 511
	drawtext(lt->symbol, dc.norm, False);
555 512
	x = dc.x + dc.w;
556 513
	dc.w = textw(stext);
557 -
	dc.x = sw - dc.w;
514 +
	dc.x = BW - dc.w;
558 515
	if(dc.x < x) {
559 516
		dc.x = x;
560 -
		dc.w = sw - x;
517 +
		dc.w = BW - x;
561 518
	}
562 519
	drawtext(stext, dc.norm, False);
563 520
	if((dc.w = dc.x - x) > bh) {
569 526
		else
570 527
			drawtext(NULL, dc.norm, False);
571 528
	}
572 -
	XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, sw, bh, 0, 0);
529 +
	XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, BW, bh, 0, 0);
573 530
	XSync(dpy, False);
574 531
}
575 532
677 634
floating(void) { /* default floating layout */
678 635
	Client *c;
679 636
680 -
	domwfact = dozoom = False;
637 +
	dozoom = False;
681 638
	for(c = clients; c; c = c->next)
682 639
		if(isvisible(c))
683 640
			resize(c, c->x, c->y, c->w, c->h, True);
690 647
	if(sel && sel != c) {
691 648
		grabbuttons(sel, False);
692 649
		XSetWindowBorder(dpy, sel->win, dc.norm[ColBorder]);
650 +
		if(lt->arrange == monocle)
651 +
			resize(sel, sel->rx, sel->ry, sel->rw, sel->rh, True);
693 652
	}
694 653
	if(c) {
695 654
		detachstack(c);
696 655
		attachstack(c);
697 656
		grabbuttons(c, True);
657 +
		if(lt->arrange == monocle) {
658 +
			if(sel != c) {
659 +
				c->rx = c->x;
660 +
				c->ry = c->y;
661 +
				c->rw = c->w;
662 +
				c->rh = c->h;
663 +
			}
664 +
			resize(c, MOX, MOY, MOW, MOH, RESIZEHINTS);
665 +
		}
698 666
	}
699 667
	sel = c;
700 668
	if(c) {
1016 984
	c->tags = emallocz(TAGSZ);
1017 985
	c->win = w;
1018 986
1019 -
	c->x = wa->x + sx;
1020 -
	c->y = wa->y + sy;
1021 -
	c->w = wa->width;
1022 -
	c->h = wa->height;
987 +
	c->x = c->rx = wa->x + sx;
988 +
	c->y = c->ry = wa->y + sy;
989 +
	c->w = c->rw = wa->width;
990 +
	c->h = c->rh = wa->height;
1023 991
	c->oldborder = wa->border_width;
1024 992
1025 993
	if(c->w == sw && c->h == sh) {
1028 996
		c->border = wa->border_width;
1029 997
	}
1030 998
	else {
1031 -
		if(c->x + c->w + 2 * c->border > wax + waw)
1032 -
			c->x = wax + waw - c->w - 2 * c->border;
1033 -
		if(c->y + c->h + 2 * c->border > way + wah)
1034 -
			c->y = way + wah - c->h - 2 * c->border;
1035 -
		if(c->x < wax)
1036 -
			c->x = wax;
1037 -
		if(c->y < way)
1038 -
			c->y = way;
999 +
		if(c->x + c->w + 2 * c->border > sx + sw)
1000 +
			c->x = sx + sw - c->w - 2 * c->border;
1001 +
		if(c->y + c->h + 2 * c->border > sy + sh)
1002 +
			c->y = sy + sh - c->h - 2 * c->border;
1003 +
		if(c->x < sx)
1004 +
			c->x = sx;
1005 +
		if(c->y < sy)
1006 +
			c->y = sy;
1039 1007
		c->border = BORDERPX;
1040 1008
	}
1041 1009
	wc.border_width = c->border;
1087 1055
1088 1056
void
1089 1057
monocle(void) {
1090 -
	Client *c;
1091 -
1092 -
	domwfact = dozoom = False;
1093 -
	for(c = nexttiled(clients); c; c = nexttiled(c->next))
1094 -
		resize(c, wax, way, waw - 2 * c->border, wah - 2 * c->border, RESIZEHINTS);
1058 +
	dozoom = False;
1095 1059
}
1096 1060
1097 1061
void
1122 1086
			XSync(dpy, False);
1123 1087
			nx = ocx + (ev.xmotion.x - x1);
1124 1088
			ny = ocy + (ev.xmotion.y - y1);
1125 -
			if(abs(wax - nx) < SNAP)
1126 -
				nx = wax;
1127 -
			else if(abs((wax + waw) - (nx + c->w + 2 * c->border)) < SNAP)
1128 -
				nx = wax + waw - c->w - 2 * c->border;
1129 -
			if(abs(way - ny) < SNAP)
1130 -
				ny = way;
1131 -
			else if(abs((way + wah) - (ny + c->h + 2 * c->border)) < SNAP)
1132 -
				ny = way + wah - c->h - 2 * c->border;
1089 +
			if(abs(sx - nx) < SNAP)
1090 +
				nx = sx;
1091 +
			else if(abs((sx + sw) - (nx + c->w + 2 * c->border)) < SNAP)
1092 +
				nx = sx + sw - c->w - 2 * c->border;
1093 +
			if(abs(sy - ny) < SNAP)
1094 +
				ny = sy;
1095 +
			else if(abs((sy + sh) - (ny + c->h + 2 * c->border)) < SNAP)
1096 +
				ny = sy + sh - c->h - 2 * c->border;
1133 1097
			if(!c->isfloating && (lt->arrange != floating) && (abs(nx - c->x) > SNAP || abs(ny - c->y) > SNAP))
1134 1098
				togglefloating(NULL);
1135 1099
			if((lt->arrange == floating) || c->isfloating)
1428 1392
setlayout(const char *arg) {
1429 1393
	unsigned int i;
1430 1394
1431 -
	if(!arg) {
1432 -
		lt++;
1433 -
		if(lt == &layouts[LENGTH(layouts)])
1434 -
			lt = &layouts[0];
1435 -
	}
1436 -
	else {
1437 -
		for(i = 0; i < LENGTH(layouts); i++)
1438 -
			if(!strcmp(arg, layouts[i].symbol))
1439 -
				break;
1440 -
		if(i == LENGTH(layouts))
1441 -
			return;
1442 -
		lt = &layouts[i];
1443 -
	}
1395 +
	if(!arg)
1396 +
		return;
1397 +
	for(i = 0; i < LENGTH(layouts); i++)
1398 +
		if(!strcmp(arg, layouts[i].symbol))
1399 +
			break;
1400 +
	if(i == LENGTH(layouts))
1401 +
		return;
1402 +
	lt = &layouts[i];
1444 1403
	if(sel)
1445 1404
		arrange();
1446 1405
	else
1448 1407
}
1449 1408
1450 1409
void
1451 -
setmwfact(const char *arg) {
1452 -
	double delta;
1453 -
1454 -
	if(!domwfact)
1455 -
		return;
1456 -
	/* arg handling, manipulate mwfact */
1457 -
	if(arg == NULL)
1458 -
		mwfact = MWFACT;
1459 -
	else if(sscanf(arg, "%lf", &delta) == 1) {
1460 -
		if(arg[0] == '+' || arg[0] == '-')
1461 -
			mwfact += delta;
1462 -
		else
1463 -
			mwfact = delta;
1464 -
		if(mwfact < 0.1)
1465 -
			mwfact = 0.1;
1466 -
		else if(mwfact > 0.9)
1467 -
			mwfact = 0.9;
1468 -
	}
1469 -
	arrange();
1470 -
}
1471 -
1472 -
void
1473 1410
setup(void) {
1474 -
	int screens = 1;
1475 1411
	unsigned int i;
1476 1412
	XSetWindowAttributes wa;
1477 -
//#ifdef XINERAMA
1478 -
	XineramaScreenInfo *info;
1479 -
//#endif
1480 1413
1481 1414
	/* init screen */
1482 1415
	screen = DefaultScreen(dpy);
1485 1418
	sy = 0;
1486 1419
	sw = DisplayWidth(dpy, screen);
1487 1420
	sh = DisplayHeight(dpy, screen);
1488 -
	if(XineramaIsActive(dpy)) {
1489 -
		if((info = XineramaQueryScreens(dpy, &screens))) {
1490 -
			sx = info[0].x_org;
1491 -
			sy = info[0].y_org;
1492 -
			sw = info[0].width;
1493 -
			sh = info[0].height;
1494 -
		}
1495 -
	}
1496 1421
1497 1422
	/* init atoms */
1498 1423
	wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
1507 1432
	cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
1508 1433
	cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur);
1509 1434
1510 -
	ncols = 2;
1511 -
#if 0
1512 -
	if(XineramaIsActive(dpy)) {
1513 -
		if((info = XineramaQueryScreens(dpy, &screens))) {
1514 -
			if(screens >= 1) {
1515 -
				sx = info[0].x_org;
1516 -
				sy = info[0].y_org;
1517 -
				sw = info[0].width;
1518 -
				sh = info[0].height;
1519 -
			}
1520 -
			else {
1521 -
				ncols = screens;
1522 -
				cols = emallocz(ncols * sizeof(Column));
1523 -
				for(i = 0; i < ncols; i++) {
1524 -
					cols[i].x = info[i].x_org;
1525 -
					cols[i].y = info[i].y_org;
1526 -
					cols[i].w = info[i].width;
1527 -
					cols[i].h = info[i].height;
1528 -
				}
1529 -
			}
1530 -
			XFree(info);
1531 -
		}
1532 -
	}
1533 -
	else
1534 -
	{
1535 -
		cols = emallocz(ncols * sizeof(Column));
1536 -
		cols[0].x = sx;
1537 -
		cols[0].y = sy;
1538 -
	}
1539 -
#endif
1540 1435
	/* init appearance */
1541 1436
	dc.norm[ColBorder] = getcolor(NORMBORDERCOLOR);
1542 1437
	dc.norm[ColBG] = getcolor(NORMBGCOLOR);
1558 1453
	seltags[0] = prevtags[0] = True;
1559 1454
1560 1455
	/* init layouts */
1561 -
	mwfact = MWFACT;
1562 1456
	lt = &layouts[0];
1563 1457
1564 -
	/* TODO: Xinerama hints ? */
1565 1458
	/* init bar */
1566 1459
	for(blw = i = 0; i < LENGTH(layouts); i++) {
1567 1460
		i = textw(layouts[i].symbol);
1569 1462
			blw = i;
1570 1463
	}
1571 1464
1572 -
	bpos = BARPOS;
1573 1465
	wa.override_redirect = 1;
1574 1466
	wa.background_pixmap = ParentRelative;
1575 1467
	wa.event_mask = ButtonPressMask|ExposureMask;
1576 1468
1577 -
	barwin = XCreateWindow(dpy, root, sx, sy, sw, bh, 0, DefaultDepth(dpy, screen),
1469 +
	barwin = XCreateWindow(dpy, root, BX, BY, BW, bh, 0, DefaultDepth(dpy, screen),
1578 1470
				CopyFromParent, DefaultVisual(dpy, screen),
1579 1471
				CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
1580 1472
	XDefineCursor(dpy, barwin, cursor[CurNormal]);
1581 -
	updatebarpos();
1582 1473
	XMapRaised(dpy, barwin);
1583 1474
	strcpy(stext, "dwm-"VERSION);
1584 1475
	drawbar();
1655 1546
	unsigned int i, n, nx, ny, nw, nh, mw, th;
1656 1547
	Client *c, *mc;
1657 1548
1658 -
	domwfact = dozoom = True;
1659 -
	nx = wax;
1660 -
	ny = way;
1549 +
	dozoom = True;
1550 +
	nx = MX;
1551 +
	ny = MY;
1661 1552
	nw = 0;
1662 1553
	for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
1663 1554
		n++;
1664 1555
1665 1556
	/* window geoms */
1666 -
	mw = (n == 1) ? waw : mwfact * waw;
1667 -
	th = (n > 1) ? wah / (n - 1) : 0;
1557 +
	mw = (n == 1) ? MOW : MW;
1558 +
	th = (n > 1) ? TH / (n - 1) : 0;
1668 1559
	if(n > 1 && th < bh)
1669 -
		th = wah;
1560 +
		th = TH;
1670 1561
1671 1562
	for(i = 0, c = mc = nexttiled(clients); c; c = nexttiled(c->next)) {
1672 1563
		if(i == 0) { /* master */
1673 1564
			nw = mw - 2 * c->border;
1674 -
			nh = wah - 2 * c->border;
1565 +
			nh = MH - 2 * c->border;
1675 1566
		}
1676 1567
		else {  /* tile window */
1677 1568
			if(i == 1) {
1678 -
				ny = way;
1679 -
				nx += mc->w + 2 * mc->border;
1680 -
				nw = waw - mw - 2 * c->border;
1569 +
				ny = TY;
1570 +
				nx = TX;
1571 +
				nw = TW - 2 * c->border;
1681 1572
			}
1682 1573
			if(i + 1 == n) /* remainder */
1683 -
				nh = (way + wah) - ny - 2 * c->border;
1574 +
				nh = (TY + TH) - ny - 2 * c->border;
1684 1575
			else
1685 1576
				nh = th - 2 * c->border;
1686 1577
		}
1688 1579
		if((RESIZEHINTS) && ((c->h < bh) || (c->h > nh) || (c->w < bh) || (c->w > nw)))
1689 1580
			/* client doesn't accept size constraints */
1690 1581
			resize(c, nx, ny, nw, nh, False);
1691 -
		if(n > 1 && th != wah)
1582 +
		if(n > 1 && th != TH)
1692 1583
			ny = c->y + c->h + 2 * c->border;
1693 1584
		i++;
1694 1585
	}
1695 1586
}
1696 1587
1697 1588
void
1698 -
togglebar(const char *arg) {
1699 -
	if(bpos == BarOff)
1700 -
		bpos = (BARPOS == BarOff) ? BarTop : BARPOS;
1701 -
	else
1702 -
		bpos = BarOff;
1703 -
	updatebarpos();
1704 -
	arrange();
1705 -
}
1706 -
1707 -
void
1708 1589
togglefloating(const char *arg) {
1709 1590
	if(!sel)
1710 1591
		return;
1721 1602
	if(!sel)
1722 1603
		return;
1723 1604
	i = idxoftag(arg);
1724 -
	if(conflicts(sel, i))
1725 -
		return;
1726 1605
	sel->tags[i] = !sel->tags[i];
1727 1606
	for(j = 0; j < LENGTH(tags) && !sel->tags[j]; j++);
1728 1607
	if(j == LENGTH(tags))
1780 1659
1781 1660
	if((c = getclient(ev->window)))
1782 1661
		unmanage(c);
1783 -
}
1784 -
1785 -
void
1786 -
updatebarpos(void) {
1787 -
	XEvent ev;
1788 -
1789 -
	wax = sx;
1790 -
	way = sy;
1791 -
	wah = sh;
1792 -
	waw = sw;
1793 -
	switch(bpos) {
1794 -
	default:
1795 -
		wah -= bh;
1796 -
		way += bh;
1797 -
		XMoveWindow(dpy, barwin, sx, sy);
1798 -
		break;
1799 -
	case BarBot:
1800 -
		wah -= bh;
1801 -
		XMoveWindow(dpy, barwin, sx, sy + wah);
1802 -
		break;
1803 -
	case BarOff:
1804 -
		XMoveWindow(dpy, barwin, sx, sy - bh);
1805 -
		break;
1806 -
	}
1807 -
	XSync(dpy, False);
1808 -
	while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
1809 1662
}
1810 1663
1811 1664
void