X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=tag.c;h=4b6d513c06c6544c397dd5923cb69bd4deb4dcb3;hb=727449d1e7840bae1700d722168a73def9738ccd;hp=b5bebea241478dfee1cb17216e10678a8a3e0486;hpb=fe3dfbbe90f813294bb69e41f996a000f63c1560;p=dwm.git diff --git a/tag.c b/tag.c index b5bebea..4b6d513 100644 --- a/tag.c +++ b/tag.c @@ -34,20 +34,6 @@ void (*arrange)(Arg *) = DEFMODE; /* extern */ -void -appendtag(Arg *arg) -{ - Client *c = sel; - - if(!c) - return; - - c->tags[arg->i] = True; - arrange(NULL); - focus(c); - restack(); -} - void dofloat(Arg *arg) { @@ -61,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(); } @@ -125,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); @@ -186,19 +176,6 @@ isvisible(Client *c) return False; } -void -replacetag(Arg *arg) -{ - int i; - - if(!sel) - return; - - for(i = 0; i < ntags; i++) - sel->tags[i] = False; - appendtag(arg); -} - void restack() { @@ -284,6 +261,22 @@ settags(Client *c) c->tags[i] = seltag[i]; } +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) { @@ -292,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); +}