we need a tagset per monitor, removed tagset declaration from config.h c2fff604
Anselm R Garbe · 2009-06-20 17:02 2 file(s) · +17 −16
config.def.h +0 −1
16 16
17 17
/* tagging */
18 18
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
19 -
static unsigned int tagset[] = {1, 1}; /* after start, first tag is selected */
20 19
21 20
static Rule rules[] = {
22 21
	/* class      instance    title       tags mask     isfloating */
dwm.c +17 −15
44 44
#define BUTTONMASK              (ButtonPressMask|ButtonReleaseMask)
45 45
#define CLEANMASK(mask)         (mask & ~(numlockmask|LockMask))
46 46
#define INRECT(X,Y,RX,RY,RW,RH) ((X) >= (RX) && (X) < (RX) + (RW) && (Y) >= (RY) && (Y) < (RY) + (RH))
47 -
#define ISVISIBLE(M, C)         ((M) == (&mon[C->mon]) && (C->tags & tagset[M->seltags]))
47 +
#define ISVISIBLE(M, C)         ((M) == (&mon[C->mon]) && (C->tags & M->tagset[M->seltags]))
48 48
#define LENGTH(X)               (sizeof X / sizeof X[0])
49 -
#define MAX(a, b)               ((a) > (b) ? (a) : (b))
50 -
#define MIN(a, b)               ((a) < (b) ? (a) : (b))
49 +
#define MAX(A, B)               ((A) > (B) ? (A) : (B))
50 +
#define MIN(A, B)               ((A) < (B) ? (A) : (B))
51 51
#define MOUSEMASK               (BUTTONMASK|PointerMotionMask)
52 -
#define WIDTH(x)                ((x)->w + 2 * (x)->bw)
53 -
#define HEIGHT(x)               ((x)->h + 2 * (x)->bw)
52 +
#define WIDTH(X)                ((X)->w + 2 * (X)->bw)
53 +
#define HEIGHT(X)               ((X)->h + 2 * (X)->bw)
54 54
#define TAGMASK                 ((int)((1LL << LENGTH(tags)) - 1))
55 -
#define TEXTW(x)                (textnw(x, strlen(x)) + dc.font.height)
55 +
#define TEXTW(X)                (textnw(X, strlen(X)) + dc.font.height)
56 56
57 57
/* enums */
58 58
enum { CurNormal, CurResize, CurMove, CurLast };        /* cursor */
121 121
	int wx, wy, ww, wh;   /* window area  */
122 122
	unsigned int seltags;
123 123
	unsigned int sellt;
124 +
	unsigned int tagset[2];
124 125
	Bool showbar;
125 126
	Bool topbar;
126 127
	Window barwin;
284 285
		if(ch.res_name)
285 286
			XFree(ch.res_name);
286 287
	}
287 -
	c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : tagset[mon[c->mon].seltags];
288 +
	c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : mon[c->mon].tagset[mon[c->mon].seltags];
288 289
}
289 290
290 291
Bool
605 606
	m->btx = dc.x;
606 607
	for(i = 0; i < LENGTH(tags); i++) {
607 608
		dc.w = TEXTW(tags[i]);
608 -
		col = tagset[m->seltags] & 1 << i ? dc.sel : dc.norm;
609 +
		col = m->tagset[m->seltags] & 1 << i ? dc.sel : dc.norm;
609 610
		drawtext(tags[i], col, urg & 1 << i);
610 611
		drawsquare(m == selmon && sel && sel->tags & 1 << i,
611 612
		           occ & 1 << i, urg & 1 << i, col);
748 749
	else
749 750
		XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
750 751
	sel = c;
751 -
	if(c)
752 -
		selmon = &mon[c->mon];
753 752
	drawbars();
754 753
}
755 754
1413 1412
		return;
1414 1413
	if(ISVISIBLE((&mon[c->mon]), c)) { /* show clients top down */
1415 1414
		XMoveWindow(dpy, c->win, c->x, c->y);
1416 -
		if(!lt[selmon->sellt]->arrange || c->isfloating)
1415 +
		if(!lt[mon[c->mon].sellt]->arrange || c->isfloating)
1417 1416
			resize(c, c->x, c->y, c->w, c->h);
1418 1417
		showhide(c->snext);
1419 1418
	}
1540 1539
1541 1540
void
1542 1541
toggleview(const Arg *arg) {
1543 -
	unsigned int mask = tagset[selmon->seltags] ^ (arg->ui & TAGMASK);
1542 +
	unsigned int mask = selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK);
1544 1543
1545 1544
	if(mask) {
1546 -
		tagset[selmon->seltags] = mask;
1545 +
		selmon->tagset[selmon->seltags] = mask;
1547 1546
		arrange();
1548 1547
	}
1549 1548
}
1595 1594
					c->mon = n - 1;
1596 1595
			if(!(mon = (Monitor *)realloc(mon, sizeof(Monitor) * n)))
1597 1596
				die("fatal: could not realloc() %u bytes\n", sizeof(Monitor) * nmons);
1597 +
			selmon = NULL;
1598 1598
		}
1599 1599
		for(i = 0; i < n ; i++) {
1600 1600
			/* TODO: consider re-using XineramaScreenInfo */
1606 1606
				mon[i].mfact = mfact;
1607 1607
				mon[i].showbar = showbar;
1608 1608
				mon[i].topbar = topbar;
1609 +
				mon[i].tagset[0] = mon[i].tagset[1] = 1;
1609 1610
			}
1610 1611
			mon[i].wx = info[i].x_org;
1611 1612
			mon[i].wy = mon[i].showbar && mon[i].topbar ? info[i].y_org + bh : info[i].y_org;
1649 1650
			mon[0].mfact = mfact;
1650 1651
			mon[0].showbar = showbar;
1651 1652
			mon[0].topbar = topbar;
1653 +
			mon[0].tagset[0] = mon[0].tagset[1] = 1;
1652 1654
		}
1653 1655
		mon[0].wx = sx;
1654 1656
		mon[0].wy = mon[0].showbar && mon[0].topbar ? sy + bh : sy;
1760 1762
1761 1763
void
1762 1764
view(const Arg *arg) {
1763 -
	if((arg->ui & TAGMASK) == tagset[selmon->seltags])
1765 +
	if((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
1764 1766
		return;
1765 1767
	selmon->seltags ^= 1; /* toggle sel tagset */
1766 1768
	if(arg->ui & TAGMASK)
1767 -
		tagset[selmon->seltags] = arg->ui & TAGMASK;
1769 +
		selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
1768 1770
	arrange();
1769 1771
}
1770 1772