handle uicb_client_toggletag() with no args or with i > ntags

This commit is contained in:
Julien Danjou 2007-11-16 22:07:58 +01:00
parent d46f740a39
commit 51911613c5
1 changed files with 20 additions and 7 deletions

27
tag.c
View File

@ -120,16 +120,29 @@ uicb_client_toggletag(awesome_config *awesomeconf,
const char *arg)
{
Client *sel = get_current_tag(awesomeconf->tags, awesomeconf->ntags)->client_sel;
unsigned int i;
int j;
int i, j;
if(!sel)
return;
i = arg ? atoi(arg) - 1 : 0;
sel->tags[i] = !sel->tags[i];
for(j = 0; j < awesomeconf->ntags && !sel->tags[j]; j++);
if(j == awesomeconf->ntags)
sel->tags[i] = True;
if(arg)
{
i = atoi(arg) - 1;
if(i >= awesomeconf->ntags)
return;
sel->tags[i] = !sel->tags[i];
/* check that there's at least one tag selected for this client*/
for(j = 0; j < awesomeconf->ntags && !sel->tags[j]; j++);
if(j == awesomeconf->ntags)
sel->tags[i] = True;
}
else
for(i = 0; i < awesomeconf->ntags; i++)
sel->tags[i] = True;
saveprops(sel, awesomeconf->ntags);
arrange(awesomeconf);
}