small bugfix b32cd445
Anselm R. Garbe · 2007-08-13 20:10 1 file(s) · +19 −9
tag.c +19 −9
27 27
static unsigned int nrules = 0;
28 28
static char prop[512];
29 29
30 +
static void
31 +
persisttags(Client *c)
32 +
{
33 +
	unsigned int i;
34 +
35 +
	for(i = 0; i < ntags && i < sizeof prop - 1; i++)
36 +
		prop[i] = c->tags[i] ? '+' : '-';
37 +
	prop[i] = '\0';
38 +
	XChangeProperty(dpy, c->win, dwmtags, XA_STRING, 8,
39 +
			PropModeReplace, (unsigned char *)prop, i);
40 +
}
41 +
30 42
/* extern */
31 43
32 44
void
77 89
	if(matched) {
78 90
		for(i = 0; i < ntags; i++)
79 91
			c->tags[i] = trans->tags[i];
80 -
		return;
81 92
	}
82 93
	else {
83 94
		/* check if window has set a property */
91 102
				if((c->tags[i] = prop[i] == '+'))
92 103
					matched = True;
93 104
		}
94 -
		if(matched)
95 -
			return;
105 +
	}
106 +
	if(!matched) {
96 107
		/* rule matching */
97 108
		XGetClassHint(dpy, c->win, &ch);
98 109
		snprintf(prop, sizeof prop, "%s:%s:%s",
116 127
	if(!matched)
117 128
		for(i = 0; i < ntags; i++)
118 129
			c->tags[i] = seltag[i];
130 +
	persisttags(c);
119 131
}
120 132
121 133
void
129 141
	i = arg ? atoi(arg) : 0;
130 142
	if(i >= 0 && i < ntags)
131 143
		sel->tags[i] = True;
132 -
	if(sel) {
133 -
		for(i = 0; i < ntags && i < sizeof prop - 1; i++)
134 -
			prop[i] = sel->tags[i] ? '+' : '-';
135 -
		prop[i] = '\0';
136 -
		XChangeProperty(dpy, sel->win, dwmtags, XA_STRING, 8, PropModeReplace, (unsigned char *)prop, i);
137 -
	}
144 +
	if(sel)
145 +
		persisttags(sel);
138 146
	arrange();
139 147
}
140 148
149 157
	for(j = 0; j < ntags && !sel->tags[j]; j++);
150 158
	if(j == ntags)
151 159
		sel->tags[i] = True;
160 +
	if(sel)
161 +
		persisttags(sel);
152 162
	arrange();
153 163
}
154 164