implement multi-tag selection through button3 click on the specific tag
							parent
							
								
									50729a2e73
								
							
						
					
					
						commit
						d7413ffd2d
					
				
							
								
								
									
										4
									
								
								client.c
								
								
								
								
							
							
						
						
									
										4
									
								
								client.c
								
								
								
								
							|  | @ -24,7 +24,7 @@ resizetitle(Client *c) | |||
| 		c->tw = c->w + 2; | ||||
| 	c->tx = c->x + c->w - c->tw + 2; | ||||
| 	c->ty = c->y; | ||||
| 	if(c->tags[tsel]) | ||||
| 	if(isvisible(c)) | ||||
| 		XMoveResizeWindow(dpy, c->title, c->tx, c->ty, c->tw, c->th); | ||||
| 	else | ||||
| 		XMoveResizeWindow(dpy, c->title, c->tx + 2 * sw, c->ty, c->tw, c->th); | ||||
|  | @ -276,7 +276,7 @@ manage(Window w, XWindowAttributes *wa) | |||
| 	/* mapping the window now prevents flicker */ | ||||
| 	XMapRaised(dpy, c->win); | ||||
| 	XMapRaised(dpy, c->title); | ||||
| 	if(c->tags[tsel]) | ||||
| 	if(isvisible(c)) | ||||
| 		focus(c); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
							
								
								
									
										4
									
								
								draw.c
								
								
								
								
							
							
						
						
									
										4
									
								
								draw.c
								
								
								
								
							|  | @ -109,9 +109,9 @@ drawstatus() | |||
| 		dc.x += dc.w; | ||||
| 		dc.w = textw(tags[i]); | ||||
| 		if(istile) | ||||
| 			drawtext(tags[i], (i == tsel)); | ||||
| 			drawtext(tags[i], tsel[i]); | ||||
| 		else | ||||
| 			drawtext(tags[i], (i != tsel)); | ||||
| 			drawtext(tags[i], !tsel[i]); | ||||
| 	} | ||||
| 	x = dc.x + dc.w; | ||||
| 	dc.w = textw(stext); | ||||
|  |  | |||
							
								
								
									
										5
									
								
								dwm.h
								
								
								
								
							
							
						
						
									
										5
									
								
								dwm.h
								
								
								
								
							|  | @ -69,12 +69,12 @@ struct Client { | |||
| 
 | ||||
| extern const char *tags[]; | ||||
| extern char stext[1024]; | ||||
| extern int tsel, screen, sx, sy, sw, sh, bx, by, bw, bh, mw; | ||||
| extern int screen, sx, sy, sw, sh, bx, by, bw, bh, mw; | ||||
| extern unsigned int ntags; | ||||
| extern void (*handler[LASTEvent])(XEvent *); | ||||
| extern void (*arrange)(Arg *); | ||||
| extern Atom wmatom[WMLast], netatom[NetLast]; | ||||
| extern Bool running, issel; | ||||
| extern Bool running, issel, *tsel; | ||||
| extern Client *clients, *sel; | ||||
| extern Cursor cursor[CurLast]; | ||||
| extern DC dc; | ||||
|  | @ -121,6 +121,7 @@ extern void appendtag(Arg *arg); | |||
| extern void dofloat(Arg *arg); | ||||
| extern void dotile(Arg *arg); | ||||
| extern void initrregs(); | ||||
| extern Bool isvisible(Client *c); | ||||
| extern Client *getnext(Client *c); | ||||
| extern Client *getprev(Client *c); | ||||
| extern void replacetag(Arg *arg); | ||||
|  |  | |||
							
								
								
									
										8
									
								
								event.c
								
								
								
								
							
							
						
						
									
										8
									
								
								event.c
								
								
								
								
							|  | @ -108,7 +108,13 @@ buttonpress(XEvent *e) | |||
| 			for(a.i = 0; a.i < ntags; a.i++) { | ||||
| 				x += textw(tags[a.i]); | ||||
| 				if(ev->x < x) { | ||||
| 					view(&a); | ||||
| 					if(ev->button == Button3) { | ||||
| 						tsel[a.i] = True; | ||||
| 						arrange(NULL); | ||||
| 						drawall(); | ||||
| 					} | ||||
| 					else | ||||
| 						view(&a); | ||||
| 					return; | ||||
| 				} | ||||
| 			} | ||||
|  |  | |||
							
								
								
									
										4
									
								
								main.c
								
								
								
								
							
							
						
						
									
										4
									
								
								main.c
								
								
								
								
							|  | @ -83,7 +83,7 @@ xerrorstart(Display *dsply, XErrorEvent *ee) | |||
| /* extern */ | ||||
| 
 | ||||
| char stext[1024]; | ||||
| int tsel = DEFTAG; | ||||
| Bool *tsel; | ||||
| int screen, sx, sy, sw, sh, bx, by, bw, bh, mw; | ||||
| unsigned int ntags; | ||||
| Atom wmatom[WMLast], netatom[NetLast]; | ||||
|  | @ -213,6 +213,8 @@ main(int argc, char *argv[]) | |||
| 	initrregs(); | ||||
| 
 | ||||
| 	for(ntags = 0; tags[ntags]; ntags++); | ||||
| 	tsel = emallocz(sizeof(Bool) * ntags); | ||||
| 	tsel[DEFTAG] = True; | ||||
| 
 | ||||
| 	/* style */ | ||||
| 	dc.bg = getcolor(BGCOLOR); | ||||
|  |  | |||
							
								
								
									
										40
									
								
								tag.c
								
								
								
								
							
							
						
						
									
										40
									
								
								tag.c
								
								
								
								
							|  | @ -51,7 +51,7 @@ dofloat(Arg *arg) | |||
| 
 | ||||
| 	for(c = clients; c; c = c->next) { | ||||
| 		c->ismax = False; | ||||
| 		if(c->tags[tsel]) { | ||||
| 		if(isvisible(c)) { | ||||
| 			resize(c, True, TopLeft); | ||||
| 		} | ||||
| 		else | ||||
|  | @ -74,7 +74,7 @@ dotile(Arg *arg) | |||
| 
 | ||||
| 	w = sw - mw; | ||||
| 	for(n = 0, c = clients; c; c = c->next) | ||||
| 		if(c->tags[tsel] && !c->isfloat) | ||||
| 		if(isvisible(c) && !c->isfloat) | ||||
| 			n++; | ||||
| 
 | ||||
| 	if(n > 1) | ||||
|  | @ -84,7 +84,7 @@ dotile(Arg *arg) | |||
| 
 | ||||
| 	for(i = 0, c = clients; c; c = c->next) { | ||||
| 		c->ismax = False; | ||||
| 		if(c->tags[tsel]) { | ||||
| 		if(isvisible(c)) { | ||||
| 			if(c->isfloat) { | ||||
| 				higher(c); | ||||
| 				resize(c, True, TopLeft); | ||||
|  | @ -135,14 +135,14 @@ dotile(Arg *arg) | |||
| Client * | ||||
| getnext(Client *c) | ||||
| { | ||||
| 	for(; c && !c->tags[tsel]; c = c->next); | ||||
| 	for(; c && !isvisible(c); c = c->next); | ||||
| 	return c; | ||||
| } | ||||
| 
 | ||||
| Client * | ||||
| getprev(Client *c) | ||||
| { | ||||
| 	for(; c && !c->tags[tsel]; c = c->prev); | ||||
| 	for(; c && !isvisible(c); c = c->prev); | ||||
| 	return c; | ||||
| } | ||||
| 
 | ||||
|  | @ -175,6 +175,17 @@ initrregs() | |||
| 	} | ||||
| } | ||||
| 
 | ||||
| Bool | ||||
| isvisible(Client *c) | ||||
| { | ||||
| 	unsigned int i; | ||||
| 
 | ||||
| 	for(i = 0; i < ntags; i++) | ||||
| 		if(c->tags[i] && tsel[i]) | ||||
| 			return True; | ||||
| 	return False; | ||||
| } | ||||
| 
 | ||||
| void | ||||
| replacetag(Arg *arg) | ||||
| { | ||||
|  | @ -217,7 +228,8 @@ settags(Client *c) | |||
| 			XFree(ch.res_name); | ||||
| 	} | ||||
| 	if(!matched) | ||||
| 		c->tags[tsel] = True; | ||||
| 		for(i = 0; i < ntags; i++) | ||||
| 			c->tags[i] = tsel[i]; | ||||
| } | ||||
| 
 | ||||
| void | ||||
|  | @ -230,7 +242,11 @@ togglemode(Arg *arg) | |||
| void | ||||
| view(Arg *arg) | ||||
| { | ||||
| 	tsel = arg->i; | ||||
| 	unsigned int i; | ||||
| 
 | ||||
| 	for(i = 0; i < ntags; i++) | ||||
| 		tsel[i] = False; | ||||
| 	tsel[arg->i] = True; | ||||
| 	arrange(NULL); | ||||
| 	drawall(); | ||||
| } | ||||
|  | @ -238,13 +254,19 @@ view(Arg *arg) | |||
| void | ||||
| viewnext(Arg *arg) | ||||
| { | ||||
| 	arg->i = (tsel < ntags-1) ? tsel+1 : 0; | ||||
| 	unsigned int i; | ||||
| 
 | ||||
| 	for(i = 0; !tsel[i]; i++); | ||||
| 	arg->i = (i < ntags-1) ? i+1 : 0; | ||||
| 	view(arg); | ||||
| } | ||||
| 
 | ||||
| void | ||||
| viewprev(Arg *arg) | ||||
| { | ||||
| 	arg->i = (tsel > 0) ? tsel-1 : ntags-1; | ||||
| 	unsigned int i; | ||||
| 
 | ||||
| 	for(i = 0; !tsel[i]; i++); | ||||
| 	arg->i = (i > 0) ? i-1 : ntags-1; | ||||
| 	view(arg); | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue