--- dwm-5.0.1/dwm.c 2008-06-19 10:11:38.000000000 +0200 +++ dwm-5.0.1-fred/dwm.c 2008-06-29 17:38:44.008624580 +0200 @@ -229,13 +229,15 @@ static Bool ismax = False; static Bool otherwm, readin; static Bool running = True; static uint tagset[] = {1, 1}; /* after start, first tag is selected */ +static uint maintag[] = {1, 1}; static Client *clients = NULL; static Client *sel = NULL; static Client *stack = NULL; static Cursor cursor[CurLast]; static Display *dpy; static DC dc = {0}; -static Layout *lt = NULL; +static Layout *lt[MAXTAGLEN]; +static float mfacts[MAXTAGLEN]; static Window root, barwin; /* configuration, allows nested code to access above variables */ #include "config.h" @@ -279,7 +281,7 @@ arrange(void) { XMoveResizeWindow(dpy, c->win, wx, wy, ww - 2 * c->bw, wh - 2 * c->bw); c->ismoved = True; } - else if(!lt->arrange || c->isfloating) + else if(!lt[maintag[seltags]]->arrange || c->isfloating) resize(c, c->x, c->y, c->w, c->h, True); c->isbanned = False; } @@ -289,8 +291,8 @@ arrange(void) { } focus(NULL); - if(lt->arrange && !ismax) - lt->arrange(); + if(lt[maintag[seltags]]->arrange && !ismax) + lt[maintag[seltags]]->arrange(); restack(); } @@ -357,10 +359,13 @@ void cleanup(void) { Arg a = {.i = ~0}; Layout foo = { "", NULL }; + int i; close(STDIN_FILENO); view(&a); - lt = &foo; + for(i = 0; i < LENGTH(tags); i++) + lt[i] = &foo; + while(stack) unmanage(stack); if(dc.font.set) @@ -420,7 +425,7 @@ configurerequest(XEvent *e) { c->bw = ev->border_width; if(ismax && !c->isbanned && !c->isfixed) XMoveResizeWindow(dpy, c->win, wx, wy, ww - 2 * c->bw, wh + 2 * c->bw); - else if(c->isfloating || !lt->arrange) { + else if(c->isfloating || !lt[maintag[seltags]]->arrange) { if(ev->value_mask & CWX) c->x = sx + ev->x; if(ev->value_mask & CWY) @@ -507,7 +512,7 @@ drawbar(void) { } if(blw > 0) { dc.w = blw; - drawtext(lt->symbol, dc.norm, ismax); + drawtext(lt[maintag[seltags]]->symbol, dc.norm, ismax); x = dc.x + dc.w; } else @@ -1008,10 +1013,10 @@ movemouse(const Arg *arg) { ny = wy; else if(abs((wy + wh) - (ny + c->h + 2 * c->bw)) < snap) ny = wy + wh - c->h - 2 * c->bw; - if(!c->isfloating && lt->arrange && (abs(nx - c->x) > snap || abs(ny - c->y) > snap)) + if(!c->isfloating && lt[maintag[seltags]]->arrange && (abs(nx - c->x) > snap || abs(ny - c->y) > snap)) togglefloating(NULL); } - if(!lt->arrange || c->isfloating) + if(!lt[maintag[seltags]]->arrange || c->isfloating) resize(c, nx, ny, c->w, c->h, False); break; } @@ -1166,11 +1171,11 @@ resizemouse(const Arg *arg) { if(snap && nw >= wx && nw <= wx + ww && nh >= wy && nh <= wy + wh) { - if(!c->isfloating && lt->arrange + if(!c->isfloating && lt[maintag[seltags]]->arrange && (abs(nw - c->w) > snap || abs(nh - c->h) > snap)) togglefloating(NULL); } - if(!lt->arrange || c->isfloating) + if(!lt[maintag[seltags]]->arrange || c->isfloating) resize(c, c->x, c->y, nw, nh, True); break; } @@ -1186,9 +1191,9 @@ restack(void) { drawbar(); if(!sel) return; - if(ismax || sel->isfloating || !lt->arrange) + if(ismax || sel->isfloating || !lt[maintag[seltags]]->arrange) XRaiseWindow(dpy, sel->win); - if(!ismax && lt->arrange) { + if(!ismax && lt[maintag[seltags]]->arrange) { wc.stack_mode = Below; wc.sibling = barwin; for(c = stack; c; c = c->snext) @@ -1301,12 +1306,13 @@ void setmfact(const Arg *arg) { float f; - if(!arg || !lt->arrange) + if(!arg || !lt[maintag[seltags]]->arrange) return; f = arg->f < 1.0 ? arg->f + mfact : arg->f - 1.0; if(f < 0.1 || f > 0.9) return; mfact = f; + mfacts[maintag[seltags]] = mfact; arrange(); } @@ -1325,7 +1331,10 @@ setup(void) { sw = DisplayWidth(dpy, screen); sh = DisplayHeight(dpy, screen); bh = dc.h = dc.font.height + 2; - lt = layouts; + for(i = 0; i < LENGTH(tags); i++) { + lt[i] = layouts; + mfacts[i] = mfact; + } updategeom(); /* init atoms */ @@ -1478,10 +1487,15 @@ togglefloating(const Arg *arg) { void togglelayout(const Arg *arg) { - if(arg && arg->v) - lt = (Layout *)arg->v; - else if(++lt == &layouts[LENGTH(layouts)]) - lt = &layouts[0]; + int i; + for(i = 0; i < LENGTH(tags); i++) { + if(tagset[seltags] & 1 << i) { + if(arg && arg->v) + lt[i] = (Layout *)arg->v; + else if(++(lt[i]) == &layouts[LENGTH(layouts)]) + lt[i] = &layouts[0]; + } + } if(sel) arrange(); else @@ -1650,9 +1664,18 @@ updatewmhints(Client *c) { void view(const Arg *arg) { + int i; seltags ^= 1; /* toggle sel tagset */ - if(arg && (arg->ui & TAGMASK)) + if(arg && (arg->ui & TAGMASK)) { tagset[seltags] = arg->i & TAGMASK; + for(i = 0; i < LENGTH(tags); i++) + if(tagset[seltags] & 1 << i) { + maintag[seltags] = i; + break; + } + + } + mfact = mfacts[maintag[seltags]]; arrange(); } @@ -1693,7 +1716,7 @@ void zoom(const Arg *arg) { Client *c = sel; - if(ismax || !lt->arrange || (sel && sel->isfloating)) + if(ismax || !lt[maintag[seltags]]->arrange || (sel && sel->isfloating)) return; if(c == nexttiled(clients)) if(!c || !(c = nexttiled(c->next)))