-
Notifications
You must be signed in to change notification settings - Fork 0
/
dwm-5.8.2-pertag.diff
180 lines (170 loc) · 4.77 KB
/
dwm-5.8.2-pertag.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
diff --git a/dwm.c b/dwm.c
--- a/dwm.c
+++ b/dwm.c
@@ -122,26 +122,6 @@ typedef struct {
void (*arrange)(Monitor *);
} Layout;
-struct Monitor {
- char ltsymbol[16];
- float mfact;
- int num;
- int by; /* bar geometry */
- int mx, my, mw, mh; /* screen size */
- int wx, wy, ww, wh; /* window area */
- unsigned int seltags;
- unsigned int sellt;
- unsigned int tagset[2];
- Bool showbar;
- Bool topbar;
- Client *clients;
- Client *sel;
- Client *stack;
- Monitor *next;
- Window barwin;
- const Layout *lt[2];
-};
-
typedef struct {
const char *class;
const char *instance;
@@ -278,6 +258,31 @@ static Window root;
/* configuration, allows nested code to access above variables */
#include "config.h"
+struct Monitor {
+ char ltsymbol[16];
+ float mfact;
+ int num;
+ int by; /* bar geometry */
+ int mx, my, mw, mh; /* screen size */
+ int wx, wy, ww, wh; /* window area */
+ unsigned int seltags;
+ unsigned int sellt;
+ unsigned int tagset[2];
+ Bool showbar;
+ Bool topbar;
+ Client *clients;
+ Client *sel;
+ Client *stack;
+ Monitor *next;
+ Window barwin;
+ const Layout *lt[2];
+ int curtag;
+ int prevtag;
+ const Layout *lts[LENGTH(tags) + 1];
+ double mfacts[LENGTH(tags) + 1];
+ Bool showbars[LENGTH(tags) + 1];
+};
+
/* compile-time check if all tags fit into an unsigned int bit array. */
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
@@ -609,6 +614,7 @@ configurerequest(XEvent *e) {
Monitor *
createmon(void) {
Monitor *m;
+ unsigned int i;
if(!(m = (Monitor *)calloc(1, sizeof(Monitor))))
die("fatal: could not malloc() %u bytes\n", sizeof(Monitor));
@@ -619,6 +625,15 @@ createmon(void) {
m->lt[0] = &layouts[0];
m->lt[1] = &layouts[1 % LENGTH(layouts)];
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
+
+ /* pertag init */
+ m->curtag = m->prevtag = 1;
+ for(i=0; i < LENGTH(tags) + 1 ; i++) {
+ m->mfacts[i] = mfact;
+ m->lts[i] = &layouts[0];
+ m->showbars[i] = m->showbar;
+ }
+
return m;
}
@@ -1486,7 +1501,7 @@ setlayout(const Arg *arg) {
if(!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
selmon->sellt ^= 1;
if(arg && arg->v)
- selmon->lt[selmon->sellt] = (Layout *)arg->v;
+ selmon->lt[selmon->sellt] = selmon->lts[selmon->curtag] = (Layout *)arg->v;
strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol);
if(selmon->sel)
arrange(selmon);
@@ -1504,7 +1519,7 @@ setmfact(const Arg *arg) {
f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0;
if(f < 0.1 || f > 0.9)
return;
- selmon->mfact = f;
+ selmon->mfact = selmon->mfacts[selmon->curtag] = f;
arrange(selmon);
}
@@ -1547,7 +1562,6 @@ setup(void) {
XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
if(!dc.font.set)
XSetFont(dpy, dc.gc, dc.font.xfont->fid);
- /* init bars */
updatebars();
updatestatus();
/* EWMH support per view */
@@ -1658,7 +1672,7 @@ tile(Monitor *m) {
void
togglebar(const Arg *arg) {
- selmon->showbar = !selmon->showbar;
+ selmon->showbar = selmon->showbars[selmon->curtag] = !selmon->showbar;
updatebarpos(selmon);
XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
arrange(selmon);
@@ -1678,12 +1692,27 @@ togglefloating(const Arg *arg) {
void
toggletag(const Arg *arg) {
unsigned int newtags;
+ unsigned int i;
if(!selmon->sel)
return;
newtags = selmon->sel->tags ^ (arg->ui & TAGMASK);
if(newtags) {
selmon->sel->tags = newtags;
+ if(newtags == ~0) {
+ selmon->prevtag = selmon->curtag;
+ selmon->curtag = 0;
+ }
+ if(!(newtags & 1 << (selmon->curtag - 1))) {
+ selmon->prevtag = selmon->curtag;
+ for (i=0; !(newtags & 1 << i); i++);
+ selmon->curtag = i + 1;
+ }
+ selmon->sel->tags = newtags;
+ selmon->lt[selmon->sellt] = selmon->lts[selmon->curtag];
+ selmon->mfact = selmon->mfacts[selmon->curtag];
+ if (selmon->showbar != selmon->showbars[selmon->curtag])
+ togglebar(NULL);
arrange(selmon);
}
}
@@ -1950,11 +1979,29 @@ updatewmhints(Client *c) {
void
view(const Arg *arg) {
+ unsigned int i;
+
if((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
return;
selmon->seltags ^= 1; /* toggle sel tagset */
- if(arg->ui & TAGMASK)
+ if(arg->ui & TAGMASK) {
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
+ selmon->prevtag = selmon->curtag;
+ if(arg->ui == ~0)
+ selmon->curtag = 0;
+ else {
+ for (i=0; !(arg->ui & 1 << i); i++);
+ selmon->curtag = i + 1;
+ }
+ } else {
+ selmon->prevtag= selmon->curtag ^ selmon->prevtag;
+ selmon->curtag^= selmon->prevtag;
+ selmon->prevtag= selmon->curtag ^ selmon->prevtag;
+ }
+ selmon->lt[selmon->sellt]= selmon->lts[selmon->curtag];
+ selmon->mfact = selmon->mfacts[selmon->curtag];
+ if(selmon->showbar != selmon->showbars[selmon->curtag])
+ togglebar(NULL);
arrange(selmon);
}