static char stext[256];
static int screen, sx, sy, sw, sh;
static int by, bh, blw, wx, wy, ww, wh;
-static uint seltags = 0;
+static uint seltags = 0, sellt = 0;
static int (*xerrorxlib)(Display *, XErrorEvent *);
static uint numlockmask = 0;
static void (*handler[LASTEvent]) (XEvent *) = {
static Cursor cursor[CurLast];
static Display *dpy;
static DC dc = {0};
-static Layout *lt = NULL;
+static Layout *lt[] = { NULL, NULL };
static Window root, barwin;
/* configuration, allows nested code to access above variables */
#include "config.h"
for(c = clients; c; c = c->next)
if(c->tags & tagset[seltags]) { /* is visible */
- if(!lt->arrange || c->isfloating)
- resize(c, c->x, c->y, c->w, c->h, True);
c->isbanned = False;
+ if(!lt[sellt]->arrange || c->isfloating)
+ resize(c, c->x, c->y, c->w, c->h, True);
}
else if(!c->isbanned) {
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
}
focus(NULL);
- if(lt->arrange)
- lt->arrange();
+ if(lt[sellt]->arrange)
+ lt[sellt]->arrange();
restack();
}
close(STDIN_FILENO);
view(&a);
- lt = &foo;
+ lt[sellt] = &foo;
while(stack)
unmanage(stack);
if(dc.font.set)
if((c = getclient(ev->window))) {
if(ev->value_mask & CWBorderWidth)
c->bw = ev->border_width;
- else if(c->isfloating || !lt->arrange) {
+ else if(c->isfloating || !lt[sellt]->arrange) {
if(ev->value_mask & CWX)
c->x = sx + ev->x;
if(ev->value_mask & CWY)
c->x = sx + (sw / 2 - c->w / 2); /* center in x direction */
if((c->y - sy + c->h) > sh && c->isfloating)
c->y = sy + (sh / 2 - c->h / 2); /* center in y direction */
- if((ev->value_mask & (CWX|CWY))
- && !(ev->value_mask & (CWWidth|CWHeight)))
+ if((ev->value_mask & (CWX|CWY)) && !(ev->value_mask & (CWWidth|CWHeight)))
configure(c);
if(!c->isbanned)
XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
void
drawbar(void) {
int i, x;
- Client *c;
dc.x = 0;
- for(c = stack; c && c->isbanned; c = c->snext);
for(i = 0; i < LENGTH(tags); i++) {
dc.w = TEXTW(tags[i]);
if(tagset[seltags] & 1 << i) {
drawtext(tags[i], dc.sel, isurgent(i));
- drawsquare(c && c->tags & 1 << i, isoccupied(i), isurgent(i), dc.sel);
+ drawsquare(sel && sel->tags & 1 << i, isoccupied(i), isurgent(i), dc.sel);
}
else {
drawtext(tags[i], dc.norm, isurgent(i));
- drawsquare(c && c->tags & 1 << i, isoccupied(i), isurgent(i), dc.norm);
+ drawsquare(sel && sel->tags & 1 << i, isoccupied(i), isurgent(i), dc.norm);
}
dc.x += dc.w;
}
if(blw > 0) {
dc.w = blw;
- drawtext(lt->symbol, dc.norm, False);
+ drawtext(lt[sellt]->symbol, dc.norm, False);
x = dc.x + dc.w;
}
else
drawtext(stext, dc.norm, False);
if((dc.w = dc.x - x) > bh) {
dc.x = x;
- if(c) {
- drawtext(c->name, dc.sel, False);
- drawsquare(c->isfixed, c->isfloating, False, dc.sel);
+ if(sel) {
+ drawtext(sel->name, dc.sel, False);
+ drawsquare(sel->isfixed, sel->isfloating, False, dc.sel);
}
else
drawtext(NULL, dc.norm, False);
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[sellt]->arrange && (abs(nx - c->x) > snap || abs(ny - c->y) > snap))
togglefloating(NULL);
}
- if(!lt->arrange || c->isfloating)
+ if(!lt[sellt]->arrange || c->isfloating)
resize(c, nx, ny, c->w, c->h, False);
break;
}
h = bh;
if(w < bh)
w = bh;
- if(c->x != x || c->y != y || c->w != w || c->h != h) {
+ if(!c->isbanned || c->x != x || c->y != y || c->w != w || c->h != h) {
c->x = wc.x = x;
c->y = wc.y = y;
c->w = wc.width = w;
if(snap && nw >= wx && nw <= wx + ww
&& nh >= wy && nh <= wy + wh) {
- if(!c->isfloating && lt->arrange
+ if(!c->isfloating && lt[sellt]->arrange
&& (abs(nw - c->w) > snap || abs(nh - c->h) > snap))
togglefloating(NULL);
}
- if(!lt->arrange || c->isfloating)
+ if(!lt[sellt]->arrange || c->isfloating)
resize(c, c->x, c->y, nw, nh, True);
break;
}
drawbar();
if(!sel)
return;
- if(sel->isfloating || !lt->arrange)
+ if(sel->isfloating || !lt[sellt]->arrange)
XRaiseWindow(dpy, sel->win);
- if(lt->arrange) {
+ if(lt[sellt]->arrange) {
wc.stack_mode = Below;
wc.sibling = barwin;
for(c = stack; c; c = c->snext)
void
setlayout(const Arg *arg) {
- static Layout *prevlt = &layouts[1 % LENGTH(layouts)];
-
- if(!arg || !arg->v || arg->v == lt)
- lt = prevlt;
- else {
- prevlt = lt;
- lt = (Layout *)arg->v;
- }
+ sellt ^= 1;
+ if(arg && arg->v && arg->v != lt[sellt])
+ lt[sellt] = (Layout *)arg->v;
if(sel)
arrange();
else
setmfact(const Arg *arg) {
float f;
- if(!arg || !lt->arrange)
+ if(!arg || !lt[sellt]->arrange)
return;
f = arg->f < 1.0 ? arg->f + mfact : arg->f - 1.0;
if(f < 0.1 || f > 0.9)
sw = DisplayWidth(dpy, screen);
sh = DisplayHeight(dpy, screen);
bh = dc.h = dc.font.height + 2;
- lt = layouts;
+ lt[0] = &layouts[0];
+ lt[1] = &layouts[1 % LENGTH(layouts)];
updategeom();
/* init atoms */
zoom(const Arg *arg) {
Client *c = sel;
- if(!lt->arrange || lt->arrange == monocle || (sel && sel->isfloating))
+ if(!lt[sellt]->arrange || lt[sellt]->arrange == monocle || (sel && sel->isfloating))
return;
if(c == nexttiled(clients))
if(!c || !(c = nexttiled(c->next)))