@@ -8,7 +8,7 @@ Subject: [PATCH] preserve clients on old tags when renewing dwm
8
8
1 file changed, 37 insertions(+), 1 deletion(-)
9
9
10
10
diff --git a/dwm.c b/dwm.c
11
- index a96f33c..a12e0bd 100644
11
+ index 03baf42..b11eabc 100644
12
12
--- a/dwm.c
13
13
+++ b/dwm.c
14
14
@@ -62,7 +62,7 @@ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
@@ -28,61 +28,81 @@ index a96f33c..a12e0bd 100644
28
28
static void setfocus(Client *c);
29
29
static void setfullscreen(Client *c, int fullscreen);
30
30
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
+ + }
48
59
+ }
60
+ + if (n > 0)
61
+ + XFree(data);
49
62
+ }
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);
54
74
+
55
75
XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
56
76
grabbuttons(c, 0);
57
77
if (!c->isfloating)
58
- @@ -1423 ,6 +1444 ,7 @@ sendmon(Client *c, Monitor *m)
78
+ @@ -1430 ,6 +1457 ,7 @@ sendmon(Client *c, Monitor *m)
59
79
c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
60
80
attach(c);
61
81
attachstack(c);
62
82
+ setclienttagprop(c);
63
83
focus(NULL);
64
84
arrange(NULL);
65
85
}
66
- @@ -1566 ,6 +1588 ,7 @@ setup(void)
86
+ @@ -1573 ,6 +1601 ,7 @@ setup(void)
67
87
netatom[NetWMWindowType] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False);
68
88
netatom[NetWMWindowTypeDialog] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False);
69
89
netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False);
70
90
+ netatom[NetClientInfo] = XInternAtom(dpy, "_NET_CLIENT_INFO", False);
71
91
/* init cursors */
72
92
cursor[CurNormal] = drw_cur_create(drw, XC_left_ptr);
73
93
cursor[CurResize] = drw_cur_create(drw, XC_sizing);
74
- @@ -1589 ,6 +1612 ,7 @@ setup(void)
94
+ @@ -1596 ,6 +1625 ,7 @@ setup(void)
75
95
XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32,
76
96
PropModeReplace, (unsigned char *) netatom, NetLast);
77
97
XDeleteProperty(dpy, root, netatom[NetClientList]);
78
98
+ XDeleteProperty(dpy, root, netatom[NetClientInfo]);
79
99
/* select events */
80
100
wa.cursor = cursor[CurNormal]->cursor;
81
101
wa.event_mask = SubstructureRedirectMask|SubstructureNotifyMask
82
- @@ -1656 ,11 +1680 ,22 @@ spawn(const Arg *arg)
102
+ @@ -1660 ,11 +1690 ,22 @@ spawn(const Arg *arg)
83
103
}
84
104
}
85
-
105
+
86
106
+ void
87
107
+ setclienttagprop(Client *c)
88
108
+ {
@@ -102,14 +122,11 @@ index a96f33c..a12e0bd 100644
102
122
focus(NULL);
103
123
arrange(selmon);
104
124
}
105
- @@ -1735 ,6 +1770 ,7 @@ toggletag(const Arg *arg)
125
+ @@ -1739 ,6 +1780 ,7 @@ toggletag(const Arg *arg)
106
126
newtags = selmon->sel->tags ^ (arg->ui & TAGMASK);
107
127
if (newtags) {
108
128
selmon->sel->tags = newtags;
109
129
+ setclienttagprop(selmon->sel);
110
130
focus(NULL);
111
131
arrange(selmon);
112
132
}
113
- - -
114
- 2.36.1
115
-
0 commit comments