implement multi-tag selection through button3 click on the specific tag d7413ffd
Anselm R.Garbe · 2006-08-11 18:37 6 file(s) · +48 −17
client.c +2 −2
24 24
		c->tw = c->w + 2;
25 25
	c->tx = c->x + c->w - c->tw + 2;
26 26
	c->ty = c->y;
27 -
	if(c->tags[tsel])
27 +
	if(isvisible(c))
28 28
		XMoveResizeWindow(dpy, c->title, c->tx, c->ty, c->tw, c->th);
29 29
	else
30 30
		XMoveResizeWindow(dpy, c->title, c->tx + 2 * sw, c->ty, c->tw, c->th);
276 276
	/* mapping the window now prevents flicker */
277 277
	XMapRaised(dpy, c->win);
278 278
	XMapRaised(dpy, c->title);
279 -
	if(c->tags[tsel])
279 +
	if(isvisible(c))
280 280
		focus(c);
281 281
}
282 282
draw.c +2 −2
109 109
		dc.x += dc.w;
110 110
		dc.w = textw(tags[i]);
111 111
		if(istile)
112 -
			drawtext(tags[i], (i == tsel));
112 +
			drawtext(tags[i], tsel[i]);
113 113
		else
114 -
			drawtext(tags[i], (i != tsel));
114 +
			drawtext(tags[i], !tsel[i]);
115 115
	}
116 116
	x = dc.x + dc.w;
117 117
	dc.w = textw(stext);
dwm.h +3 −2
69 69
70 70
extern const char *tags[];
71 71
extern char stext[1024];
72 -
extern int tsel, screen, sx, sy, sw, sh, bx, by, bw, bh, mw;
72 +
extern int screen, sx, sy, sw, sh, bx, by, bw, bh, mw;
73 73
extern unsigned int ntags;
74 74
extern void (*handler[LASTEvent])(XEvent *);
75 75
extern void (*arrange)(Arg *);
76 76
extern Atom wmatom[WMLast], netatom[NetLast];
77 -
extern Bool running, issel;
77 +
extern Bool running, issel, *tsel;
78 78
extern Client *clients, *sel;
79 79
extern Cursor cursor[CurLast];
80 80
extern DC dc;
121 121
extern void dofloat(Arg *arg);
122 122
extern void dotile(Arg *arg);
123 123
extern void initrregs();
124 +
extern Bool isvisible(Client *c);
124 125
extern Client *getnext(Client *c);
125 126
extern Client *getprev(Client *c);
126 127
extern void replacetag(Arg *arg);
event.c +7 −1
108 108
			for(a.i = 0; a.i < ntags; a.i++) {
109 109
				x += textw(tags[a.i]);
110 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 118
					return;
113 119
				}
114 120
			}
main.c +3 −1
83 83
/* extern */
84 84
85 85
char stext[1024];
86 -
int tsel = DEFTAG;
86 +
Bool *tsel;
87 87
int screen, sx, sy, sw, sh, bx, by, bw, bh, mw;
88 88
unsigned int ntags;
89 89
Atom wmatom[WMLast], netatom[NetLast];
213 213
	initrregs();
214 214
215 215
	for(ntags = 0; tags[ntags]; ntags++);
216 +
	tsel = emallocz(sizeof(Bool) * ntags);
217 +
	tsel[DEFTAG] = True;
216 218
217 219
	/* style */
218 220
	dc.bg = getcolor(BGCOLOR);
tag.c +31 −9
51 51
52 52
	for(c = clients; c; c = c->next) {
53 53
		c->ismax = False;
54 -
		if(c->tags[tsel]) {
54 +
		if(isvisible(c)) {
55 55
			resize(c, True, TopLeft);
56 56
		}
57 57
		else
74 74
75 75
	w = sw - mw;
76 76
	for(n = 0, c = clients; c; c = c->next)
77 -
		if(c->tags[tsel] && !c->isfloat)
77 +
		if(isvisible(c) && !c->isfloat)
78 78
			n++;
79 79
80 80
	if(n > 1)
84 84
85 85
	for(i = 0, c = clients; c; c = c->next) {
86 86
		c->ismax = False;
87 -
		if(c->tags[tsel]) {
87 +
		if(isvisible(c)) {
88 88
			if(c->isfloat) {
89 89
				higher(c);
90 90
				resize(c, True, TopLeft);
135 135
Client *
136 136
getnext(Client *c)
137 137
{
138 -
	for(; c && !c->tags[tsel]; c = c->next);
138 +
	for(; c && !isvisible(c); c = c->next);
139 139
	return c;
140 140
}
141 141
142 142
Client *
143 143
getprev(Client *c)
144 144
{
145 -
	for(; c && !c->tags[tsel]; c = c->prev);
145 +
	for(; c && !isvisible(c); c = c->prev);
146 146
	return c;
147 147
}
148 148
175 175
	}
176 176
}
177 177
178 +
Bool
179 +
isvisible(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 +
178 189
void
179 190
replacetag(Arg *arg)
180 191
{
217 228
			XFree(ch.res_name);
218 229
	}
219 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
223 235
void
230 242
void
231 243
view(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 250
	arrange(NULL);
235 251
	drawall();
236 252
}
238 254
void
239 255
viewnext(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 261
	view(arg);
243 262
}
244 263
245 264
void
246 265
viewprev(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 271
	view(arg);
250 272
}