applied Connors cleanup patch of Eckehards proposed fix of applyrules(), thanks everyone involved 0f1f30da
garbeam@gmail.com · 2011-08-15 18:44 1 file(s) · +20 −20
dwm.c +20 −20
289 289
	unsigned int i;
290 290
	const Rule *r;
291 291
	Monitor *m;
292 -
	XClassHint ch = { 0 };
292 +
	XClassHint ch = { NULL, NULL };
293 293
294 294
	/* rule matching */
295 295
	c->isfloating = c->tags = 0;
296 -
	if(XGetClassHint(dpy, c->win, &ch)) {
297 -
		class = ch.res_class ? ch.res_class : broken;
298 -
		instance = ch.res_name ? ch.res_name : broken;
299 -
		for(i = 0; i < LENGTH(rules); i++) {
300 -
			r = &rules[i];
301 -
			if((!r->title || strstr(c->name, r->title))
302 -
			&& (!r->class || strstr(class, r->class))
303 -
			&& (!r->instance || strstr(instance, r->instance)))
304 -
			{
305 -
				c->isfloating = r->isfloating;
306 -
				c->tags |= r->tags;
307 -
				for(m = mons; m && m->num != r->monitor; m = m->next);
308 -
				if(m)
309 -
					c->mon = m;
310 -
			}
296 +
	XGetClassHint(dpy, c->win, &ch);
297 +
	class    = ch.res_class ? ch.res_class : broken;
298 +
	instance = ch.res_name  ? ch.res_name  : broken;
299 +
300 +
	for(i = 0; i < LENGTH(rules); i++) {
301 +
		r = &rules[i];
302 +
		if((!r->title || strstr(c->name, r->title))
303 +
		&& (!r->class || strstr(class, r->class))
304 +
		&& (!r->instance || strstr(instance, r->instance)))
305 +
		{
306 +
			c->isfloating = r->isfloating;
307 +
			c->tags |= r->tags;
308 +
			for(m = mons; m && m->num != r->monitor; m = m->next);
309 +
			if(m)
310 +
				c->mon = m;
311 311
		}
312 -
		if(ch.res_class)
313 -
			XFree(ch.res_class);
314 -
		if(ch.res_name)
315 -
			XFree(ch.res_name);
316 312
	}
313 +
	if(ch.res_class)
314 +
		XFree(ch.res_class);
315 +
	if(ch.res_name)
316 +
		XFree(ch.res_name);
317 317
	c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : c->mon->tagset[c->mon->seltags];
318 318
}
319 319