changed adjustborder to be a macro b16d8282
a@null · 2008-12-19 23:56 1 file(s) · +7 −19
dwm.c +7 −19
41 41
#endif
42 42
43 43
/* macros */
44 +
#define ADJUSTBORDER(C, BW)     if((C)->bw != (BW)) XSetWindowBorder(dpy, (C)->win, (BW));
44 45
#define BUTTONMASK              (ButtonPressMask|ButtonReleaseMask)
45 46
#define CLEANMASK(mask)         (mask & ~(numlockmask|LockMask))
46 47
#define INRECT(X,Y,RX,RY,RW,RH) ((X) >= (RX) && (X) < (RX) + (RW) && (Y) >= (RY) && (Y) < (RY) + (RH))
128 129
} Rule;
129 130
130 131
/* function declarations */
131 -
static void adjustborder(Client *c, Bool issingle);
132 132
static void applyrules(Client *c);
133 133
static void arrange(void);
134 134
static void attach(Client *c);
245 245
struct NumTags { char limitexceeded[sizeof(unsigned int) * 8 < LENGTH(tags) ? -1 : 1]; };
246 246
247 247
/* function implementations */
248 -
void
249 -
adjustborder(Client *c, Bool issingle) {
250 -
	XWindowChanges wc;
251 -
252 -
	wc.border_width = issingle ? 0 : borderpx;
253 -
	if(c->bw != wc.border_width) {
254 -
		c->bw = wc.border_width;
255 -
		XConfigureWindow(dpy, c->win, CWBorderWidth, &wc);
256 -
	}
257 -
}
258 -
259 248
void
260 249
applyrules(Client *c) {
261 250
	unsigned int i;
941 930
942 931
	for(n = 0, c = nexttiled(clients); c && n < 2; c = nexttiled(c->next), n++);
943 932
	for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
944 -
		adjustborder(c, n == 1);
933 +
		ADJUSTBORDER(c, (n == 1 ? 0 : borderpx))
945 934
		resize(c, wx, wy, ww - 2 * c->bw, wh - 2 * c->bw, resizehints);
946 935
	}
947 936
}
1148 1137
			handler[ev.type](&ev);
1149 1138
			break;
1150 1139
		case MotionNotify:
1151 -
			nw = MAX(ev.xmotion.x - ocx - 2*c->bw + 1, 1);
1152 -
			nh = MAX(ev.xmotion.y - ocy - 2*c->bw + 1, 1);
1153 -
1140 +
			nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1);
1141 +
			nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1);
1154 1142
			if(snap && nw >= wx && nw <= wx + ww
1155 1143
			        && nh >= wy && nh <= wy + wh) {
1156 1144
				if(!c->isfloating && lt[sellt]->arrange
1346 1334
	if(!c)
1347 1335
		return;
1348 1336
	if(ISVISIBLE(c)) { /* show clients top down */
1349 -
		adjustborder(c, False);
1337 +
		ADJUSTBORDER(c, borderpx)
1350 1338
		XMoveWindow(dpy, c->win, c->x, c->y);
1351 1339
		if(!lt[sellt]->arrange || c->isfloating)
1352 1340
			resize(c, c->x, c->y, c->w, c->h, True);
1410 1398
	/* master */
1411 1399
	c = nexttiled(clients);
1412 1400
	mw = mfact * ww;
1413 -
	adjustborder(c, n == 1);
1401 +
	ADJUSTBORDER(c, (n == 1 ? 0 : borderpx))
1414 1402
	resize(c, wx, wy, (n == 1 ? ww : mw) - 2 * c->bw, wh - 2 * c->bw, resizehints);
1415 1403
1416 1404
	if(--n == 0)
1425 1413
		h = wh;
1426 1414
1427 1415
	for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) {
1428 -
		adjustborder(c, False);
1416 +
		ADJUSTBORDER(c, borderpx)
1429 1417
		resize(c, x, y, w - 2 * c->bw, /* remainder */ ((i + 1 == n)
1430 1418
		       ? wy + wh - y - 2 * c->bw : h - 2 * c->bw), resizehints);
1431 1419
		if(h != wh)