applied yiyus tagset patch

pull/1/head
Anselm R Garbe 17 years ago
parent 7f70d90219
commit bfd6079a15
  1. 37
      dwm.c

37
dwm.c

@ -214,7 +214,7 @@ char stext[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; int seltags = 0;
double mfact; double mfact;
unsigned int numlockmask = 0; unsigned int numlockmask = 0;
void (*handler[LASTEvent]) (XEvent *) = { void (*handler[LASTEvent]) (XEvent *) = {
@ -234,8 +234,7 @@ 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 *seltags; Bool *tagset[2];
Bool *viewtags[2];
Client *clients = NULL; Client *clients = NULL;
Client *sel = NULL; Client *sel = NULL;
Client *stack = NULL; Client *stack = NULL;
@ -278,7 +277,7 @@ applyrules(Client *c) {
if(ch.res_name) if(ch.res_name)
XFree(ch.res_name); XFree(ch.res_name);
if(!matched) if(!matched)
memcpy(c->tags, seltags, TAGSZ); memcpy(c->tags, tagset[seltags], TAGSZ);
} }
void void
@ -538,7 +537,7 @@ drawbar(void) {
for(c = stack; c && !isvisible(c); c = c->snext); for(c = stack; c && !isvisible(c); c = c->snext);
for(i = 0; i < LENGTH(tags); i++) { for(i = 0; i < LENGTH(tags); i++) {
dc.w = textw(tags[i]); dc.w = textw(tags[i]);
if(seltags[i]) { if(tagset[seltags][i]) {
drawtext(tags[i], dc.sel, isurgent(i)); drawtext(tags[i], dc.sel, isurgent(i));
drawsquare(c && c->tags[i], isoccupied(i), isurgent(i), dc.sel); drawsquare(c && c->tags[i], isoccupied(i), isurgent(i), dc.sel);
} }
@ -933,7 +932,7 @@ isvisible(Client *c) {
unsigned int i; unsigned int i;
for(i = 0; i < LENGTH(tags); i++) for(i = 0; i < LENGTH(tags); i++)
if(c->tags[i] && seltags[i]) if(c->tags[i] && tagset[seltags][i])
return True; return True;
return False; return False;
} }
@ -1505,10 +1504,9 @@ setup(void) {
XSetFont(dpy, dc.gc, dc.font.xfont->fid); XSetFont(dpy, dc.gc, dc.font.xfont->fid);
/* init tags */ /* init tags */
viewtags[0] = emallocz(TAGSZ); tagset[0] = emallocz(TAGSZ);
viewtags[1] = emallocz(TAGSZ); tagset[1] = emallocz(TAGSZ);
viewtags[0][0] = viewtags[1][0] = True; tagset[0][0] = tagset[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++) {
@ -1701,10 +1699,10 @@ toggleview(const char *arg) {
unsigned int i, j; unsigned int i, j;
i = idxoftag(arg); i = idxoftag(arg);
seltags[i] = !seltags[i]; tagset[seltags][i] = !tagset[seltags][i];
for(j = 0; j < LENGTH(tags) && !seltags[j]; j++); for(j = 0; j < LENGTH(tags) && !tagset[seltags][j]; j++);
if(j == LENGTH(tags)) if(j == LENGTH(tags))
seltags[i] = True; /* at least one tag must be viewed */ tagset[seltags][i] = True; /* at least one tag must be viewed */
arrange(); arrange();
} }
@ -1837,18 +1835,15 @@ view(const char *arg) {
tmp[i] = (NULL == arg); tmp[i] = (NULL == arg);
tmp[idxoftag(arg)] = True; tmp[idxoftag(arg)] = True;
if(memcmp(seltags, tmp, TAGSZ) != 0) { seltags ^= 1; /* toggle sel tagset */
seltags = viewtags[viewtags_set ^= 1]; /* toggle tagset */ if(memcmp(tagset[seltags ^ 1], tmp, TAGSZ) != 0)
memcpy(seltags, tmp, TAGSZ); memcpy(tagset[seltags], tmp, TAGSZ);
arrange(); arrange();
}
else
viewprevtag(NULL);
} }
void void
viewprevtag(const char *arg) { viewprevtag(const char *arg) {
seltags = viewtags[viewtags_set ^= 1]; /* toggle tagset */ seltags ^= 1; /* toggle sel tagset */
arrange(); arrange();
} }

Loading…
Cancel
Save