aewl

diff tag.c @ 261:d6fd632d861c

implement multi-tag selection through button3 click on the specific tag
author Anselm R.Garbe <arg@10ksloc.org>
date Fri, 11 Aug 2006 18:37:41 +0200
parents 87c5d5176e17
children d659a2dce2b5
line diff
     1.1 --- a/tag.c	Fri Aug 11 18:11:39 2006 +0200
     1.2 +++ b/tag.c	Fri Aug 11 18:37:41 2006 +0200
     1.3 @@ -51,7 +51,7 @@
     1.4  
     1.5  	for(c = clients; c; c = c->next) {
     1.6  		c->ismax = False;
     1.7 -		if(c->tags[tsel]) {
     1.8 +		if(isvisible(c)) {
     1.9  			resize(c, True, TopLeft);
    1.10  		}
    1.11  		else
    1.12 @@ -74,7 +74,7 @@
    1.13  
    1.14  	w = sw - mw;
    1.15  	for(n = 0, c = clients; c; c = c->next)
    1.16 -		if(c->tags[tsel] && !c->isfloat)
    1.17 +		if(isvisible(c) && !c->isfloat)
    1.18  			n++;
    1.19  
    1.20  	if(n > 1)
    1.21 @@ -84,7 +84,7 @@
    1.22  
    1.23  	for(i = 0, c = clients; c; c = c->next) {
    1.24  		c->ismax = False;
    1.25 -		if(c->tags[tsel]) {
    1.26 +		if(isvisible(c)) {
    1.27  			if(c->isfloat) {
    1.28  				higher(c);
    1.29  				resize(c, True, TopLeft);
    1.30 @@ -135,14 +135,14 @@
    1.31  Client *
    1.32  getnext(Client *c)
    1.33  {
    1.34 -	for(; c && !c->tags[tsel]; c = c->next);
    1.35 +	for(; c && !isvisible(c); c = c->next);
    1.36  	return c;
    1.37  }
    1.38  
    1.39  Client *
    1.40  getprev(Client *c)
    1.41  {
    1.42 -	for(; c && !c->tags[tsel]; c = c->prev);
    1.43 +	for(; c && !isvisible(c); c = c->prev);
    1.44  	return c;
    1.45  }
    1.46  
    1.47 @@ -175,6 +175,17 @@
    1.48  	}
    1.49  }
    1.50  
    1.51 +Bool
    1.52 +isvisible(Client *c)
    1.53 +{
    1.54 +	unsigned int i;
    1.55 +
    1.56 +	for(i = 0; i < ntags; i++)
    1.57 +		if(c->tags[i] && tsel[i])
    1.58 +			return True;
    1.59 +	return False;
    1.60 +}
    1.61 +
    1.62  void
    1.63  replacetag(Arg *arg)
    1.64  {
    1.65 @@ -217,7 +228,8 @@
    1.66  			XFree(ch.res_name);
    1.67  	}
    1.68  	if(!matched)
    1.69 -		c->tags[tsel] = True;
    1.70 +		for(i = 0; i < ntags; i++)
    1.71 +			c->tags[i] = tsel[i];
    1.72  }
    1.73  
    1.74  void
    1.75 @@ -230,7 +242,11 @@
    1.76  void
    1.77  view(Arg *arg)
    1.78  {
    1.79 -	tsel = arg->i;
    1.80 +	unsigned int i;
    1.81 +
    1.82 +	for(i = 0; i < ntags; i++)
    1.83 +		tsel[i] = False;
    1.84 +	tsel[arg->i] = True;
    1.85  	arrange(NULL);
    1.86  	drawall();
    1.87  }
    1.88 @@ -238,13 +254,19 @@
    1.89  void
    1.90  viewnext(Arg *arg)
    1.91  {
    1.92 -	arg->i = (tsel < ntags-1) ? tsel+1 : 0;
    1.93 +	unsigned int i;
    1.94 +
    1.95 +	for(i = 0; !tsel[i]; i++);
    1.96 +	arg->i = (i < ntags-1) ? i+1 : 0;
    1.97  	view(arg);
    1.98  }
    1.99  
   1.100  void
   1.101  viewprev(Arg *arg)
   1.102  {
   1.103 -	arg->i = (tsel > 0) ? tsel-1 : ntags-1;
   1.104 +	unsigned int i;
   1.105 +
   1.106 +	for(i = 0; !tsel[i]; i++);
   1.107 +	arg->i = (i > 0) ? i-1 : ntags-1;
   1.108  	view(arg);
   1.109  }