small bugfix
authorAnselm R. Garbe <garbeam@gmail.com>
Mon, 13 Aug 2007 20:10:44 +0200
changeset 950 ebf2363d95f9
parent 949 99ee5c370f94
child 951 3a0407d4b95b
small bugfix
tag.c
--- a/tag.c	Mon Aug 13 20:06:00 2007 +0200
+++ b/tag.c	Mon Aug 13 20:10:44 2007 +0200
@@ -27,6 +27,18 @@
 static unsigned int nrules = 0;
 static char prop[512];
 
+static void
+persisttags(Client *c)
+{
+	unsigned int i;
+
+	for(i = 0; i < ntags && i < sizeof prop - 1; i++)
+		prop[i] = c->tags[i] ? '+' : '-';
+	prop[i] = '\0';
+	XChangeProperty(dpy, c->win, dwmtags, XA_STRING, 8,
+			PropModeReplace, (unsigned char *)prop, i);
+}
+
 /* extern */
 
 void
@@ -77,7 +89,6 @@
 	if(matched) {
 		for(i = 0; i < ntags; i++)
 			c->tags[i] = trans->tags[i];
-		return;
 	}
 	else {
 		/* check if window has set a property */
@@ -91,8 +102,8 @@
 				if((c->tags[i] = prop[i] == '+'))
 					matched = True;
 		}
-		if(matched)
-			return;
+	}
+	if(!matched) {
 		/* rule matching */
 		XGetClassHint(dpy, c->win, &ch);
 		snprintf(prop, sizeof prop, "%s:%s:%s",
@@ -116,6 +127,7 @@
 	if(!matched)
 		for(i = 0; i < ntags; i++)
 			c->tags[i] = seltag[i];
+	persisttags(c);
 }
 
 void
@@ -129,12 +141,8 @@
 	i = arg ? atoi(arg) : 0;
 	if(i >= 0 && i < ntags)
 		sel->tags[i] = True;
-	if(sel) {
-		for(i = 0; i < ntags && i < sizeof prop - 1; i++)
-			prop[i] = sel->tags[i] ? '+' : '-';
-		prop[i] = '\0';
-		XChangeProperty(dpy, sel->win, dwmtags, XA_STRING, 8, PropModeReplace, (unsigned char *)prop, i);
-	}
+	if(sel)
+		persisttags(sel);
 	arrange();
 }
 
@@ -149,6 +157,8 @@
 	for(j = 0; j < ntags && !sel->tags[j]; j++);
 	if(j == ntags)
 		sel->tags[i] = True;
+	if(sel)
+		persisttags(sel);
 	arrange();
 }