aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dwm.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/dwm.c b/dwm.c
index de4eefc..fb36ace 100644
--- a/dwm.c
+++ b/dwm.c
@@ -64,7 +64,7 @@ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
64enum { SchemeNorm, SchemeSel }; /* color schemes */ 64enum { SchemeNorm, SchemeSel }; /* color schemes */
65enum { NetSupported, NetWMName, NetWMState, NetWMCheck, 65enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
66 NetWMFullscreen, NetActiveWindow, NetWMWindowType, 66 NetWMFullscreen, NetActiveWindow, NetWMWindowType,
67 NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */ 67 NetWMWindowTypeDialog, NetClientList, NetClientInfo, NetLast }; /* EWMH atoms */
68enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */ 68enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
69enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, 69enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
70 ClkClientWin, ClkRootWin, ClkLast }; /* clicks */ 70 ClkClientWin, ClkRootWin, ClkLast }; /* clicks */
@@ -209,6 +209,7 @@ static void scan(void);
209static int sendevent(Client *c, Atom proto); 209static int sendevent(Client *c, Atom proto);
210static void sendmon(Client *c, Monitor *m); 210static void sendmon(Client *c, Monitor *m);
211static void setclientstate(Client *c, long state); 211static void setclientstate(Client *c, long state);
212static void setclienttagprop(Client *c);
212static void setfocus(Client *c); 213static void setfocus(Client *c);
213static void setfullscreen(Client *c, int fullscreen); 214static void setfullscreen(Client *c, int fullscreen);
214static void setlayout(const Arg *arg); 215static void setlayout(const Arg *arg);
@@ -1205,6 +1206,26 @@ manage(Window w, XWindowAttributes *wa)
1205 updatewindowtype(c); 1206 updatewindowtype(c);
1206 updatesizehints(c); 1207 updatesizehints(c);
1207 updatewmhints(c); 1208 updatewmhints(c);
1209 {
1210 int format;
1211 unsigned long *data, n, extra;
1212 Monitor *m;
1213 Atom atom;
1214 if (XGetWindowProperty(dpy, c->win, netatom[NetClientInfo], 0L, 2L, False, XA_CARDINAL,
1215 &atom, &format, &n, &extra, (unsigned char **)&data) == Success && n == 2) {
1216 c->tags = *data;
1217 for (m = mons; m; m = m->next) {
1218 if (m->num == *(data+1)) {
1219 c->mon = m;
1220 break;
1221 }
1222 }
1223 }
1224 if (n > 0)
1225 XFree(data);
1226 }
1227 setclienttagprop(c);
1228
1208 XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask); 1229 XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
1209 grabbuttons(c, 0); 1230 grabbuttons(c, 0);
1210 if (!c->isfloating) 1231 if (!c->isfloating)
@@ -1570,6 +1591,7 @@ sendmon(Client *c, Monitor *m)
1570 c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */ 1591 c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
1571 attach(c); 1592 attach(c);
1572 attachstack(c); 1593 attachstack(c);
1594 setclienttagprop(c);
1573 focus(NULL); 1595 focus(NULL);
1574 arrange(NULL); 1596 arrange(NULL);
1575} 1597}
@@ -1713,6 +1735,7 @@ setup(void)
1713 netatom[NetWMWindowType] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False); 1735 netatom[NetWMWindowType] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False);
1714 netatom[NetWMWindowTypeDialog] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False); 1736 netatom[NetWMWindowTypeDialog] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False);
1715 netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False); 1737 netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False);
1738 netatom[NetClientInfo] = XInternAtom(dpy, "_NET_CLIENT_INFO", False);
1716 /* init cursors */ 1739 /* init cursors */
1717 cursor[CurNormal] = drw_cur_create(drw, XC_left_ptr); 1740 cursor[CurNormal] = drw_cur_create(drw, XC_left_ptr);
1718 cursor[CurResize] = drw_cur_create(drw, XC_sizing); 1741 cursor[CurResize] = drw_cur_create(drw, XC_sizing);
@@ -1736,6 +1759,7 @@ setup(void)
1736 XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32, 1759 XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32,
1737 PropModeReplace, (unsigned char *) netatom, NetLast); 1760 PropModeReplace, (unsigned char *) netatom, NetLast);
1738 XDeleteProperty(dpy, root, netatom[NetClientList]); 1761 XDeleteProperty(dpy, root, netatom[NetClientList]);
1762 XDeleteProperty(dpy, root, netatom[NetClientInfo]);
1739 /* select events */ 1763 /* select events */
1740 wa.cursor = cursor[CurNormal]->cursor; 1764 wa.cursor = cursor[CurNormal]->cursor;
1741 wa.event_mask = SubstructureRedirectMask|SubstructureNotifyMask 1765 wa.event_mask = SubstructureRedirectMask|SubstructureNotifyMask
@@ -1816,10 +1840,21 @@ spawn(const Arg *arg)
1816} 1840}
1817 1841
1818void 1842void
1843setclienttagprop(Client *c)
1844{
1845 long data[] = { (long) c->tags, (long) c->mon->num };
1846 XChangeProperty(dpy, c->win, netatom[NetClientInfo], XA_CARDINAL, 32,
1847 PropModeReplace, (unsigned char *) data, 2);
1848}
1849
1850void
1819tag(const Arg *arg) 1851tag(const Arg *arg)
1820{ 1852{
1853 Client *c;
1821 if (selmon->sel && arg->ui & TAGMASK) { 1854 if (selmon->sel && arg->ui & TAGMASK) {
1855 c = selmon->sel;
1822 selmon->sel->tags = arg->ui & TAGMASK; 1856 selmon->sel->tags = arg->ui & TAGMASK;
1857 setclienttagprop(c);
1823 focus(NULL); 1858 focus(NULL);
1824 arrange(selmon); 1859 arrange(selmon);
1825 } 1860 }
@@ -1866,6 +1901,7 @@ toggletag(const Arg *arg)
1866 newtags = selmon->sel->tags ^ (arg->ui & TAGMASK); 1901 newtags = selmon->sel->tags ^ (arg->ui & TAGMASK);
1867 if (newtags) { 1902 if (newtags) {
1868 selmon->sel->tags = newtags; 1903 selmon->sel->tags = newtags;
1904 setclienttagprop(selmon->sel);
1869 focus(NULL); 1905 focus(NULL);
1870 arrange(selmon); 1906 arrange(selmon);
1871 } 1907 }