summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnselm R.Garbe <arg@10ksloc.org>2006-08-11 18:37:41 +0200
committerAnselm R.Garbe <arg@10ksloc.org>2006-08-11 18:37:41 +0200
commitd7413ffd2d9a84fc3140b28b26f8cb6bb80164e4 (patch)
tree7e7f0f998a77610178e91d57c175526332098abd
parentafter some days of experimenting with grey background, I finally give up and ... (diff)
downloaddwm-d7413ffd2d9a84fc3140b28b26f8cb6bb80164e4.tar.gz
dwm-d7413ffd2d9a84fc3140b28b26f8cb6bb80164e4.zip
implement multi-tag selection through button3 click on the specific tag
Diffstat (limited to '')
-rw-r--r--client.c4
-rw-r--r--draw.c4
-rw-r--r--dwm.h5
-rw-r--r--event.c8
-rw-r--r--main.c4
-rw-r--r--tag.c40
6 files changed, 48 insertions, 17 deletions
diff --git a/client.c b/client.c
index 9710989..5be438e 100644
--- a/client.c
+++ b/client.c
@@ -24,7 +24,7 @@ resizetitle(Client *c)
24 c->tw = c->w + 2; 24 c->tw = c->w + 2;
25 c->tx = c->x + c->w - c->tw + 2; 25 c->tx = c->x + c->w - c->tw + 2;
26 c->ty = c->y; 26 c->ty = c->y;
27 if(c->tags[tsel]) 27 if(isvisible(c))
28 XMoveResizeWindow(dpy, c->title, c->tx, c->ty, c->tw, c->th); 28 XMoveResizeWindow(dpy, c->title, c->tx, c->ty, c->tw, c->th);
29 else 29 else
30 XMoveResizeWindow(dpy, c->title, c->tx + 2 * sw, c->ty, c->tw, c->th); 30 XMoveResizeWindow(dpy, c->title, c->tx + 2 * sw, c->ty, c->tw, c->th);
@@ -276,7 +276,7 @@ manage(Window w, XWindowAttributes *wa)
276 /* mapping the window now prevents flicker */ 276 /* mapping the window now prevents flicker */
277 XMapRaised(dpy, c->win); 277 XMapRaised(dpy, c->win);
278 XMapRaised(dpy, c->title); 278 XMapRaised(dpy, c->title);
279 if(c->tags[tsel]) 279 if(isvisible(c))
280 focus(c); 280 focus(c);
281} 281}
282 282
diff --git a/draw.c b/draw.c
index 6466f41..bdbe85a 100644
--- a/draw.c
+++ b/draw.c
@@ -109,9 +109,9 @@ drawstatus()
109 dc.x += dc.w; 109 dc.x += dc.w;
110 dc.w = textw(tags[i]); 110 dc.w = textw(tags[i]);
111 if(istile) 111 if(istile)
112 drawtext(tags[i], (i == tsel)); 112 drawtext(tags[i], tsel[i]);
113 else 113 else
114 drawtext(tags[i], (i != tsel)); 114 drawtext(tags[i], !tsel[i]);
115 } 115 }
116 x = dc.x + dc.w; 116 x = dc.x + dc.w;
117 dc.w = textw(stext); 117 dc.w = textw(stext);
diff --git a/dwm.h b/dwm.h
index 88640b8..41b1c36 100644
--- a/dwm.h
+++ b/dwm.h
@@ -69,12 +69,12 @@ struct Client {
69 69
70extern const char *tags[]; 70extern const char *tags[];
71extern char stext[1024]; 71extern char stext[1024];
72extern int tsel, screen, sx, sy, sw, sh, bx, by, bw, bh, mw; 72extern int screen, sx, sy, sw, sh, bx, by, bw, bh, mw;
73extern unsigned int ntags; 73extern unsigned int ntags;
74extern void (*handler[LASTEvent])(XEvent *); 74extern void (*handler[LASTEvent])(XEvent *);
75extern void (*arrange)(Arg *); 75extern void (*arrange)(Arg *);
76extern Atom wmatom[WMLast], netatom[NetLast]; 76extern Atom wmatom[WMLast], netatom[NetLast];
77extern Bool running, issel; 77extern Bool running, issel, *tsel;
78extern Client *clients, *sel; 78extern Client *clients, *sel;
79extern Cursor cursor[CurLast]; 79extern Cursor cursor[CurLast];
80extern DC dc; 80extern DC dc;
@@ -121,6 +121,7 @@ extern void appendtag(Arg *arg);
121extern void dofloat(Arg *arg); 121extern void dofloat(Arg *arg);
122extern void dotile(Arg *arg); 122extern void dotile(Arg *arg);
123extern void initrregs(); 123extern void initrregs();
124extern Bool isvisible(Client *c);
124extern Client *getnext(Client *c); 125extern Client *getnext(Client *c);
125extern Client *getprev(Client *c); 126extern Client *getprev(Client *c);
126extern void replacetag(Arg *arg); 127extern void replacetag(Arg *arg);
diff --git a/event.c b/event.c
index 8a1c2a9..05b42f0 100644
--- a/event.c
+++ b/event.c
@@ -108,7 +108,13 @@ buttonpress(XEvent *e)
108 for(a.i = 0; a.i < ntags; a.i++) { 108 for(a.i = 0; a.i < ntags; a.i++) {
109 x += textw(tags[a.i]); 109 x += textw(tags[a.i]);
110 if(ev->x < x) { 110 if(ev->x < x) {
111 view(&a); 111 if(ev->button == Button3) {
112 tsel[a.i] = True;
113 arrange(NULL);
114 drawall();
115 }
116 else
117 view(&a);
112 return; 118 return;
113 } 119 }
114 } 120 }
diff --git a/main.c b/main.c
index 52c0347..fec7ea8 100644
--- a/main.c
+++ b/main.c
@@ -83,7 +83,7 @@ xerrorstart(Display *dsply, XErrorEvent *ee)
83/* extern */ 83/* extern */
84 84
85char stext[1024]; 85char stext[1024];
86int tsel = DEFTAG; 86Bool *tsel;
87int screen, sx, sy, sw, sh, bx, by, bw, bh, mw; 87int screen, sx, sy, sw, sh, bx, by, bw, bh, mw;
88unsigned int ntags; 88unsigned int ntags;
89Atom wmatom[WMLast], netatom[NetLast]; 89Atom wmatom[WMLast], netatom[NetLast];
@@ -213,6 +213,8 @@ main(int argc, char *argv[])
213 initrregs(); 213 initrregs();
214 214
215 for(ntags = 0; tags[ntags]; ntags++); 215 for(ntags = 0; tags[ntags]; ntags++);
216 tsel = emallocz(sizeof(Bool) * ntags);
217 tsel[DEFTAG] = True;
216 218
217 /* style */ 219 /* style */
218 dc.bg = getcolor(BGCOLOR); 220 dc.bg = getcolor(BGCOLOR);
diff --git a/tag.c b/tag.c
index 3aa0263..3e89569 100644
--- a/tag.c
+++ b/tag.c
@@ -51,7 +51,7 @@ dofloat(Arg *arg)
51 51
52 for(c = clients; c; c = c->next) { 52 for(c = clients; c; c = c->next) {
53 c->ismax = False; 53 c->ismax = False;
54 if(c->tags[tsel]) { 54 if(isvisible(c)) {
55 resize(c, True, TopLeft); 55 resize(c, True, TopLeft);
56 } 56 }
57 else 57 else
@@ -74,7 +74,7 @@ dotile(Arg *arg)
74 74
75 w = sw - mw; 75 w = sw - mw;
76 for(n = 0, c = clients; c; c = c->next) 76 for(n = 0, c = clients; c; c = c->next)
77 if(c->tags[tsel] && !c->isfloat) 77 if(isvisible(c) && !c->isfloat)
78 n++; 78 n++;
79 79
80 if(n > 1) 80 if(n > 1)
@@ -84,7 +84,7 @@ dotile(Arg *arg)
84 84
85 for(i = 0, c = clients; c; c = c->next) { 85 for(i = 0, c = clients; c; c = c->next) {
86 c->ismax = False; 86 c->ismax = False;
87 if(c->tags[tsel]) { 87 if(isvisible(c)) {
88 if(c->isfloat) { 88 if(c->isfloat) {
89 higher(c); 89 higher(c);
90 resize(c, True, TopLeft); 90 resize(c, True, TopLeft);
@@ -135,14 +135,14 @@ dotile(Arg *arg)
135Client * 135Client *
136getnext(Client *c) 136getnext(Client *c)
137{ 137{
138 for(; c && !c->tags[tsel]; c = c->next); 138 for(; c && !isvisible(c); c = c->next);
139 return c; 139 return c;
140} 140}
141 141
142Client * 142Client *
143getprev(Client *c) 143getprev(Client *c)
144{ 144{
145 for(; c && !c->tags[tsel]; c = c->prev); 145 for(; c && !isvisible(c); c = c->prev);
146 return c; 146 return c;
147} 147}
148 148
@@ -175,6 +175,17 @@ initrregs()
175 } 175 }
176} 176}
177 177
178Bool
179isvisible(Client *c)
180{
181 unsigned int i;
182
183 for(i = 0; i < ntags; i++)
184 if(c->tags[i] && tsel[i])
185 return True;
186 return False;
187}
188
178void 189void
179replacetag(Arg *arg) 190replacetag(Arg *arg)
180{ 191{
@@ -217,7 +228,8 @@ settags(Client *c)
217 XFree(ch.res_name); 228 XFree(ch.res_name);
218 } 229 }
219 if(!matched) 230 if(!matched)
220 c->tags[tsel] = True; 231 for(i = 0; i < ntags; i++)
232 c->tags[i] = tsel[i];
221} 233}
222 234
223void 235void
@@ -230,7 +242,11 @@ togglemode(Arg *arg)
230void 242void
231view(Arg *arg) 243view(Arg *arg)
232{ 244{
233 tsel = arg->i; 245 unsigned int i;
246
247 for(i = 0; i < ntags; i++)
248 tsel[i] = False;
249 tsel[arg->i] = True;
234 arrange(NULL); 250 arrange(NULL);
235 drawall(); 251 drawall();
236} 252}
@@ -238,13 +254,19 @@ view(Arg *arg)
238void 254void
239viewnext(Arg *arg) 255viewnext(Arg *arg)
240{ 256{
241 arg->i = (tsel < ntags-1) ? tsel+1 : 0; 257 unsigned int i;
258
259 for(i = 0; !tsel[i]; i++);
260 arg->i = (i < ntags-1) ? i+1 : 0;
242 view(arg); 261 view(arg);
243} 262}
244 263
245void 264void
246viewprev(Arg *arg) 265viewprev(Arg *arg)
247{ 266{
248 arg->i = (tsel > 0) ? tsel-1 : ntags-1; 267 unsigned int i;
268
269 for(i = 0; !tsel[i]; i++);
270 arg->i = (i > 0) ? i-1 : ntags-1;
249 view(arg); 271 view(arg);
250} 272}