X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=screen.c;h=f793c5d248e32d3bf2417bb8ca44c3e78c2e4456;hb=9800518ae3505e54c0e52ea3d40050f279e722d6;hp=ec8637f8fe3d98601efdbdf88b91da5f34dd0773;hpb=b18e6840152b300f2db8ff8dca16aee0839f864b;p=dwm.git diff --git a/screen.c b/screen.c index ec8637f..f793c5d 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 buf[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 buf - 1; i++) - buf[i] = seltags[i] ? '1' : '0'; - if(i < sizeof buf - 1) - buf[i++] = (char)ltidx + '0'; - buf[i] = '\0'; - XChangeProperty(dpy, root, dwmprops, XA_STRING, 8, - PropModeReplace, (unsigned char *)buf, 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; @@ -215,20 +201,6 @@ isvisible(Client *c) { return False; } -void -getdwmprops(void) { - unsigned int i; - - if(gettextprop(root, dwmprops, buf, sizeof buf)) { - for(i = 0; i < ntags && i < sizeof buf - 1 && buf[i] != '\0'; i++) - seltags[i] = buf[i] == '1'; - if(i < sizeof buf - 1 && buf[i] != '\0') { - if((unsigned int)(buf[i] - '0') < nlayouts) - ltidx = buf[i] - '0'; - } - } -} - Client * nexttiled(Client *c) { for(; c && (c->isfloating || !isvisible(c)); c = c->next); @@ -241,7 +213,7 @@ restack(void) { XEvent ev; XWindowChanges wc; - drawstatus(); + drawbar(); if(!sel) return; if(sel->isfloating || isfloating()) @@ -266,23 +238,24 @@ 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; } if(sel) arrange(); else - drawstatus(); - setdwmprops(); + drawbar(); } 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(); } @@ -337,7 +307,7 @@ togglemax(const char *arg) { } else resize(sel, sel->rx, sel->ry, sel->rw, sel->rh, True); - drawstatus(); + drawbar(); while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); } @@ -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(); }