X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=dwm.c;h=37e833e3cafa9a1bf59e588061c83825c1c8e8d1;hb=0c71b16b9282562ee59f73f215c6ba827df25927;hp=54d021f460bf01319b5f8a8bfbd4ca1c2c8f9bb2;hpb=a6a216f28cbc49afaace269c2662382a351fda24;p=dwm.git diff --git a/dwm.c b/dwm.c index 54d021f..37e833e 100644 --- a/dwm.c +++ b/dwm.c @@ -178,6 +178,7 @@ void scan(void); void setclientstate(Client *c, long state); void setgeom(const char *arg); void setlayout(const char *arg); +void setmfact(const char *arg); void setup(void); void spawn(const char *arg); void tag(const char *arg); @@ -322,10 +323,14 @@ buttonpress(XEvent *e) { XButtonPressedEvent *ev = &e->xbutton; if(ev->window == barwin) { + if((ev->x < bgw) && ev->button == Button1) { + setgeom(NULL); + return; + } x = bgw; for(i = 0; i < LENGTH(tags); i++) { x += textw(tags[i]); - if(ev->x > bgw && ev->x < x) { + if(ev->x >= bgw && ev->x < x) { if(ev->button == Button1) { if(ev->state & MODKEY) tag(tags[i]); @@ -341,6 +346,8 @@ buttonpress(XEvent *e) { return; } } + if((ev->x < x + blw) && ev->button == Button1) + setlayout(NULL); } else if((c = getclient(ev->window))) { focus(c); @@ -426,7 +433,7 @@ configurenotify(XEvent *e) { if(ev->window == root && (ev->width != sw || ev->height != sh)) { sw = ev->width; sh = ev->height; - setgeom(NULL); + setgeom(geom->symbol); } } @@ -1417,12 +1424,18 @@ void setgeom(const char *arg) { unsigned int i; - for(i = 0; arg && i < LENGTH(geoms); i++) - if(!strcmp(geoms[i].symbol, arg)) - break; - if(i == LENGTH(geoms)) - return; - geom = &geoms[i]; + if(!arg) { + if(++geom == &geoms[LENGTH(geoms)]) + geom = &geoms[0]; + } + else { + for(i = 0; i < LENGTH(geoms); i++) + if(!strcmp(geoms[i].symbol, arg)) + break; + if(i == LENGTH(geoms)) + return; + geom = &geoms[i]; + } geom->apply(); updatebarpos(); arrange(); @@ -1430,20 +1443,18 @@ setgeom(const char *arg) { void setlayout(const char *arg) { - static Layout *revert = 0; unsigned int i; - if(!arg) - return; - for(i = 0; i < LENGTH(layouts); i++) - if(!strcmp(arg, layouts[i].symbol)) - break; - if(i == LENGTH(layouts)) - return; - if(revert && &layouts[i] == lt) - lt = revert; + if(!arg) { + if(++lt == &layouts[LENGTH(layouts)]) + lt = &layouts[0]; + } else { - revert = lt; + for(i = 0; i < LENGTH(layouts); i++) + if(!strcmp(arg, layouts[i].symbol)) + break; + if(i == LENGTH(layouts)) + return; lt = &layouts[i]; } if(sel) @@ -1453,6 +1464,26 @@ setlayout(const char *arg) { } void +setmfact(const char *arg) { + double delta; + + if(!arg || lt->isfloating) + return; + delta = strtod(arg, NULL); + if(arg[0] == '-' || arg[0] == '+') { + if(mfact + delta < 0.1 || mfact + delta > 0.9) + return; + mfact += delta; + } + else { + if(delta < 0.1 || delta > 0.9) + return; + mfact = delta; + } + setgeom(geom->symbol); +} + +void setup(void) { unsigned int i, w; XSetWindowAttributes wa;