Save client tags and monitors only on restart
This commit is contained in:
parent
18cc871a2a
commit
9cbc6bfeb9
49
dwm.c
49
dwm.c
@ -77,7 +77,7 @@ enum { SchemeNorm, SchemeSel, SchemeStatus, SchemeTagsSel, SchemeTagsNorm, Schem
|
|||||||
enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
|
enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
|
||||||
NetSystemTray, NetSystemTrayOP, NetSystemTrayOrientation, NetSystemTrayOrientationHorz,
|
NetSystemTray, NetSystemTrayOP, NetSystemTrayOrientation, NetSystemTrayOrientationHorz,
|
||||||
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
|
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
|
||||||
NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
|
NetWMWindowTypeDialog, NetClientList, NetClientInfo, NetLast }; /* EWMH atoms */
|
||||||
enum { Manager, Xembed, XembedInfo, XLast }; /* Xembed atoms */
|
enum { Manager, Xembed, XembedInfo, XLast }; /* Xembed atoms */
|
||||||
enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
|
enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
|
||||||
enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
|
enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
|
||||||
@ -220,6 +220,7 @@ static void resizeclient(Client *c, int x, int y, int w, int h);
|
|||||||
static void resizemouse(const Arg *arg);
|
static void resizemouse(const Arg *arg);
|
||||||
static void resizerequest(XEvent *e);
|
static void resizerequest(XEvent *e);
|
||||||
static void restack(Monitor *m);
|
static void restack(Monitor *m);
|
||||||
|
static void restart(const Arg *arg);
|
||||||
static void run(void);
|
static void run(void);
|
||||||
static void scan(void);
|
static void scan(void);
|
||||||
static int sendevent(Window w, Atom proto, int m, long d0, long d1, long d2, long d3, long d4);
|
static int sendevent(Window w, Atom proto, int m, long d0, long d1, long d2, long d3, long d4);
|
||||||
@ -268,7 +269,6 @@ static int xerror(Display *dpy, XErrorEvent *ee);
|
|||||||
static int xerrordummy(Display *dpy, XErrorEvent *ee);
|
static int xerrordummy(Display *dpy, XErrorEvent *ee);
|
||||||
static int xerrorstart(Display *dpy, XErrorEvent *ee);
|
static int xerrorstart(Display *dpy, XErrorEvent *ee);
|
||||||
static void zoom(const Arg *arg);
|
static void zoom(const Arg *arg);
|
||||||
static void restart(const Arg *arg);
|
|
||||||
|
|
||||||
/* variables */
|
/* variables */
|
||||||
static const char *exec_name;
|
static const char *exec_name;
|
||||||
@ -1188,6 +1188,26 @@ manage(Window w, XWindowAttributes *wa)
|
|||||||
updatewindowtype(c);
|
updatewindowtype(c);
|
||||||
updatesizehints(c);
|
updatesizehints(c);
|
||||||
updatewmhints(c);
|
updatewmhints(c);
|
||||||
|
{
|
||||||
|
int format;
|
||||||
|
unsigned long *data, n, extra;
|
||||||
|
Monitor *m;
|
||||||
|
Atom atom;
|
||||||
|
if (XGetWindowProperty(dpy, c->win, netatom[NetClientInfo], 0L, 2L, False, XA_CARDINAL,
|
||||||
|
&atom, &format, &n, &extra, (unsigned char **)&data) == Success && n == 2) {
|
||||||
|
c->tags = *data;
|
||||||
|
for (m = mons; m; m = m->next) {
|
||||||
|
if (m->num == *(data+1)) {
|
||||||
|
c->mon = m;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* remove the property */
|
||||||
|
XDeleteProperty(dpy, c->win, netatom[NetClientInfo]);
|
||||||
|
}
|
||||||
|
if (n > 0)
|
||||||
|
XFree(data);
|
||||||
|
}
|
||||||
XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
|
XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
|
||||||
grabbuttons(c, 0);
|
grabbuttons(c, 0);
|
||||||
if (!c->isfloating)
|
if (!c->isfloating)
|
||||||
@ -1562,6 +1582,25 @@ restack(Monitor *m)
|
|||||||
while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
restart(const Arg *arg)
|
||||||
|
{
|
||||||
|
Monitor *m;
|
||||||
|
Client *c;
|
||||||
|
|
||||||
|
/* tag each client so we can restart with it on the correct tag*/
|
||||||
|
for (m = mons; m; m = m->next) {
|
||||||
|
for (c = m->clients; c; c = c->next) {
|
||||||
|
long data[] = { (long) c->tags, (long) c->mon->num };
|
||||||
|
XChangeProperty(dpy, c->win, netatom[NetClientInfo], XA_CARDINAL, 32,
|
||||||
|
PropModeReplace, (unsigned char *) data, 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
XFlush(dpy);
|
||||||
|
|
||||||
|
execlp(exec_name, exec_name, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
run(void)
|
run(void)
|
||||||
{
|
{
|
||||||
@ -1787,6 +1826,7 @@ setup(void)
|
|||||||
netatom[NetWMWindowType] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False);
|
netatom[NetWMWindowType] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False);
|
||||||
netatom[NetWMWindowTypeDialog] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False);
|
netatom[NetWMWindowTypeDialog] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False);
|
||||||
netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False);
|
netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False);
|
||||||
|
netatom[NetClientInfo] = XInternAtom(dpy, "_NET_CLIENT_INFO", False);
|
||||||
xatom[Manager] = XInternAtom(dpy, "MANAGER", False);
|
xatom[Manager] = XInternAtom(dpy, "MANAGER", False);
|
||||||
xatom[Xembed] = XInternAtom(dpy, "_XEMBED", False);
|
xatom[Xembed] = XInternAtom(dpy, "_XEMBED", False);
|
||||||
xatom[XembedInfo] = XInternAtom(dpy, "_XEMBED_INFO", False);
|
xatom[XembedInfo] = XInternAtom(dpy, "_XEMBED_INFO", False);
|
||||||
@ -2553,11 +2593,6 @@ zoom(const Arg *arg)
|
|||||||
pop(c);
|
pop(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
restart(const Arg *arg) {
|
|
||||||
execlp(exec_name, exec_name, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user