X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=screen.c;h=255184a686c44aa68027813ff4f035c06676e24c;hb=9f88fd093cf4f18dfd25b86344e5df73f5f1c2a1;hp=a8b093ce88b1a42b04282f6b5f64972318d6e1ff;hpb=fc109ea8f72e662ed58ef45329b6ca9e91d61d3b;p=dwm.git diff --git a/screen.c b/screen.c index a8b093c..255184a 100644 --- a/screen.c +++ b/screen.c @@ -4,7 +4,6 @@ #include #include #include -#include #include /* static */ @@ -28,7 +27,6 @@ typedef struct { TAGS RULES -static char prop[512]; static unsigned int nrules = 0; static unsigned int nlayouts = 0; static unsigned int ltidx = 0; /* default */ @@ -53,19 +51,6 @@ floating(void) { /* default floating layout */ resize(c, c->x, c->y, c->w, c->h, True); } -static void -setdwmprops(void) { - unsigned int i; - - for(i = 0; i < ntags && i < sizeof prop - 1; i++) - prop[i] = seltags[i] ? '1' : '0'; - if(i < sizeof prop - 1) - prop[i++] = (char)ltidx + '0'; - prop[i] = '\0'; - XChangeProperty(dpy, root, dwmprops, XA_STRING, 8, - PropModeReplace, (unsigned char *)prop, i); -} - LAYOUTS /* extern */ @@ -74,6 +59,7 @@ unsigned int blw = 0; void applyrules(Client *c) { + static char buf[512]; unsigned int i, j; regmatch_t tmp; Bool matched = False; @@ -81,11 +67,11 @@ applyrules(Client *c) { /* rule matching */ XGetClassHint(dpy, c->win, &ch); - snprintf(prop, sizeof prop, "%s:%s:%s", + snprintf(buf, sizeof buf, "%s:%s:%s", ch.res_class ? ch.res_class : "", ch.res_name ? ch.res_name : "", c->name); for(i = 0; i < nrules; i++) - if(regs[i].propregex && !regexec(regs[i].propregex, prop, 1, &tmp, 0)) { + if(regs[i].propregex && !regexec(regs[i].propregex, buf, 1, &tmp, 0)) { c->isfloating = rules[i].isfloating; for(j = 0; regs[i].tagregex && j < ntags; j++) { if(!regexec(regs[i].tagregex, tags[j], 1, &tmp, 0)) { @@ -215,20 +201,6 @@ isvisible(Client *c) { return False; } -void -getdwmprops(void) { - unsigned int i; - - if(gettextprop(root, dwmprops, prop, sizeof prop)) { - for(i = 0; i < ntags && i < sizeof prop - 1 && prop[i] != '\0'; i++) - seltags[i] = prop[i] == '1'; - if(i < sizeof prop - 1 && prop[i] != '\0') { - if((unsigned int)(prop[i] - '0') < nlayouts) - ltidx = prop[i] - '0'; - } - } -} - Client * nexttiled(Client *c) { for(; c && (c->isfloating || !isvisible(c)); c = c->next); @@ -266,15 +238,17 @@ restack(void) { void setlayout(const char *arg) { - int i; + unsigned int i; if(!arg) { if(++ltidx == nlayouts) ltidx = 0;; } else { - i = atoi(arg); - if(i < 0 || i >= nlayouts) + for(i = 0; i < nlayouts; i++) + if(!strcmp(arg, layouts[i].symbol)) + break; + if(i == nlayouts) return; ltidx = i; } @@ -282,7 +256,6 @@ setlayout(const char *arg) { arrange(); else drawstatus(); - setdwmprops(); } void @@ -296,7 +269,6 @@ tag(const char *arg) { i = idxoftag(arg); if(i >= 0 && i < ntags) sel->tags[i] = True; - setprops(sel); arrange(); } @@ -312,13 +284,11 @@ togglebar(const char *arg) { void togglefloating(const char *arg) { - if(!sel || isfloating()) + if(!sel) return; sel->isfloating = !sel->isfloating; - if(sel->isfloating) { + if(sel->isfloating) resize(sel, sel->x, sel->y, sel->w, sel->h, True); - setprops(sel); - } arrange(); } @@ -352,7 +322,6 @@ toggletag(const char *arg) { for(j = 0; j < ntags && !sel->tags[j]; j++); if(j == ntags) sel->tags[i] = True; - setprops(sel); arrange(); } @@ -365,7 +334,6 @@ toggleview(const char *arg) { for(j = 0; j < ntags && !seltags[j]; j++); if(j == ntags) seltags[i] = True; /* cannot toggle last view */ - setdwmprops(); arrange(); } @@ -404,6 +372,5 @@ view(const char *arg) { i = idxoftag(arg); if(i >= 0 && i < ntags) seltags[i] = True; - setdwmprops(); arrange(); }