diff -r 85a78d8afa0f dwm.c --- a/dwm.c Sun Feb 08 12:11:22 2009 +0000 +++ b/dwm.c Thu Feb 26 02:26:08 2009 -0500 @@ -60,6 +60,7 @@ enum { ColBorder, ColFG, ColBG, ColLast enum { ColBorder, ColFG, ColBG, ColLast }; /* color */ enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */ enum { WMProtocols, WMDelete, WMState, WMLast }; /* default atoms */ +enum { DWMTags, DWMLast }; /* DWM atoms */ enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, ClkRootWin, ClkLast }; /* clicks */ @@ -178,6 +179,7 @@ static void setclientstate(Client *c, lo static void setclientstate(Client *c, long state); static void setlayout(const Arg *arg); static void setmfact(const Arg *arg); +static void settagsprop(Window w, unsigned int tags); static void setup(void); static void showhide(Client *c, unsigned int ntiled); static void sigchld(int signal); @@ -227,7 +229,7 @@ static void (*handler[LASTEvent]) (XEven [PropertyNotify] = propertynotify, [UnmapNotify] = unmapnotify }; -static Atom wmatom[WMLast], netatom[NetLast]; +static Atom wmatom[WMLast], netatom[NetLast], dwmatom[DWMLast]; static Bool otherwm; static Bool running = True; static Client *clients = NULL; @@ -897,12 +899,20 @@ manage(Window w, XWindowAttributes *wa) XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask); grabbuttons(c, False); updatetitle(c); - if(XGetTransientForHint(dpy, w, &trans)) - t = getclient(trans); - if(t) - c->tags = t->tags; - else - applyrules(c); + XTextProperty prop; + applyrules(c); + if(XGetTextProperty(dpy, c->win, &prop, dwmatom[DWMTags])) { + c->tags = *(unsigned int *)prop.value; + XFree(prop.value); + } else { + if(XGetTransientForHint(dpy, w, &trans)) + t = getclient(trans); + if(t) + c->tags = t->tags; + } + if(!c->tags) + c->tags = tagset[seltags]; + settagsprop(c->win, c->tags); if(!c->isfloating) c->isfloating = trans != None || c->isfixed; if(c->isfloating) @@ -1244,6 +1254,17 @@ setclientstate(Client *c, long state) { } void +settagsprop(Window w, unsigned int tags) { + unsigned int v[1] = { tags }; + XTextProperty p; + p.value = (unsigned char *)v; + p.encoding = XA_CARDINAL; + p.format = 32; + p.nitems = LENGTH(v); + XSetTextProperty(dpy, w, &p, dwmatom[DWMTags]); +} + +void setlayout(const Arg *arg) { if(!arg || !arg->v || arg->v != lt[sellt]) sellt ^= 1; @@ -1294,6 +1315,7 @@ setup(void) { wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False); netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False); netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False); + dwmatom[DWMTags] = XInternAtom(dpy, "DWM_TAGS", False); /* init cursors */ wa.cursor = cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr); @@ -1386,6 +1408,7 @@ tag(const Arg *arg) { tag(const Arg *arg) { if(sel && arg->ui & TAGMASK) { sel->tags = arg->ui & TAGMASK; + settagsprop(sel->win, sel->tags); arrange(); } } @@ -1465,6 +1488,7 @@ toggletag(const Arg *arg) { mask = sel->tags ^ (arg->ui & TAGMASK); if(sel && mask) { sel->tags = mask; + settagsprop(sel->win, sel->tags); arrange(); } }