dwm.c
changeset 1460 606761ddf6d6
parent 1459 a5eecc6d674f
child 1462 7997ebe5484f
equal deleted inserted replaced
1459:a5eecc6d674f 1460:606761ddf6d6
   235 static int xerrordummy(Display *dpy, XErrorEvent *ee);
   235 static int xerrordummy(Display *dpy, XErrorEvent *ee);
   236 static int xerrorstart(Display *dpy, XErrorEvent *ee);
   236 static int xerrorstart(Display *dpy, XErrorEvent *ee);
   237 static void zoom(const Arg *arg);
   237 static void zoom(const Arg *arg);
   238 
   238 
   239 /* variables */
   239 /* variables */
       
   240 static const char broken[] = "broken";
   240 static char stext[256], ntext[8];
   241 static char stext[256], ntext[8];
   241 static int screen;
   242 static int screen;
   242 static int sw, sh;           /* X display screen geometry width, height */
   243 static int sw, sh;           /* X display screen geometry width, height */
   243 static int bh, blw = 0;      /* bar geometry */
   244 static int bh, blw = 0;      /* bar geometry */
   244 static int (*xerrorxlib)(Display *, XErrorEvent *);
   245 static int (*xerrorxlib)(Display *, XErrorEvent *);
   273 struct NumTags { char limitexceeded[sizeof(unsigned int) * 8 < LENGTH(tags) ? -1 : 1]; };
   274 struct NumTags { char limitexceeded[sizeof(unsigned int) * 8 < LENGTH(tags) ? -1 : 1]; };
   274 
   275 
   275 /* function implementations */
   276 /* function implementations */
   276 void
   277 void
   277 applyrules(Client *c) {
   278 applyrules(Client *c) {
       
   279 	const char *class, *instance;
   278 	unsigned int i;
   280 	unsigned int i;
   279 	const Rule *r;
   281 	const Rule *r;
   280 	Monitor *m;
   282 	Monitor *m;
   281 	XClassHint ch = { 0 };
   283 	XClassHint ch = { 0 };
   282 
   284 
   283 	/* rule matching */
   285 	/* rule matching */
   284 	c->isfloating = c->tags = 0;
   286 	c->isfloating = c->tags = 0;
   285 	if(XGetClassHint(dpy, c->win, &ch)) {
   287 	if(XGetClassHint(dpy, c->win, &ch)) {
       
   288 		class = ch.res_class ? ch.res_class : broken;
       
   289 		instance = ch.res_name ? ch.res_name : broken;
   286 		for(i = 0; i < LENGTH(rules); i++) {
   290 		for(i = 0; i < LENGTH(rules); i++) {
   287 			r = &rules[i];
   291 			r = &rules[i];
   288 			if((!r->title || strstr(c->name, r->title))
   292 			if((!r->title || strstr(c->name, r->title))
   289 			&& (!r->class || (ch.res_class && strstr(ch.res_class, r->class)))
   293 			&& (!r->class || strstr(class, r->class))
   290 			&& (!r->instance || (ch.res_name && strstr(ch.res_name, r->instance))))
   294 			&& (!r->instance || strstr(instance, r->instance)))
   291 			{
   295 			{
   292 				c->isfloating = r->isfloating;
   296 				c->isfloating = r->isfloating;
   293 				c->tags |= r->tags;
   297 				c->tags |= r->tags;
   294 				for(m = mons; m && m->num != r->monitor; m = m->next);
   298 				for(m = mons; m && m->num != r->monitor; m = m->next);
   295 				if(m)
   299 				if(m)
  1817 
  1821 
  1818 void
  1822 void
  1819 updatetitle(Client *c) {
  1823 updatetitle(Client *c) {
  1820 	if(!gettextprop(c->win, netatom[NetWMName], c->name, sizeof c->name))
  1824 	if(!gettextprop(c->win, netatom[NetWMName], c->name, sizeof c->name))
  1821 		gettextprop(c->win, XA_WM_NAME, c->name, sizeof c->name);
  1825 		gettextprop(c->win, XA_WM_NAME, c->name, sizeof c->name);
       
  1826 	if(c->name[0] == '\0') /* hack to mark broken clients */
       
  1827 		strcpy(c->name, broken);
  1822 }
  1828 }
  1823 
  1829 
  1824 void
  1830 void
  1825 updatestatus(void) {
  1831 updatestatus(void) {
  1826 	if(!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
  1832 	if(!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))