Skip to content

Commit 7d06d03

Browse files
committed
updated preserve on restart
1 parent cbbe83b commit 7d06d03

File tree

1 file changed

+48
-31
lines changed

1 file changed

+48
-31
lines changed

patches/dwm-6.3-patches/dwm-preserveonrestart-6.3.diff

Lines changed: 48 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Subject: [PATCH] preserve clients on old tags when renewing dwm
88
1 file changed, 37 insertions(+), 1 deletion(-)
99

1010
diff --git a/dwm.c b/dwm.c
11-
index a96f33c..a12e0bd 100644
11+
index 03baf42..b11eabc 100644
1212
--- a/dwm.c
1313
+++ b/dwm.c
1414
@@ -62,7 +62,7 @@ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
@@ -28,61 +28,81 @@ index a96f33c..a12e0bd 100644
2828
static void setfocus(Client *c);
2929
static void setfullscreen(Client *c, int fullscreen);
3030
static void setlayout(const Arg *arg);
31-
@@ -1060,6 +1061,26 @@ manage(Window w, XWindowAttributes *wa)
32-
updatewindowtype(c);
33-
updatesizehints(c);
34-
updatewmhints(c);
35-
+ {
36-
+ int format;
37-
+ unsigned long *data, n, extra;
38-
+ Monitor *m;
39-
+ Atom atom;
40-
+ if (XGetWindowProperty(dpy, c->win, netatom[NetClientInfo], 0L, 2L, False, XA_CARDINAL,
41-
+ &atom, &format, &n, &extra, (unsigned char **)&data) == Success && n == 2) {
42-
+ c->tags = *data;
43-
+ for (m = mons; m; m = m->next) {
44-
+ if (m->num == *(data+1)) {
45-
+ c->mon = m;
46-
+ break;
47-
+ }
31+
@@ -1049,9 +1050,35 @@ manage(Window w, XWindowAttributes *wa)
32+
if (XGetTransientForHint(dpy, w, &trans) && (t = wintoclient(trans))) {
33+
c->mon = t->mon;
34+
c->tags = t->tags;
35+
+ updatewindowtype(c);
36+
} else {
37+
c->mon = selmon;
38+
applyrules(c);
39+
+ updatewindowtype(c);
40+
+ {
41+
+ int format;
42+
+ unsigned long *data, n, extra;
43+
+ Monitor *m;
44+
+ Atom atom;
45+
+
46+
+ if (XGetWindowProperty(dpy, c->win, netatom[NetClientInfo], 0L, 2L, False, XA_CARDINAL,
47+
+ &atom, &format, &n, &extra, (unsigned char **)&data) == Success && n == 2)
48+
+ {
49+
+ c->tags = *data;
50+
+
51+
+ for (m = mons; m; m = m->next)
52+
+ {
53+
+ if (m->num == *(data+1))
54+
+ {
55+
+ c->mon = m;
56+
+ break;
57+
+ }
58+
+ }
4859
+ }
60+
+ if (n > 0)
61+
+ XFree(data);
4962
+ }
50-
+ if (n > 0)
51-
+ XFree(data);
52-
+ }
53-
+ setclienttagprop(c);
63+
+ setclienttagprop(c);
64+
}
65+
66+
if (c->x + WIDTH(c) > c->mon->wx + c->mon->ww)
67+
@@ -1066,9 +1093,9 @@ manage(Window w, XWindowAttributes *wa)
68+
XConfigureWindow(dpy, w, CWBorderWidth, &wc);
69+
XSetWindowBorder(dpy, w, scheme[SchemeNorm][ColBorder].pixel);
70+
configure(c); /* propagates border_width, if size doesn't change */
71+
- updatewindowtype(c);
72+
updatesizehints(c);
73+
updatewmhints(c);
5474
+
5575
XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
5676
grabbuttons(c, 0);
5777
if (!c->isfloating)
58-
@@ -1423,6 +1444,7 @@ sendmon(Client *c, Monitor *m)
78+
@@ -1430,6 +1457,7 @@ sendmon(Client *c, Monitor *m)
5979
c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
6080
attach(c);
6181
attachstack(c);
6282
+ setclienttagprop(c);
6383
focus(NULL);
6484
arrange(NULL);
6585
}
66-
@@ -1566,6 +1588,7 @@ setup(void)
86+
@@ -1573,6 +1601,7 @@ setup(void)
6787
netatom[NetWMWindowType] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False);
6888
netatom[NetWMWindowTypeDialog] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False);
6989
netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False);
7090
+ netatom[NetClientInfo] = XInternAtom(dpy, "_NET_CLIENT_INFO", False);
7191
/* init cursors */
7292
cursor[CurNormal] = drw_cur_create(drw, XC_left_ptr);
7393
cursor[CurResize] = drw_cur_create(drw, XC_sizing);
74-
@@ -1589,6 +1612,7 @@ setup(void)
94+
@@ -1596,6 +1625,7 @@ setup(void)
7595
XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32,
7696
PropModeReplace, (unsigned char *) netatom, NetLast);
7797
XDeleteProperty(dpy, root, netatom[NetClientList]);
7898
+ XDeleteProperty(dpy, root, netatom[NetClientInfo]);
7999
/* select events */
80100
wa.cursor = cursor[CurNormal]->cursor;
81101
wa.event_mask = SubstructureRedirectMask|SubstructureNotifyMask
82-
@@ -1656,11 +1680,22 @@ spawn(const Arg *arg)
102+
@@ -1660,11 +1690,22 @@ spawn(const Arg *arg)
83103
}
84104
}
85-
105+
86106
+void
87107
+setclienttagprop(Client *c)
88108
+{
@@ -102,14 +122,11 @@ index a96f33c..a12e0bd 100644
102122
focus(NULL);
103123
arrange(selmon);
104124
}
105-
@@ -1735,6 +1770,7 @@ toggletag(const Arg *arg)
125+
@@ -1739,6 +1780,7 @@ toggletag(const Arg *arg)
106126
newtags = selmon->sel->tags ^ (arg->ui & TAGMASK);
107127
if (newtags) {
108128
selmon->sel->tags = newtags;
109129
+ setclienttagprop(selmon->sel);
110130
focus(NULL);
111131
arrange(selmon);
112132
}
113-
--
114-
2.36.1
115-

0 commit comments

Comments
 (0)