screen.c
changeset 970 d5c3537ee3be
parent 969 50fb50842dbc
child 971 b2a0dfa22b1d
equal deleted inserted replaced
969:50fb50842dbc 970:d5c3537ee3be
    26 } Regs;
    26 } Regs;
    27 
    27 
    28 TAGS
    28 TAGS
    29 RULES
    29 RULES
    30 
    30 
    31 static char prop[512];
    31 static char buf[512];
    32 static unsigned int nrules = 0;
    32 static unsigned int nrules = 0;
    33 static unsigned int nlayouts = 0;
    33 static unsigned int nlayouts = 0;
    34 static unsigned int ltidx = 0; /* default */
    34 static unsigned int ltidx = 0; /* default */
    35 static Regs *regs = NULL;
    35 static Regs *regs = NULL;
    36 
    36 
    55 
    55 
    56 static void
    56 static void
    57 setdwmprops(void) {
    57 setdwmprops(void) {
    58 	unsigned int i;
    58 	unsigned int i;
    59 
    59 
    60 	for(i = 0; i < ntags && i < sizeof prop - 1; i++)
    60 	for(i = 0; i < ntags && i < sizeof buf - 1; i++)
    61 		prop[i] = seltags[i] ? '1' : '0';
    61 		buf[i] = seltags[i] ? '1' : '0';
    62 	if(i < sizeof prop - 1)
    62 	if(i < sizeof buf - 1)
    63 		prop[i++] = (char)ltidx + '0';
    63 		buf[i++] = (char)ltidx + '0';
    64 	prop[i] = '\0';
    64 	buf[i] = '\0';
    65 	XChangeProperty(dpy, root, dwmprops, XA_STRING, 8,
    65 	XChangeProperty(dpy, root, dwmprops, XA_STRING, 8,
    66 			PropModeReplace, (unsigned char *)prop, i);
    66 			PropModeReplace, (unsigned char *)buf, i);
    67 }
    67 }
    68 
    68 
    69 LAYOUTS
    69 LAYOUTS
    70 
    70 
    71 /* extern */
    71 /* extern */
    79 	Bool matched = False;
    79 	Bool matched = False;
    80 	XClassHint ch = { 0 };
    80 	XClassHint ch = { 0 };
    81 
    81 
    82 	/* rule matching */
    82 	/* rule matching */
    83 	XGetClassHint(dpy, c->win, &ch);
    83 	XGetClassHint(dpy, c->win, &ch);
    84 	snprintf(prop, sizeof prop, "%s:%s:%s",
    84 	snprintf(buf, sizeof buf, "%s:%s:%s",
    85 			ch.res_class ? ch.res_class : "",
    85 			ch.res_class ? ch.res_class : "",
    86 			ch.res_name ? ch.res_name : "", c->name);
    86 			ch.res_name ? ch.res_name : "", c->name);
    87 	for(i = 0; i < nrules; i++)
    87 	for(i = 0; i < nrules; i++)
    88 		if(regs[i].propregex && !regexec(regs[i].propregex, prop, 1, &tmp, 0)) {
    88 		if(regs[i].propregex && !regexec(regs[i].propregex, buf, 1, &tmp, 0)) {
    89 			c->isfloating = rules[i].isfloating;
    89 			c->isfloating = rules[i].isfloating;
    90 			for(j = 0; regs[i].tagregex && j < ntags; j++) {
    90 			for(j = 0; regs[i].tagregex && j < ntags; j++) {
    91 				if(!regexec(regs[i].tagregex, tags[j], 1, &tmp, 0)) {
    91 				if(!regexec(regs[i].tagregex, tags[j], 1, &tmp, 0)) {
    92 					matched = True;
    92 					matched = True;
    93 					c->tags[j] = True;
    93 					c->tags[j] = True;
   217 
   217 
   218 void
   218 void
   219 getdwmprops(void) {
   219 getdwmprops(void) {
   220 	unsigned int i;
   220 	unsigned int i;
   221 
   221 
   222 	if(gettextprop(root, dwmprops, prop, sizeof prop)) {
   222 	if(gettextprop(root, dwmprops, buf, sizeof buf)) {
   223 		for(i = 0; i < ntags && i < sizeof prop - 1 && prop[i] != '\0'; i++)
   223 		for(i = 0; i < ntags && i < sizeof buf - 1 && buf[i] != '\0'; i++)
   224 			seltags[i] = prop[i] == '1';
   224 			seltags[i] = buf[i] == '1';
   225 		if(i < sizeof prop - 1 && prop[i] != '\0') {
   225 		if(i < sizeof buf - 1 && buf[i] != '\0') {
   226 			if((unsigned int)(prop[i] - '0') < nlayouts)
   226 			if((unsigned int)(buf[i] - '0') < nlayouts)
   227 				ltidx = prop[i] - '0';
   227 				ltidx = buf[i] - '0';
   228 		}
   228 		}
   229 	}
   229 	}
   230 }
   230 }
   231 
   231 
   232 Client *
   232 Client *