From 51911613c57c2dc721a43f0572d843197225ec90 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Fri, 16 Nov 2007 22:07:58 +0100 Subject: [PATCH] handle uicb_client_toggletag() with no args or with i > ntags --- tag.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/tag.c b/tag.c index a26e4cc2..6d430253 100644 --- a/tag.c +++ b/tag.c @@ -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); }