applied Gottox patch 31da0b75
Anselm R Garbe · 2008-06-19 12:28 1 file(s) · +21 −25
dwm.c +21 −25
207 207
static char stext[256];
208 208
static int screen, sx, sy, sw, sh;
209 209
static int by, bh, blw, wx, wy, ww, wh;
210 -
static uint seltags = 0;
210 +
static uint seltags = 0, sellt = 0;
211 211
static int (*xerrorxlib)(Display *, XErrorEvent *);
212 212
static uint numlockmask = 0;
213 213
static void (*handler[LASTEvent]) (XEvent *) = {
234 234
static Cursor cursor[CurLast];
235 235
static Display *dpy;
236 236
static DC dc = {0};
237 -
static Layout *lt = NULL;
237 +
static Layout *lt[] = { NULL, NULL };
238 238
static Window root, barwin;
239 239
/* configuration, allows nested code to access above variables */
240 240
#include "config.h"
274 274
275 275
	for(c = clients; c; c = c->next)
276 276
		if(c->tags & tagset[seltags]) { /* is visible */
277 -
			if(!lt->arrange || c->isfloating)
277 +
			if(!lt[sellt]->arrange || c->isfloating)
278 278
				resize(c, c->x, c->y, c->w, c->h, True);
279 279
			c->isbanned = False;
280 280
		}
284 284
		}
285 285
286 286
	focus(NULL);
287 -
	if(lt->arrange)
288 -
		lt->arrange();
287 +
	if(lt[sellt]->arrange)
288 +
		lt[sellt]->arrange();
289 289
	restack();
290 290
}
291 291
355 355
356 356
	close(STDIN_FILENO);
357 357
	view(&a);
358 -
	lt = &foo;
358 +
	lt[sellt] = &foo;
359 359
	while(stack)
360 360
		unmanage(stack);
361 361
	if(dc.font.set)
413 413
	if((c = getclient(ev->window))) {
414 414
		if(ev->value_mask & CWBorderWidth)
415 415
			c->bw = ev->border_width;
416 -
		else if(c->isfloating || !lt->arrange) {
416 +
		else if(c->isfloating || !lt[sellt]->arrange) {
417 417
			if(ev->value_mask & CWX)
418 418
				c->x = sx + ev->x;
419 419
			if(ev->value_mask & CWY)
500 500
	}
501 501
	if(blw > 0) {
502 502
		dc.w = blw;
503 -
		drawtext(lt->symbol, dc.norm, False);
503 +
		drawtext(lt[sellt]->symbol, dc.norm, False);
504 504
		x = dc.x + dc.w;
505 505
	}
506 506
	else
1009 1009
					ny = wy;
1010 1010
				else if(abs((wy + wh) - (ny + c->h + 2 * c->bw)) < snap)
1011 1011
					ny = wy + wh - c->h - 2 * c->bw;
1012 -
				if(!c->isfloating && lt->arrange && (abs(nx - c->x) > snap || abs(ny - c->y) > snap))
1012 +
				if(!c->isfloating && lt[sellt]->arrange && (abs(nx - c->x) > snap || abs(ny - c->y) > snap))
1013 1013
					togglefloating(NULL);
1014 1014
			}
1015 -
			if(!lt->arrange || c->isfloating)
1015 +
			if(!lt[sellt]->arrange || c->isfloating)
1016 1016
				resize(c, nx, ny, c->w, c->h, False);
1017 1017
			break;
1018 1018
		}
1166 1166
1167 1167
			if(snap && nw >= wx && nw <= wx + ww
1168 1168
			        && nh >= wy && nh <= wy + wh) {
1169 -
				if(!c->isfloating && lt->arrange
1169 +
				if(!c->isfloating && lt[sellt]->arrange
1170 1170
				   && (abs(nw - c->w) > snap || abs(nh - c->h) > snap))
1171 1171
					togglefloating(NULL);
1172 1172
			}
1173 -
			if(!lt->arrange || c->isfloating)
1173 +
			if(!lt[sellt]->arrange || c->isfloating)
1174 1174
				resize(c, c->x, c->y, nw, nh, True);
1175 1175
			break;
1176 1176
		}
1186 1186
	drawbar();
1187 1187
	if(!sel)
1188 1188
		return;
1189 -
	if(sel->isfloating || !lt->arrange)
1189 +
	if(sel->isfloating || !lt[sellt]->arrange)
1190 1190
		XRaiseWindow(dpy, sel->win);
1191 -
	if(lt->arrange) {
1191 +
	if(lt[sellt]->arrange) {
1192 1192
		wc.stack_mode = Below;
1193 1193
		wc.sibling = barwin;
1194 1194
		for(c = stack; c; c = c->snext)
1298 1298
1299 1299
void
1300 1300
setlayout(const Arg *arg) {
1301 -
	static Layout *prevlt = &layouts[1 % LENGTH(layouts)];
1302 -
1303 -
	if(!arg || !arg->v || arg->v == lt)
1304 -
		lt = prevlt;
1305 -
	else {
1306 -
		prevlt = lt;
1307 -
		lt = (Layout *)arg->v;
1308 -
	}
1301 +
	sellt ^= 1;
1302 +
	if(arg && arg->v && arg->v != lt[sellt])
1303 +
		lt[sellt] = (Layout *)arg->v;
1309 1304
	if(sel)
1310 1305
		arrange();
1311 1306
	else
1317 1312
setmfact(const Arg *arg) {
1318 1313
	float f;
1319 1314
1320 -
	if(!arg || !lt->arrange)
1315 +
	if(!arg || !lt[sellt]->arrange)
1321 1316
		return;
1322 1317
	f = arg->f < 1.0 ? arg->f + mfact : arg->f - 1.0;
1323 1318
	if(f < 0.1 || f > 0.9)
1341 1336
	sw = DisplayWidth(dpy, screen);
1342 1337
	sh = DisplayHeight(dpy, screen);
1343 1338
	bh = dc.h = dc.font.height + 2;
1344 -
	lt = layouts;
1339 +
	lt[0] = &layouts[0];
1340 +
	lt[1] = &layouts[1 % LENGTH(layouts)];
1345 1341
	updategeom();
1346 1342
1347 1343
	/* init atoms */
1691 1687
zoom(const Arg *arg) {
1692 1688
	Client *c = sel;
1693 1689
1694 -
	if(!lt->arrange || lt->arrange == monocle || (sel && sel->isfloating))
1690 +
	if(!lt[sellt]->arrange || lt[sellt]->arrange == monocle || (sel && sel->isfloating))
1695 1691
		return;
1696 1692
	if(c == nexttiled(clients))
1697 1693
		if(!c || !(c = nexttiled(c->next)))