applied Ph's seltags-simplification with some modifications

keyboard
anselm@anselm1 17 years ago
parent 874837f653
commit c059625128
  1. 23
      dwm.c

23
dwm.c

@ -214,6 +214,7 @@ char stext[256], buf[256];
int screen, sx, sy, sw, sh; int screen, sx, sy, sw, sh;
int (*xerrorxlib)(Display *, XErrorEvent *); int (*xerrorxlib)(Display *, XErrorEvent *);
int bx, by, bw, bh, blw, bgw, mx, my, mw, mh, mox, moy, mow, moh, tx, ty, tw, th, wx, wy, ww, wh; int bx, by, bw, bh, blw, bgw, mx, my, mw, mh, mox, moy, mow, moh, tx, ty, tw, th, wx, wy, ww, wh;
int viewtags_set = 0;
double mfact; double mfact;
unsigned int numlockmask = 0; unsigned int numlockmask = 0;
void (*handler[LASTEvent]) (XEvent *) = { void (*handler[LASTEvent]) (XEvent *) = {
@ -233,8 +234,8 @@ void (*handler[LASTEvent]) (XEvent *) = {
Atom wmatom[WMLast], netatom[NetLast]; Atom wmatom[WMLast], netatom[NetLast];
Bool otherwm, readin; Bool otherwm, readin;
Bool running = True; Bool running = True;
Bool *prevtags;
Bool *seltags; Bool *seltags;
Bool *viewtags[2];
Client *clients = NULL; Client *clients = NULL;
Client *sel = NULL; Client *sel = NULL;
Client *stack = NULL; Client *stack = NULL;
@ -246,7 +247,6 @@ Window root, barwin;
/* configuration, allows nested code to access above variables */ /* configuration, allows nested code to access above variables */
#include "config.h" #include "config.h"
#define TAGSZ (LENGTH(tags) * sizeof(Bool)) #define TAGSZ (LENGTH(tags) * sizeof(Bool))
Bool tmp[LENGTH(tags)];
Layout *lt = layouts; Layout *lt = layouts;
Geom *geom = geoms; Geom *geom = geoms;
@ -1158,11 +1158,10 @@ quit(const char *arg) {
void void
reapply(const char *arg) { reapply(const char *arg) {
static Bool zerotags[LENGTH(tags)] = { 0 };
Client *c; Client *c;
for(c = clients; c; c = c->next) { for(c = clients; c; c = c->next) {
memcpy(c->tags, zerotags, sizeof zerotags); memset(c->tags, 0, TAGSZ);
applyrules(c); applyrules(c);
} }
arrange(); arrange();
@ -1506,9 +1505,10 @@ setup(void) {
XSetFont(dpy, dc.gc, dc.font.xfont->fid); XSetFont(dpy, dc.gc, dc.font.xfont->fid);
/* init tags */ /* init tags */
seltags = emallocz(TAGSZ); viewtags[0] = emallocz(TAGSZ);
prevtags = emallocz(TAGSZ); viewtags[1] = emallocz(TAGSZ);
seltags[0] = prevtags[0] = True; viewtags[0][0] = viewtags[1][0] = True;
seltags = viewtags[0];
/* init bar */ /* init bar */
for(blw = i = 0; LENGTH(layouts) > 1 && i < LENGTH(layouts); i++) { for(blw = i = 0; LENGTH(layouts) > 1 && i < LENGTH(layouts); i++) {
@ -1828,9 +1828,9 @@ updatewmhints(Client *c) {
} }
} }
void void
view(const char *arg) { view(const char *arg) {
Bool tmp[LENGTH(tags)];
unsigned int i; unsigned int i;
for(i = 0; i < LENGTH(tags); i++) for(i = 0; i < LENGTH(tags); i++)
@ -1838,7 +1838,7 @@ view(const char *arg) {
tmp[idxoftag(arg)] = True; tmp[idxoftag(arg)] = True;
if(memcmp(seltags, tmp, TAGSZ) != 0) { if(memcmp(seltags, tmp, TAGSZ) != 0) {
memcpy(prevtags, seltags, TAGSZ); seltags = viewtags[viewtags_set ^= 1]; /* toggle tagset */
memcpy(seltags, tmp, TAGSZ); memcpy(seltags, tmp, TAGSZ);
arrange(); arrange();
} }
@ -1846,10 +1846,7 @@ view(const char *arg) {
void void
viewprevtag(const char *arg) { viewprevtag(const char *arg) {
seltags = viewtags[viewtags_set ^= 1]; /* toggle tagset */
memcpy(tmp, seltags, TAGSZ);
memcpy(seltags, prevtags, TAGSZ);
memcpy(prevtags, tmp, TAGSZ);
arrange(); arrange();
} }

Loading…
Cancel
Save