Mercurial > aewl
annotate view.c @ 396:be3be9590d5c
changed shortcut into Mod1-0
author | Anselm R. Garbe <arg@10kloc.org> |
---|---|
date | Thu, 31 Aug 2006 18:04:34 +0200 |
parents | 7528080beb0e |
children | cb8a231610c7 |
rev | line source |
---|---|
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
1 /* |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
3 * See LICENSE file for license details. |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
4 */ |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
5 #include "dwm.h" |
382 | 6 #include <stdio.h> |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
7 |
380
4bf79305d675
this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents:
378
diff
changeset
|
8 /* static */ |
4bf79305d675
this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents:
378
diff
changeset
|
9 |
382 | 10 static Client * |
11 minclient() | |
12 { | |
13 Client *c, *min; | |
14 | |
15 for(min = c = clients; c; c = c->next) | |
16 if(c->weight < min->weight) | |
17 min = c; | |
18 return min; | |
19 } | |
20 | |
21 | |
381
b00cc483d13b
still something wrong with reorder()
Anselm R. Garbe <arg@10kloc.org>
parents:
380
diff
changeset
|
22 static void |
b00cc483d13b
still something wrong with reorder()
Anselm R. Garbe <arg@10kloc.org>
parents:
380
diff
changeset
|
23 reorder() |
380
4bf79305d675
this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents:
378
diff
changeset
|
24 { |
382 | 25 Client *c, *newclients, *tail; |
381
b00cc483d13b
still something wrong with reorder()
Anselm R. Garbe <arg@10kloc.org>
parents:
380
diff
changeset
|
26 |
382 | 27 newclients = tail = NULL; |
28 while((c = minclient())) { | |
381
b00cc483d13b
still something wrong with reorder()
Anselm R. Garbe <arg@10kloc.org>
parents:
380
diff
changeset
|
29 detach(c); |
382 | 30 if(tail) { |
31 c->prev = tail; | |
32 tail->next = c; | |
33 tail = c; | |
381
b00cc483d13b
still something wrong with reorder()
Anselm R. Garbe <arg@10kloc.org>
parents:
380
diff
changeset
|
34 } |
b00cc483d13b
still something wrong with reorder()
Anselm R. Garbe <arg@10kloc.org>
parents:
380
diff
changeset
|
35 else |
382 | 36 tail = newclients = c; |
380
4bf79305d675
this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents:
378
diff
changeset
|
37 } |
382 | 38 clients = newclients; |
380
4bf79305d675
this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents:
378
diff
changeset
|
39 } |
4bf79305d675
this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents:
378
diff
changeset
|
40 |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
41 /* extern */ |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
42 |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
43 void (*arrange)(Arg *) = DEFMODE; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
44 |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
45 void |
378
83576f5f0a90
added attach/detach functions which don't attach at the begin of list, but at the slot of a first match of the tags of a client
Anselm R. Garbe <arg@10kloc.org>
parents:
342
diff
changeset
|
46 detach(Client *c) |
83576f5f0a90
added attach/detach functions which don't attach at the begin of list, but at the slot of a first match of the tags of a client
Anselm R. Garbe <arg@10kloc.org>
parents:
342
diff
changeset
|
47 { |
83576f5f0a90
added attach/detach functions which don't attach at the begin of list, but at the slot of a first match of the tags of a client
Anselm R. Garbe <arg@10kloc.org>
parents:
342
diff
changeset
|
48 if(c->prev) |
83576f5f0a90
added attach/detach functions which don't attach at the begin of list, but at the slot of a first match of the tags of a client
Anselm R. Garbe <arg@10kloc.org>
parents:
342
diff
changeset
|
49 c->prev->next = c->next; |
83576f5f0a90
added attach/detach functions which don't attach at the begin of list, but at the slot of a first match of the tags of a client
Anselm R. Garbe <arg@10kloc.org>
parents:
342
diff
changeset
|
50 if(c->next) |
83576f5f0a90
added attach/detach functions which don't attach at the begin of list, but at the slot of a first match of the tags of a client
Anselm R. Garbe <arg@10kloc.org>
parents:
342
diff
changeset
|
51 c->next->prev = c->prev; |
83576f5f0a90
added attach/detach functions which don't attach at the begin of list, but at the slot of a first match of the tags of a client
Anselm R. Garbe <arg@10kloc.org>
parents:
342
diff
changeset
|
52 if(c == clients) |
83576f5f0a90
added attach/detach functions which don't attach at the begin of list, but at the slot of a first match of the tags of a client
Anselm R. Garbe <arg@10kloc.org>
parents:
342
diff
changeset
|
53 clients = c->next; |
83576f5f0a90
added attach/detach functions which don't attach at the begin of list, but at the slot of a first match of the tags of a client
Anselm R. Garbe <arg@10kloc.org>
parents:
342
diff
changeset
|
54 c->next = c->prev = NULL; |
83576f5f0a90
added attach/detach functions which don't attach at the begin of list, but at the slot of a first match of the tags of a client
Anselm R. Garbe <arg@10kloc.org>
parents:
342
diff
changeset
|
55 } |
83576f5f0a90
added attach/detach functions which don't attach at the begin of list, but at the slot of a first match of the tags of a client
Anselm R. Garbe <arg@10kloc.org>
parents:
342
diff
changeset
|
56 |
83576f5f0a90
added attach/detach functions which don't attach at the begin of list, but at the slot of a first match of the tags of a client
Anselm R. Garbe <arg@10kloc.org>
parents:
342
diff
changeset
|
57 void |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
58 dofloat(Arg *arg) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
59 { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
60 Client *c; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
61 |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
62 for(c = clients; c; c = c->next) { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
63 c->ismax = False; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
64 if(isvisible(c)) { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
65 resize(c, True, TopLeft); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
66 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
67 else |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
68 ban(c); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
69 } |
393
6786cd59468f
applied sanders patch to remove unnecessary commit()
Anselm R. Garbe <arg@10kloc.org>
parents:
388
diff
changeset
|
70 if(!sel || !isvisible(sel)) |
6786cd59468f
applied sanders patch to remove unnecessary commit()
Anselm R. Garbe <arg@10kloc.org>
parents:
388
diff
changeset
|
71 sel = getnext(clients); |
6786cd59468f
applied sanders patch to remove unnecessary commit()
Anselm R. Garbe <arg@10kloc.org>
parents:
388
diff
changeset
|
72 if(sel) |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
73 focus(sel); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
74 else |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
75 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
76 restack(); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
77 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
78 |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
79 void |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
80 dotile(Arg *arg) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
81 { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
82 int h, i, n, w; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
83 Client *c; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
84 |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
85 w = sw - mw; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
86 for(n = 0, c = clients; c; c = c->next) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
87 if(isvisible(c) && !c->isfloat) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
88 n++; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
89 |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
90 if(n > 1) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
91 h = (sh - bh) / (n - 1); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
92 else |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
93 h = sh - bh; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
94 |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
95 for(i = 0, c = clients; c; c = c->next) { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
96 c->ismax = False; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
97 if(isvisible(c)) { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
98 if(c->isfloat) { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
99 resize(c, True, TopLeft); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
100 continue; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
101 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
102 if(n == 1) { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
103 c->x = sx; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
104 c->y = sy + bh; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
105 c->w = sw - 2; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
106 c->h = sh - 2 - bh; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
107 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
108 else if(i == 0) { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
109 c->x = sx; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
110 c->y = sy + bh; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
111 c->w = mw - 2; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
112 c->h = sh - 2 - bh; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
113 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
114 else if(h > bh) { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
115 c->x = sx + mw; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
116 c->y = sy + (i - 1) * h + bh; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
117 c->w = w - 2; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
118 if(i + 1 == n) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
119 c->h = sh - c->y - 2; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
120 else |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
121 c->h = h - 2; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
122 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
123 else { /* fallback if h < bh */ |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
124 c->x = sx + mw; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
125 c->y = sy + bh; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
126 c->w = w - 2; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
127 c->h = sh - 2 - bh; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
128 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
129 resize(c, False, TopLeft); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
130 i++; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
131 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
132 else |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
133 ban(c); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
134 } |
393
6786cd59468f
applied sanders patch to remove unnecessary commit()
Anselm R. Garbe <arg@10kloc.org>
parents:
388
diff
changeset
|
135 if(!sel || !isvisible(sel)) |
6786cd59468f
applied sanders patch to remove unnecessary commit()
Anselm R. Garbe <arg@10kloc.org>
parents:
388
diff
changeset
|
136 sel = getnext(clients); |
6786cd59468f
applied sanders patch to remove unnecessary commit()
Anselm R. Garbe <arg@10kloc.org>
parents:
388
diff
changeset
|
137 if(sel) |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
138 focus(sel); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
139 else |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
140 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
141 restack(); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
142 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
143 |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
144 void |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
145 focusnext(Arg *arg) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
146 { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
147 Client *c; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
148 |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
149 if(!sel) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
150 return; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
151 |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
152 if(!(c = getnext(sel->next))) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
153 c = getnext(clients); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
154 if(c) { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
155 focus(c); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
156 restack(); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
157 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
158 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
159 |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
160 void |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
161 focusprev(Arg *arg) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
162 { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
163 Client *c; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
164 |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
165 if(!sel) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
166 return; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
167 |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
168 if(!(c = getprev(sel->prev))) { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
169 for(c = clients; c && c->next; c = c->next); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
170 c = getprev(c); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
171 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
172 if(c) { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
173 focus(c); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
174 restack(); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
175 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
176 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
177 |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
178 Bool |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
179 isvisible(Client *c) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
180 { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
181 unsigned int i; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
182 |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
183 for(i = 0; i < ntags; i++) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
184 if(c->tags[i] && seltag[i]) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
185 return True; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
186 return False; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
187 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
188 |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
189 void |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
190 restack() |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
191 { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
192 static unsigned int nwins = 0; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
193 static Window *wins = NULL; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
194 unsigned int f, fi, m, mi, n; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
195 Client *c; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
196 XEvent ev; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
197 |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
198 for(f = 0, m = 0, c = clients; c; c = c->next) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
199 if(isvisible(c)) { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
200 if(c->isfloat || arrange == dofloat) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
201 f++; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
202 else |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
203 m++; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
204 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
205 if(!(n = 2 * (f + m))) { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
206 drawstatus(); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
207 return; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
208 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
209 if(nwins < n) { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
210 nwins = n; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
211 wins = erealloc(wins, nwins * sizeof(Window)); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
212 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
213 |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
214 fi = 0; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
215 mi = 2 * f; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
216 if(sel->isfloat || arrange == dofloat) { |
342 | 217 wins[fi++] = sel->twin; |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
218 wins[fi++] = sel->win; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
219 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
220 else { |
342 | 221 wins[mi++] = sel->twin; |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
222 wins[mi++] = sel->win; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
223 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
224 for(c = clients; c; c = c->next) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
225 if(isvisible(c) && c != sel) { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
226 if(c->isfloat || arrange == dofloat) { |
342 | 227 wins[fi++] = c->twin; |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
228 wins[fi++] = c->win; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
229 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
230 else { |
342 | 231 wins[mi++] = c->twin; |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
232 wins[mi++] = c->win; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
233 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
234 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
235 XRestackWindows(dpy, wins, n); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
236 drawall(); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
237 XSync(dpy, False); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
238 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
239 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
240 |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
241 void |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
242 togglemode(Arg *arg) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
243 { |
333
827f8f6c9e97
separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents:
327
diff
changeset
|
244 arrange = (arrange == dofloat) ? dotile : dofloat; |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
245 if(sel) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
246 arrange(NULL); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
247 else |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
248 drawstatus(); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
249 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
250 |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
251 void |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
252 toggleview(Arg *arg) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
253 { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
254 unsigned int i; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
255 |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
256 seltag[arg->i] = !seltag[arg->i]; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
257 for(i = 0; i < ntags && !seltag[i]; i++); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
258 if(i == ntags) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
259 seltag[arg->i] = True; /* cannot toggle last view */ |
381
b00cc483d13b
still something wrong with reorder()
Anselm R. Garbe <arg@10kloc.org>
parents:
380
diff
changeset
|
260 reorder(); |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
261 arrange(NULL); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
262 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
263 |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
264 void |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
265 view(Arg *arg) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
266 { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
267 unsigned int i; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
268 |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
269 for(i = 0; i < ntags; i++) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
270 seltag[i] = False; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
271 seltag[arg->i] = True; |
381
b00cc483d13b
still something wrong with reorder()
Anselm R. Garbe <arg@10kloc.org>
parents:
380
diff
changeset
|
272 reorder(); |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
273 arrange(NULL); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
274 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
275 |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
276 void |
395
7528080beb0e
added viewall to mainstream (only Ross Mohns version, not the toggle)
Anselm R. Garbe <arg@10kloc.org>
parents:
393
diff
changeset
|
277 viewall(Arg *arg) |
7528080beb0e
added viewall to mainstream (only Ross Mohns version, not the toggle)
Anselm R. Garbe <arg@10kloc.org>
parents:
393
diff
changeset
|
278 { |
7528080beb0e
added viewall to mainstream (only Ross Mohns version, not the toggle)
Anselm R. Garbe <arg@10kloc.org>
parents:
393
diff
changeset
|
279 unsigned int i; |
7528080beb0e
added viewall to mainstream (only Ross Mohns version, not the toggle)
Anselm R. Garbe <arg@10kloc.org>
parents:
393
diff
changeset
|
280 |
7528080beb0e
added viewall to mainstream (only Ross Mohns version, not the toggle)
Anselm R. Garbe <arg@10kloc.org>
parents:
393
diff
changeset
|
281 for(i = 0; i < ntags; i++) |
7528080beb0e
added viewall to mainstream (only Ross Mohns version, not the toggle)
Anselm R. Garbe <arg@10kloc.org>
parents:
393
diff
changeset
|
282 seltag[i] = True; |
7528080beb0e
added viewall to mainstream (only Ross Mohns version, not the toggle)
Anselm R. Garbe <arg@10kloc.org>
parents:
393
diff
changeset
|
283 arrange(NULL); |
7528080beb0e
added viewall to mainstream (only Ross Mohns version, not the toggle)
Anselm R. Garbe <arg@10kloc.org>
parents:
393
diff
changeset
|
284 } |
7528080beb0e
added viewall to mainstream (only Ross Mohns version, not the toggle)
Anselm R. Garbe <arg@10kloc.org>
parents:
393
diff
changeset
|
285 |
7528080beb0e
added viewall to mainstream (only Ross Mohns version, not the toggle)
Anselm R. Garbe <arg@10kloc.org>
parents:
393
diff
changeset
|
286 void |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
287 zoom(Arg *arg) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
288 { |
378
83576f5f0a90
added attach/detach functions which don't attach at the begin of list, but at the slot of a first match of the tags of a client
Anselm R. Garbe <arg@10kloc.org>
parents:
342
diff
changeset
|
289 Client *c = sel; |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
290 |
378
83576f5f0a90
added attach/detach functions which don't attach at the begin of list, but at the slot of a first match of the tags of a client
Anselm R. Garbe <arg@10kloc.org>
parents:
342
diff
changeset
|
291 if(!c || (arrange != dotile) || c->isfloat || c->ismax) |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
292 return; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
293 |
378
83576f5f0a90
added attach/detach functions which don't attach at the begin of list, but at the slot of a first match of the tags of a client
Anselm R. Garbe <arg@10kloc.org>
parents:
342
diff
changeset
|
294 if(c == getnext(clients)) |
83576f5f0a90
added attach/detach functions which don't attach at the begin of list, but at the slot of a first match of the tags of a client
Anselm R. Garbe <arg@10kloc.org>
parents:
342
diff
changeset
|
295 if(!(c = getnext(c->next))) |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
296 return; |
378
83576f5f0a90
added attach/detach functions which don't attach at the begin of list, but at the slot of a first match of the tags of a client
Anselm R. Garbe <arg@10kloc.org>
parents:
342
diff
changeset
|
297 detach(c); |
381
b00cc483d13b
still something wrong with reorder()
Anselm R. Garbe <arg@10kloc.org>
parents:
380
diff
changeset
|
298 c->next = clients; |
b00cc483d13b
still something wrong with reorder()
Anselm R. Garbe <arg@10kloc.org>
parents:
380
diff
changeset
|
299 clients->prev = c; |
b00cc483d13b
still something wrong with reorder()
Anselm R. Garbe <arg@10kloc.org>
parents:
380
diff
changeset
|
300 clients = c; |
378
83576f5f0a90
added attach/detach functions which don't attach at the begin of list, but at the slot of a first match of the tags of a client
Anselm R. Garbe <arg@10kloc.org>
parents:
342
diff
changeset
|
301 focus(c); |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
302 arrange(NULL); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
303 } |