# HG changeset patch # Parent 3b5f9910413a84c53905b237e5fbf0728bb1081c diff -r 3b5f9910413a dwm.c --- a/dwm.c Wed Oct 27 15:43:16 2010 +0200 +++ b/dwm.c Wed Oct 27 15:46:10 2010 +0200 @@ -275,6 +275,7 @@ static Monitor *mons = NULL, *selmon = NULL; static Window root; static char **args; +static Atom dwmatom_tags; /* configuration, allows nested code to access above variables */ #include "config.h" @@ -1104,8 +1105,15 @@ c->tags = t->tags; } else { + Atom atom; int format; unsigned long n, extra; unsigned int *ptags; c->mon = selmon; - applyrules(c); + if(XGetWindowProperty(dpy, w, dwmatom_tags, 0L, 1L, False, XA_CARDINAL, + &atom, &format, &n, &extra, (unsigned char **)&ptags)==Success && n==1 && *ptags!=0) + c->tags = *ptags; /* override rule tags with memorized tags */ + else { + applyrules(c); + XChangeProperty(dpy, w, dwmatom_tags, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&c->tags, 1); + } } /* geometry */ c->x = c->oldx = wa->x + c->mon->wx; @@ -1534,6 +1542,7 @@ netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False); netatom[NetWMState] = XInternAtom(dpy, "_NET_WM_STATE", False); netatom[NetWMFullscreen] = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False); + dwmatom_tags = XInternAtom(dpy, "DWM_TAGS", False); /* init cursors */ cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr); cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing); @@ -1607,6 +1616,7 @@ tag(const Arg *arg) { if(selmon->sel && arg->ui & TAGMASK) { selmon->sel->tags = arg->ui & TAGMASK; + XChangeProperty(dpy, selmon->sel->win, dwmatom_tags, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&selmon->sel->tags, 1); arrange(selmon); } } @@ -1687,6 +1697,7 @@ newtags = selmon->sel->tags ^ (arg->ui & TAGMASK); if(newtags) { selmon->sel->tags = newtags; + XChangeProperty(dpy, selmon->sel->win, dwmatom_tags, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&selmon->sel->tags, 1); arrange(selmon); } }