summaryrefslogtreecommitdiffstats
path: root/tag.c
diff options
context:
space:
mode:
authorAnselm R. Garbe <arg@10kloc.org>2006-08-22 16:50:21 +0200
committerAnselm R. Garbe <arg@10kloc.org>2006-08-22 16:50:21 +0200
commitaa13727067af829b94461eb36aa029297ed8e6b9 (patch)
treeaaaae4d7d65711bfb5c2153b60fdb33990564e6b /tag.c
parentremoved DEFTAG (diff)
downloaddwm-aa13727067af829b94461eb36aa029297ed8e6b9.tar.gz
dwm-aa13727067af829b94461eb36aa029297ed8e6b9.zip
separated several functions into view.c
Diffstat (limited to 'tag.c')
-rw-r--r--tag.c186
1 files changed, 0 insertions, 186 deletions
diff --git a/tag.c b/tag.c
index cdb0f52..bc36f08 100644
--- a/tag.c
+++ b/tag.c
@@ -30,97 +30,8 @@ RULES
30static RReg *rreg = NULL; 30static RReg *rreg = NULL;
31static unsigned int len = 0; 31static unsigned int len = 0;
32 32
33void (*arrange)(Arg *) = DEFMODE;
34
35/* extern */ 33/* extern */
36 34
37void
38dofloat(Arg *arg)
39{
40 Client *c;
41
42 for(c = clients; c; c = c->next) {
43 c->ismax = False;
44 if(isvisible(c)) {
45 resize(c, True, TopLeft);
46 }
47 else
48 ban(c);
49 }
50 if(!sel || !isvisible(sel))
51 sel = getnext(clients);
52 if(sel)
53 focus(sel);
54 else
55 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
56 restack();
57}
58
59void
60dotile(Arg *arg)
61{
62 int h, i, n, w;
63 Client *c;
64
65 w = sw - mw;
66 for(n = 0, c = clients; c; c = c->next)
67 if(isvisible(c) && !c->isfloat)
68 n++;
69
70 if(n > 1)
71 h = (sh - bh) / (n - 1);
72 else
73 h = sh - bh;
74
75 for(i = 0, c = clients; c; c = c->next) {
76 c->ismax = False;
77 if(isvisible(c)) {
78 if(c->isfloat) {
79 resize(c, True, TopLeft);
80 continue;
81 }
82 if(n == 1) {
83 c->x = sx;
84 c->y = sy + bh;
85 c->w = sw - 2;
86 c->h = sh - 2 - bh;
87 }
88 else if(i == 0) {
89 c->x = sx;
90 c->y = sy + bh;
91 c->w = mw - 2;
92 c->h = sh - 2 - bh;
93 }
94 else if(h > bh) {
95 c->x = sx + mw;
96 c->y = sy + (i - 1) * h + bh;
97 c->w = w - 2;
98 if(i + 1 == n)
99 c->h = sh - c->y - 2;
100 else
101 c->h = h - 2;
102 }
103 else { /* fallback if h < bh */
104 c->x = sx + mw;
105 c->y = sy + bh;
106 c->w = w - 2;
107 c->h = sh - 2 - bh;
108 }
109 resize(c, False, TopLeft);
110 i++;
111 }
112 else
113 ban(c);
114 }
115 if(!sel || !isvisible(sel))
116 sel = getnext(clients);
117 if(sel)
118 focus(sel);
119 else
120 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
121 restack();
122}
123
124Client * 35Client *
125getnext(Client *c) 36getnext(Client *c)
126{ 37{
@@ -164,69 +75,6 @@ initrregs()
164 } 75 }
165} 76}
166 77
167Bool
168isvisible(Client *c)
169{
170 unsigned int i;
171
172 for(i = 0; i < ntags; i++)
173 if(c->tags[i] && seltag[i])
174 return True;
175 return False;
176}
177
178void
179restack()
180{
181 static unsigned int nwins = 0;
182 static Window *wins = NULL;
183 unsigned int f, fi, m, mi, n;
184 Client *c;
185 XEvent ev;
186
187 for(f = 0, m = 0, c = clients; c; c = c->next)
188 if(isvisible(c)) {
189 if(c->isfloat || arrange == dofloat)
190 f++;
191 else
192 m++;
193 }
194 if(!(n = 2 * (f + m))) {
195 drawstatus();
196 return;
197 }
198 if(nwins < n) {
199 nwins = n;
200 wins = erealloc(wins, nwins * sizeof(Window));
201 }
202
203 fi = 0;
204 mi = 2 * f;
205 if(sel->isfloat || arrange == dofloat) {
206 wins[fi++] = sel->title;
207 wins[fi++] = sel->win;
208 }
209 else {
210 wins[mi++] = sel->title;
211 wins[mi++] = sel->win;
212 }
213 for(c = clients; c; c = c->next)
214 if(isvisible(c) && c != sel) {
215 if(c->isfloat || arrange == dofloat) {
216 wins[fi++] = c->title;
217 wins[fi++] = c->win;
218 }
219 else {
220 wins[mi++] = c->title;
221 wins[mi++] = c->win;
222 }
223 }
224 XRestackWindows(dpy, wins, n);
225 drawall();
226 XSync(dpy, False);
227 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
228}
229
230void 78void
231settags(Client *c) 79settags(Client *c)
232{ 80{
@@ -277,16 +125,6 @@ tag(Arg *arg)
277} 125}
278 126
279void 127void
280togglemode(Arg *arg)
281{
282 arrange = arrange == dofloat ? dotile : dofloat;
283 if(sel)
284 arrange(NULL);
285 else
286 drawstatus();
287}
288
289void
290toggletag(Arg *arg) 128toggletag(Arg *arg)
291{ 129{
292 unsigned int i; 130 unsigned int i;
@@ -302,27 +140,3 @@ toggletag(Arg *arg)
302 if(!isvisible(sel)) 140 if(!isvisible(sel))
303 arrange(NULL); 141 arrange(NULL);
304} 142}
305
306
307void
308toggleview(Arg *arg)
309{
310 unsigned int i;
311
312 seltag[arg->i] = !seltag[arg->i];
313 for(i = 0; i < ntags && !seltag[i]; i++);
314 if(i == ntags)
315 seltag[arg->i] = True; /* cannot toggle last view */
316 arrange(NULL);
317}
318
319void
320view(Arg *arg)
321{
322 unsigned int i;
323
324 for(i = 0; i < ntags; i++)
325 seltag[i] = False;
326 seltag[arg->i] = True;
327 arrange(NULL);
328}