removed initags -- we autoselect the first tag in each view instead
authoranselm@anselm1
Thu, 28 Feb 2008 20:02:57 +0000
changeset 1109 55e2f7e96b71
parent 1108 aab1c3addbaf
child 1110 227f2d07c63f
removed initags -- we autoselect the first tag in each view instead
config.def.h
dwm.c
--- a/config.def.h	Thu Feb 28 17:13:13 2008 +0000
+++ b/config.def.h	Thu Feb 28 20:02:57 2008 +0000
@@ -14,7 +14,6 @@
 /* old */
 const char tags[][MAXTAGLEN]     = { "1", "2", "3", "4", "nil", "6", "7", "8", "www" };
 unsigned int vtags[LENGTH(tags)] = {  0 ,  0 ,  0 ,  0 ,   0  ,  1 ,  1 ,  1 ,   1   };
-Bool initags[LENGTH(tags)]       = { [0] = True, [5] = True };
 
 Rule rules[] = {
 	/* class:instance:title substr	tags ref	isfloating */
--- a/dwm.c	Thu Feb 28 17:13:13 2008 +0000
+++ b/dwm.c	Thu Feb 28 20:02:57 2008 +0000
@@ -227,7 +227,6 @@
 	[UnmapNotify] = unmapnotify
 };
 Atom wmatom[WMLast], netatom[NetLast];
-Bool isxinerama = False;
 Bool domwfact = True;
 Bool dozoom = True;
 Bool otherwm, readin;
@@ -246,6 +245,7 @@
 
 /* configuration, allows nested code to access above variables */
 #include "config.h"
+#define TAGSZ (LENGTH(tags) * sizeof(Bool))
 
 /* function implementations */
 void
@@ -286,7 +286,7 @@
 	if(ch.res_name)
 		XFree(ch.res_name);
 	if(!matched) {
-		memcpy(c->tags, seltags, sizeof initags);
+		memcpy(c->tags, seltags, TAGSZ);
 		c->view = selview;
 	}
 }
@@ -654,10 +654,8 @@
 	Client *c;
 	XCrossingEvent *ev = &e->xcrossing;
 
-	if(ev->mode != NotifyNormal || ev->detail == NotifyInferior) {
-		if(!isxinerama || ev->window != root)
-			return;
-	}
+	if((ev->mode != NotifyNormal || ev->detail == NotifyInferior) && ev->window != root)
+		return;
 	if((c = getclient(ev->window)))
 		focus(c);
 	else
@@ -1042,7 +1040,7 @@
 	XWindowChanges wc;
 
 	c = emallocz(sizeof(Client));
-	c->tags = emallocz(sizeof initags);
+	c->tags = emallocz(TAGSZ);
 	c->win = w;
 
 	applyrules(c);
@@ -1082,7 +1080,7 @@
 	if((rettrans = XGetTransientForHint(dpy, w, &trans) == Success))
 		for(t = clients; t && t->win != trans; t = t->next);
 	if(t)
-		memcpy(c->tags, t->tags, sizeof initags);
+		memcpy(c->tags, t->tags, TAGSZ);
 	if(!c->isfloating)
 		c->isfloating = (rettrans == Success) || c->isfixed;
 	attach(c);
@@ -1501,7 +1499,7 @@
 
 void
 setup(void) {
-	unsigned int i;
+	unsigned int i, j;
 	View *v;
 	XSetWindowAttributes wa;
 	XineramaScreenInfo *info = NULL;
@@ -1519,10 +1517,10 @@
 	cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
 	cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur);
 
-	if((isxinerama = XineramaIsActive(dpy)))
+	if(XineramaIsActive(dpy))
 		info = XineramaQueryScreens(dpy, &nviews);
+
 #if defined(AIM_XINERAMA)
-isxinerama = True;
 nviews = 2; /* aim Xinerama */
 #endif
 	views = emallocz(nviews * sizeof(View));
@@ -1551,16 +1549,27 @@
 			blw = i;
 	}
 
-	seltags = emallocz(sizeof initags);
-	prevtags = emallocz(sizeof initags);
-	memcpy(seltags, initags, sizeof initags);
-	memcpy(prevtags, initags, sizeof initags);
+	seltags = emallocz(TAGSZ);
+	prevtags = emallocz(TAGSZ);
+
+	/* check, if vtags need assistance, because there is only 1 view */
+	if(nviews == 1)
+		for(i = 0; i < LENGTH(tags); i++)
+			vtags[i] = 0;
 
 	for(i = 0; i < nviews; i++) {
 		/* init geometry */
 		v = &views[i];
 
-		if(nviews != 1 && isxinerama) {
+		/* select first tag in each view */
+		for(j = 0; j < LENGTH(tags); j++)
+			if(vtags[j] == i) {
+				seltags[j] = prevtags[j] = True; 
+				break;
+			}
+
+
+		if(info) {
 
 #if defined(AIM_XINERAMA)
 v->w = DisplayWidth(dpy, screen) / 2;
@@ -1693,8 +1702,6 @@
 
 	for(i = 0, c = mc = nexttiled(clients, v); c; c = nexttiled(c->next, v)) {
 		if(i == 0) { /* master */
-			nx = v->wax;
-			ny = v->way;
 			nw = mw - 2 * c->border;
 			nh = v->wah - 2 * c->border;
 		}
@@ -1908,9 +1915,9 @@
 		tmp[i] = (NULL == arg);
 	tmp[idxoftag(arg)] = True;
 
-	if(memcmp(seltags, tmp, sizeof initags) != 0) {
-		memcpy(prevtags, seltags, sizeof initags);
-		memcpy(seltags, tmp, sizeof initags);
+	if(memcmp(seltags, tmp, TAGSZ) != 0) {
+		memcpy(prevtags, seltags, TAGSZ);
+		memcpy(seltags, tmp, TAGSZ);
 		arrange();
 	}
 }
@@ -1934,9 +1941,9 @@
 viewprevtag(const char *arg) {
 	static Bool tmp[LENGTH(tags)];
 
-	memcpy(tmp, seltags, sizeof initags);
-	memcpy(seltags, prevtags, sizeof initags);
-	memcpy(prevtags, tmp, sizeof initags);
+	memcpy(tmp, seltags, TAGSZ);
+	memcpy(seltags, prevtags, TAGSZ);
+	memcpy(prevtags, tmp, TAGSZ);
 	arrange();
 }