X-Git-Url: https://git.xinqibao.xyz/dwm.git/blobdiff_plain/d4b7a9a3735deeab639f28b5bb2f568e0dc49616..78b050c13c8ea660ed801c21bddd2957a2bc3f40:/tag.c diff --git a/tag.c b/tag.c index 01979d5..a718ebd 100644 --- a/tag.c +++ b/tag.c @@ -34,16 +34,6 @@ void (*arrange)(Arg *) = DEFMODE; /* extern */ -void -appendtag(Arg *arg) -{ - if(!sel) - return; - - sel->tags[arg->i] = True; - arrange(NULL); -} - void dofloat(Arg *arg) { @@ -182,19 +172,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() { @@ -211,8 +188,10 @@ restack() else m++; } - - n = 2 * (f + m); + if(!(n = 2 * (f + m))) { + drawstatus(); + return; + } if(nwins < n) { nwins = n; wins = erealloc(wins, nwins * sizeof(Window)); @@ -278,6 +257,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) { @@ -286,24 +281,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); +}