removed initags -- we autoselect the first tag in each view instead f1719ac2
anselm@anselm1 · 2008-02-28 20:02 2 file(s) · +31 −25
config.def.h +0 −1
14 14
/* old */
15 15
const char tags[][MAXTAGLEN]     = { "1", "2", "3", "4", "nil", "6", "7", "8", "www" };
16 16
unsigned int vtags[LENGTH(tags)] = {  0 ,  0 ,  0 ,  0 ,   0  ,  1 ,  1 ,  1 ,   1   };
17 -
Bool initags[LENGTH(tags)]       = { [0] = True, [5] = True };
18 17
19 18
Rule rules[] = {
20 19
	/* class:instance:title substr	tags ref	isfloating */
dwm.c +31 −24
227 227
	[UnmapNotify] = unmapnotify
228 228
};
229 229
Atom wmatom[WMLast], netatom[NetLast];
230 -
Bool isxinerama = False;
231 230
Bool domwfact = True;
232 231
Bool dozoom = True;
233 232
Bool otherwm, readin;
246 245
247 246
/* configuration, allows nested code to access above variables */
248 247
#include "config.h"
248 +
#define TAGSZ (LENGTH(tags) * sizeof(Bool))
249 249
250 250
/* function implementations */
251 251
void
286 286
	if(ch.res_name)
287 287
		XFree(ch.res_name);
288 288
	if(!matched) {
289 -
		memcpy(c->tags, seltags, sizeof initags);
289 +
		memcpy(c->tags, seltags, TAGSZ);
290 290
		c->view = selview;
291 291
	}
292 292
}
654 654
	Client *c;
655 655
	XCrossingEvent *ev = &e->xcrossing;
656 656
657 -
	if(ev->mode != NotifyNormal || ev->detail == NotifyInferior) {
658 -
		if(!isxinerama || ev->window != root)
659 -
			return;
660 -
	}
657 +
	if((ev->mode != NotifyNormal || ev->detail == NotifyInferior) && ev->window != root)
658 +
		return;
661 659
	if((c = getclient(ev->window)))
662 660
		focus(c);
663 661
	else
1042 1040
	XWindowChanges wc;
1043 1041
1044 1042
	c = emallocz(sizeof(Client));
1045 -
	c->tags = emallocz(sizeof initags);
1043 +
	c->tags = emallocz(TAGSZ);
1046 1044
	c->win = w;
1047 1045
1048 1046
	applyrules(c);
1082 1080
	if((rettrans = XGetTransientForHint(dpy, w, &trans) == Success))
1083 1081
		for(t = clients; t && t->win != trans; t = t->next);
1084 1082
	if(t)
1085 -
		memcpy(c->tags, t->tags, sizeof initags);
1083 +
		memcpy(c->tags, t->tags, TAGSZ);
1086 1084
	if(!c->isfloating)
1087 1085
		c->isfloating = (rettrans == Success) || c->isfixed;
1088 1086
	attach(c);
1501 1499
1502 1500
void
1503 1501
setup(void) {
1504 -
	unsigned int i;
1502 +
	unsigned int i, j;
1505 1503
	View *v;
1506 1504
	XSetWindowAttributes wa;
1507 1505
	XineramaScreenInfo *info = NULL;
1519 1517
	cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
1520 1518
	cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur);
1521 1519
1522 -
	if((isxinerama = XineramaIsActive(dpy)))
1520 +
	if(XineramaIsActive(dpy))
1523 1521
		info = XineramaQueryScreens(dpy, &nviews);
1522 +
1524 1523
#if defined(AIM_XINERAMA)
1525 -
isxinerama = True;
1526 1524
nviews = 2; /* aim Xinerama */
1527 1525
#endif
1528 1526
	views = emallocz(nviews * sizeof(View));
1551 1549
			blw = i;
1552 1550
	}
1553 1551
1554 -
	seltags = emallocz(sizeof initags);
1555 -
	prevtags = emallocz(sizeof initags);
1556 -
	memcpy(seltags, initags, sizeof initags);
1557 -
	memcpy(prevtags, initags, sizeof initags);
1552 +
	seltags = emallocz(TAGSZ);
1553 +
	prevtags = emallocz(TAGSZ);
1554 +
1555 +
	/* check, if vtags need assistance, because there is only 1 view */
1556 +
	if(nviews == 1)
1557 +
		for(i = 0; i < LENGTH(tags); i++)
1558 +
			vtags[i] = 0;
1558 1559
1559 1560
	for(i = 0; i < nviews; i++) {
1560 1561
		/* init geometry */
1561 1562
		v = &views[i];
1562 1563
1563 -
		if(nviews != 1 && isxinerama) {
1564 +
		/* select first tag in each view */
1565 +
		for(j = 0; j < LENGTH(tags); j++)
1566 +
			if(vtags[j] == i) {
1567 +
				seltags[j] = prevtags[j] = True; 
1568 +
				break;
1569 +
			}
1570 +
1571 +
1572 +
		if(info) {
1564 1573
1565 1574
#if defined(AIM_XINERAMA)
1566 1575
v->w = DisplayWidth(dpy, screen) / 2;
1693 1702
1694 1703
	for(i = 0, c = mc = nexttiled(clients, v); c; c = nexttiled(c->next, v)) {
1695 1704
		if(i == 0) { /* master */
1696 -
			nx = v->wax;
1697 -
			ny = v->way;
1698 1705
			nw = mw - 2 * c->border;
1699 1706
			nh = v->wah - 2 * c->border;
1700 1707
		}
1908 1915
		tmp[i] = (NULL == arg);
1909 1916
	tmp[idxoftag(arg)] = True;
1910 1917
1911 -
	if(memcmp(seltags, tmp, sizeof initags) != 0) {
1912 -
		memcpy(prevtags, seltags, sizeof initags);
1913 -
		memcpy(seltags, tmp, sizeof initags);
1918 +
	if(memcmp(seltags, tmp, TAGSZ) != 0) {
1919 +
		memcpy(prevtags, seltags, TAGSZ);
1920 +
		memcpy(seltags, tmp, TAGSZ);
1914 1921
		arrange();
1915 1922
	}
1916 1923
}
1934 1941
viewprevtag(const char *arg) {
1935 1942
	static Bool tmp[LENGTH(tags)];
1936 1943
1937 -
	memcpy(tmp, seltags, sizeof initags);
1938 -
	memcpy(seltags, prevtags, sizeof initags);
1939 -
	memcpy(prevtags, tmp, sizeof initags);
1944 +
	memcpy(tmp, seltags, TAGSZ);
1945 +
	memcpy(seltags, prevtags, TAGSZ);
1946 +
	memcpy(prevtags, tmp, TAGSZ);
1940 1947
	arrange();
1941 1948
}
1942 1949