X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=tag.c;h=4b6d513c06c6544c397dd5923cb69bd4deb4dcb3;hb=442334641e4124d8c32387287d431a83761ff916;hp=edf68c6d0c327154fdf56611eafc874a53452dea;hpb=aff4c787f484974fc01070842357548d7be395ce;p=dwm.git diff --git a/tag.c b/tag.c index edf68c6..4b6d513 100644 --- a/tag.c +++ b/tag.c @@ -35,16 +35,6 @@ void (*arrange)(Arg *) = DEFMODE; /* extern */ void -appendtag(Arg *arg) -{ - if(!sel) - return; - - sel->tags[arg->i] = True; - settitle(sel); -} - -void dofloat(Arg *arg) { Client *c; @@ -57,7 +47,9 @@ dofloat(Arg *arg) else ban(c); } - if((sel = getnext(clients))) { + if(!sel || !isvisible(sel)) + sel = getnext(clients); + if(sel) { focus(sel); restack(); } @@ -121,7 +113,9 @@ dotile(Arg *arg) else ban(c); } - if((sel = getnext(clients))) + if(!sel || !isvisible(sel)) + sel = getnext(clients); + if(sel) focus(sel); else XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); @@ -183,19 +177,6 @@ isvisible(Client *c) } void -replacetag(Arg *arg) -{ - int i; - - if(!sel) - return; - - for(i = 0; i < ntags; i++) - sel->tags[i] = False; - appendtag(arg); -} - -void restack() { static unsigned int nwins = 0; @@ -281,6 +262,22 @@ settags(Client *c) } void +tag(Arg *arg) +{ + unsigned int i; + + if(!sel) + return; + + for(i = 0; i < ntags; i++) + sel->tags[i] = False; + sel->tags[arg->i] = True; + settitle(sel); + if(!isvisible(sel)) + arrange(NULL); +} + +void togglemode(Arg *arg) { arrange = arrange == dofloat ? dotile : dofloat; @@ -288,24 +285,42 @@ togglemode(Arg *arg) } void -view(Arg *arg) +toggletag(Arg *arg) { unsigned int i; - for(i = 0; i < ntags; i++) - seltag[i] = False; - seltag[arg->i] = True; - arrange(NULL); + if(!sel) + return; + + sel->tags[arg->i] = !sel->tags[arg->i]; + for(i = 0; i < ntags && !sel->tags[i]; i++); + if(i == ntags) + sel->tags[arg->i] = True; + settitle(sel); + if(!isvisible(sel)) + arrange(NULL); } + void toggleview(Arg *arg) { unsigned int i; seltag[arg->i] = !seltag[arg->i]; - for(i = 0; !seltag[i] && i < ntags; i++); + for(i = 0; i < ntags && !seltag[i]; i++); if(i == ntags) seltag[arg->i] = True; /* cannot toggle last view */ arrange(NULL); } + +void +view(Arg *arg) +{ + unsigned int i; + + for(i = 0; i < ntags; i++) + seltag[i] = False; + seltag[arg->i] = True; + arrange(NULL); +}