dwm-meillo
changeset 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 | 243bf6783c7c |
children | d659a2dce2b5 |
files | client.c draw.c dwm.h event.c main.c tag.c |
diffstat | 6 files changed, 48 insertions(+), 17 deletions(-) [+] |
line diff
1.1 --- a/client.c Fri Aug 11 18:11:39 2006 +0200 1.2 +++ b/client.c Fri Aug 11 18:37:41 2006 +0200 1.3 @@ -24,7 +24,7 @@ 1.4 c->tw = c->w + 2; 1.5 c->tx = c->x + c->w - c->tw + 2; 1.6 c->ty = c->y; 1.7 - if(c->tags[tsel]) 1.8 + if(isvisible(c)) 1.9 XMoveResizeWindow(dpy, c->title, c->tx, c->ty, c->tw, c->th); 1.10 else 1.11 XMoveResizeWindow(dpy, c->title, c->tx + 2 * sw, c->ty, c->tw, c->th); 1.12 @@ -276,7 +276,7 @@ 1.13 /* mapping the window now prevents flicker */ 1.14 XMapRaised(dpy, c->win); 1.15 XMapRaised(dpy, c->title); 1.16 - if(c->tags[tsel]) 1.17 + if(isvisible(c)) 1.18 focus(c); 1.19 } 1.20
2.1 --- a/draw.c Fri Aug 11 18:11:39 2006 +0200 2.2 +++ b/draw.c Fri Aug 11 18:37:41 2006 +0200 2.3 @@ -109,9 +109,9 @@ 2.4 dc.x += dc.w; 2.5 dc.w = textw(tags[i]); 2.6 if(istile) 2.7 - drawtext(tags[i], (i == tsel)); 2.8 + drawtext(tags[i], tsel[i]); 2.9 else 2.10 - drawtext(tags[i], (i != tsel)); 2.11 + drawtext(tags[i], !tsel[i]); 2.12 } 2.13 x = dc.x + dc.w; 2.14 dc.w = textw(stext);
3.1 --- a/dwm.h Fri Aug 11 18:11:39 2006 +0200 3.2 +++ b/dwm.h Fri Aug 11 18:37:41 2006 +0200 3.3 @@ -69,12 +69,12 @@ 3.4 3.5 extern const char *tags[]; 3.6 extern char stext[1024]; 3.7 -extern int tsel, screen, sx, sy, sw, sh, bx, by, bw, bh, mw; 3.8 +extern int screen, sx, sy, sw, sh, bx, by, bw, bh, mw; 3.9 extern unsigned int ntags; 3.10 extern void (*handler[LASTEvent])(XEvent *); 3.11 extern void (*arrange)(Arg *); 3.12 extern Atom wmatom[WMLast], netatom[NetLast]; 3.13 -extern Bool running, issel; 3.14 +extern Bool running, issel, *tsel; 3.15 extern Client *clients, *sel; 3.16 extern Cursor cursor[CurLast]; 3.17 extern DC dc; 3.18 @@ -121,6 +121,7 @@ 3.19 extern void dofloat(Arg *arg); 3.20 extern void dotile(Arg *arg); 3.21 extern void initrregs(); 3.22 +extern Bool isvisible(Client *c); 3.23 extern Client *getnext(Client *c); 3.24 extern Client *getprev(Client *c); 3.25 extern void replacetag(Arg *arg);
4.1 --- a/event.c Fri Aug 11 18:11:39 2006 +0200 4.2 +++ b/event.c Fri Aug 11 18:37:41 2006 +0200 4.3 @@ -108,7 +108,13 @@ 4.4 for(a.i = 0; a.i < ntags; a.i++) { 4.5 x += textw(tags[a.i]); 4.6 if(ev->x < x) { 4.7 - view(&a); 4.8 + if(ev->button == Button3) { 4.9 + tsel[a.i] = True; 4.10 + arrange(NULL); 4.11 + drawall(); 4.12 + } 4.13 + else 4.14 + view(&a); 4.15 return; 4.16 } 4.17 }
5.1 --- a/main.c Fri Aug 11 18:11:39 2006 +0200 5.2 +++ b/main.c Fri Aug 11 18:37:41 2006 +0200 5.3 @@ -83,7 +83,7 @@ 5.4 /* extern */ 5.5 5.6 char stext[1024]; 5.7 -int tsel = DEFTAG; 5.8 +Bool *tsel; 5.9 int screen, sx, sy, sw, sh, bx, by, bw, bh, mw; 5.10 unsigned int ntags; 5.11 Atom wmatom[WMLast], netatom[NetLast]; 5.12 @@ -213,6 +213,8 @@ 5.13 initrregs(); 5.14 5.15 for(ntags = 0; tags[ntags]; ntags++); 5.16 + tsel = emallocz(sizeof(Bool) * ntags); 5.17 + tsel[DEFTAG] = True; 5.18 5.19 /* style */ 5.20 dc.bg = getcolor(BGCOLOR);
6.1 --- a/tag.c Fri Aug 11 18:11:39 2006 +0200 6.2 +++ b/tag.c Fri Aug 11 18:37:41 2006 +0200 6.3 @@ -51,7 +51,7 @@ 6.4 6.5 for(c = clients; c; c = c->next) { 6.6 c->ismax = False; 6.7 - if(c->tags[tsel]) { 6.8 + if(isvisible(c)) { 6.9 resize(c, True, TopLeft); 6.10 } 6.11 else 6.12 @@ -74,7 +74,7 @@ 6.13 6.14 w = sw - mw; 6.15 for(n = 0, c = clients; c; c = c->next) 6.16 - if(c->tags[tsel] && !c->isfloat) 6.17 + if(isvisible(c) && !c->isfloat) 6.18 n++; 6.19 6.20 if(n > 1) 6.21 @@ -84,7 +84,7 @@ 6.22 6.23 for(i = 0, c = clients; c; c = c->next) { 6.24 c->ismax = False; 6.25 - if(c->tags[tsel]) { 6.26 + if(isvisible(c)) { 6.27 if(c->isfloat) { 6.28 higher(c); 6.29 resize(c, True, TopLeft); 6.30 @@ -135,14 +135,14 @@ 6.31 Client * 6.32 getnext(Client *c) 6.33 { 6.34 - for(; c && !c->tags[tsel]; c = c->next); 6.35 + for(; c && !isvisible(c); c = c->next); 6.36 return c; 6.37 } 6.38 6.39 Client * 6.40 getprev(Client *c) 6.41 { 6.42 - for(; c && !c->tags[tsel]; c = c->prev); 6.43 + for(; c && !isvisible(c); c = c->prev); 6.44 return c; 6.45 } 6.46 6.47 @@ -175,6 +175,17 @@ 6.48 } 6.49 } 6.50 6.51 +Bool 6.52 +isvisible(Client *c) 6.53 +{ 6.54 + unsigned int i; 6.55 + 6.56 + for(i = 0; i < ntags; i++) 6.57 + if(c->tags[i] && tsel[i]) 6.58 + return True; 6.59 + return False; 6.60 +} 6.61 + 6.62 void 6.63 replacetag(Arg *arg) 6.64 { 6.65 @@ -217,7 +228,8 @@ 6.66 XFree(ch.res_name); 6.67 } 6.68 if(!matched) 6.69 - c->tags[tsel] = True; 6.70 + for(i = 0; i < ntags; i++) 6.71 + c->tags[i] = tsel[i]; 6.72 } 6.73 6.74 void 6.75 @@ -230,7 +242,11 @@ 6.76 void 6.77 view(Arg *arg) 6.78 { 6.79 - tsel = arg->i; 6.80 + unsigned int i; 6.81 + 6.82 + for(i = 0; i < ntags; i++) 6.83 + tsel[i] = False; 6.84 + tsel[arg->i] = True; 6.85 arrange(NULL); 6.86 drawall(); 6.87 } 6.88 @@ -238,13 +254,19 @@ 6.89 void 6.90 viewnext(Arg *arg) 6.91 { 6.92 - arg->i = (tsel < ntags-1) ? tsel+1 : 0; 6.93 + unsigned int i; 6.94 + 6.95 + for(i = 0; !tsel[i]; i++); 6.96 + arg->i = (i < ntags-1) ? i+1 : 0; 6.97 view(arg); 6.98 } 6.99 6.100 void 6.101 viewprev(Arg *arg) 6.102 { 6.103 - arg->i = (tsel > 0) ? tsel-1 : ntags-1; 6.104 + unsigned int i; 6.105 + 6.106 + for(i = 0; !tsel[i]; i++); 6.107 + arg->i = (i > 0) ? i-1 : ntags-1; 6.108 view(arg); 6.109 }