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