Mercurial > aewl
annotate view.c @ 381:b00cc483d13b
still something wrong with reorder()
author | Anselm R. Garbe <arg@10kloc.org> |
---|---|
date | Tue, 29 Aug 2006 13:40:09 +0200 |
parents | 4bf79305d675 |
children | 76b62c0c8c11 |
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" |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
6 |
380
4bf79305d675
this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents:
378
diff
changeset
|
7 /* static */ |
4bf79305d675
this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents:
378
diff
changeset
|
8 |
381
b00cc483d13b
still something wrong with reorder()
Anselm R. Garbe <arg@10kloc.org>
parents:
380
diff
changeset
|
9 static void |
b00cc483d13b
still something wrong with reorder()
Anselm R. Garbe <arg@10kloc.org>
parents:
380
diff
changeset
|
10 reorder() |
380
4bf79305d675
this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents:
378
diff
changeset
|
11 { |
381
b00cc483d13b
still something wrong with reorder()
Anselm R. Garbe <arg@10kloc.org>
parents:
380
diff
changeset
|
12 Client *c, *orig, *p; |
b00cc483d13b
still something wrong with reorder()
Anselm R. Garbe <arg@10kloc.org>
parents:
380
diff
changeset
|
13 |
b00cc483d13b
still something wrong with reorder()
Anselm R. Garbe <arg@10kloc.org>
parents:
380
diff
changeset
|
14 orig = clients; |
b00cc483d13b
still something wrong with reorder()
Anselm R. Garbe <arg@10kloc.org>
parents:
380
diff
changeset
|
15 clients = NULL; |
380
4bf79305d675
this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents:
378
diff
changeset
|
16 |
381
b00cc483d13b
still something wrong with reorder()
Anselm R. Garbe <arg@10kloc.org>
parents:
380
diff
changeset
|
17 while((c = orig)) { |
b00cc483d13b
still something wrong with reorder()
Anselm R. Garbe <arg@10kloc.org>
parents:
380
diff
changeset
|
18 orig = orig->next; |
b00cc483d13b
still something wrong with reorder()
Anselm R. Garbe <arg@10kloc.org>
parents:
380
diff
changeset
|
19 detach(c); |
b00cc483d13b
still something wrong with reorder()
Anselm R. Garbe <arg@10kloc.org>
parents:
380
diff
changeset
|
20 |
b00cc483d13b
still something wrong with reorder()
Anselm R. Garbe <arg@10kloc.org>
parents:
380
diff
changeset
|
21 for(p = clients; p && p->next && p->weight <= c->weight; p = p->next); |
b00cc483d13b
still something wrong with reorder()
Anselm R. Garbe <arg@10kloc.org>
parents:
380
diff
changeset
|
22 c->prev = p; |
b00cc483d13b
still something wrong with reorder()
Anselm R. Garbe <arg@10kloc.org>
parents:
380
diff
changeset
|
23 if(p) { |
b00cc483d13b
still something wrong with reorder()
Anselm R. Garbe <arg@10kloc.org>
parents:
380
diff
changeset
|
24 if((c->next = p->next)) |
b00cc483d13b
still something wrong with reorder()
Anselm R. Garbe <arg@10kloc.org>
parents:
380
diff
changeset
|
25 c->next->prev = c; |
b00cc483d13b
still something wrong with reorder()
Anselm R. Garbe <arg@10kloc.org>
parents:
380
diff
changeset
|
26 p->next = c; |
b00cc483d13b
still something wrong with reorder()
Anselm R. Garbe <arg@10kloc.org>
parents:
380
diff
changeset
|
27 } |
b00cc483d13b
still something wrong with reorder()
Anselm R. Garbe <arg@10kloc.org>
parents:
380
diff
changeset
|
28 else |
b00cc483d13b
still something wrong with reorder()
Anselm R. Garbe <arg@10kloc.org>
parents:
380
diff
changeset
|
29 clients = c; |
380
4bf79305d675
this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents:
378
diff
changeset
|
30 } |
4bf79305d675
this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents:
378
diff
changeset
|
31 } |
4bf79305d675
this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents:
378
diff
changeset
|
32 |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
33 /* extern */ |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
34 |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
35 void (*arrange)(Arg *) = DEFMODE; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
36 |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
37 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
|
38 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
|
39 { |
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
|
40 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
|
41 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
|
42 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
|
43 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
|
44 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
|
45 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
|
46 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
|
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 |
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 void |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
50 dofloat(Arg *arg) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
51 { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
52 Client *c; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
53 |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
54 for(c = clients; c; c = c->next) { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
55 c->ismax = False; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
56 if(isvisible(c)) { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
57 resize(c, True, TopLeft); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
58 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
59 else |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
60 ban(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 if(!sel || !isvisible(sel)) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
63 sel = getnext(clients); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
64 if(sel) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
65 focus(sel); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
66 else |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
67 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
68 restack(); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
69 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
70 |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
71 void |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
72 dotile(Arg *arg) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
73 { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
74 int h, i, n, w; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
75 Client *c; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
76 |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
77 w = sw - mw; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
78 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
|
79 if(isvisible(c) && !c->isfloat) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
80 n++; |
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 if(n > 1) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
83 h = (sh - bh) / (n - 1); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
84 else |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
85 h = sh - bh; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
86 |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
87 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
|
88 c->ismax = False; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
89 if(isvisible(c)) { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
90 if(c->isfloat) { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
91 resize(c, True, TopLeft); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
92 continue; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
93 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
94 if(n == 1) { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
95 c->x = sx; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
96 c->y = sy + bh; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
97 c->w = sw - 2; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
98 c->h = sh - 2 - bh; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
99 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
100 else if(i == 0) { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
101 c->x = sx; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
102 c->y = sy + bh; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
103 c->w = mw - 2; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
104 c->h = sh - 2 - bh; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
105 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
106 else if(h > bh) { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
107 c->x = sx + mw; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
108 c->y = sy + (i - 1) * h + bh; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
109 c->w = w - 2; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
110 if(i + 1 == n) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
111 c->h = sh - c->y - 2; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
112 else |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
113 c->h = h - 2; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
114 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
115 else { /* fallback if h < bh */ |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
116 c->x = sx + mw; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
117 c->y = sy + bh; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
118 c->w = w - 2; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
119 c->h = sh - 2 - bh; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
120 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
121 resize(c, False, TopLeft); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
122 i++; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
123 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
124 else |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
125 ban(c); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
126 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
127 if(!sel || !isvisible(sel)) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
128 sel = getnext(clients); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
129 if(sel) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
130 focus(sel); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
131 else |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
132 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
133 restack(); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
134 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
135 |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
136 void |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
137 focusnext(Arg *arg) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
138 { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
139 Client *c; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
140 |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
141 if(!sel) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
142 return; |
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 if(!(c = getnext(sel->next))) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
145 c = getnext(clients); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
146 if(c) { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
147 focus(c); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
148 restack(); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
149 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
150 } |
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 void |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
153 focusprev(Arg *arg) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
154 { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
155 Client *c; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
156 |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
157 if(!sel) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
158 return; |
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 if(!(c = getprev(sel->prev))) { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
161 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
|
162 c = getprev(c); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
163 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
164 if(c) { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
165 focus(c); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
166 restack(); |
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 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
169 |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
170 Bool |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
171 isvisible(Client *c) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
172 { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
173 unsigned int i; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
174 |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
175 for(i = 0; i < ntags; i++) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
176 if(c->tags[i] && seltag[i]) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
177 return True; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
178 return False; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
179 } |
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 void |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
182 restack() |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
183 { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
184 static unsigned int nwins = 0; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
185 static Window *wins = NULL; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
186 unsigned int f, fi, m, mi, n; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
187 Client *c; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
188 XEvent ev; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
189 |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
190 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
|
191 if(isvisible(c)) { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
192 if(c->isfloat || arrange == dofloat) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
193 f++; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
194 else |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
195 m++; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
196 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
197 if(!(n = 2 * (f + m))) { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
198 drawstatus(); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
199 return; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
200 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
201 if(nwins < n) { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
202 nwins = n; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
203 wins = erealloc(wins, nwins * sizeof(Window)); |
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 |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
206 fi = 0; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
207 mi = 2 * f; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
208 if(sel->isfloat || arrange == dofloat) { |
342 | 209 wins[fi++] = sel->twin; |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
210 wins[fi++] = sel->win; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
211 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
212 else { |
342 | 213 wins[mi++] = sel->twin; |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
214 wins[mi++] = sel->win; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
215 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
216 for(c = clients; c; c = c->next) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
217 if(isvisible(c) && c != sel) { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
218 if(c->isfloat || arrange == dofloat) { |
342 | 219 wins[fi++] = c->twin; |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
220 wins[fi++] = c->win; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
221 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
222 else { |
342 | 223 wins[mi++] = c->twin; |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
224 wins[mi++] = c->win; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
225 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
226 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
227 XRestackWindows(dpy, wins, n); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
228 drawall(); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
229 XSync(dpy, False); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
230 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
231 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
232 |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
233 void |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
234 togglemode(Arg *arg) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
235 { |
333
827f8f6c9e97
separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents:
327
diff
changeset
|
236 arrange = (arrange == dofloat) ? dotile : dofloat; |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
237 if(sel) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
238 arrange(NULL); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
239 else |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
240 drawstatus(); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
241 } |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
242 |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
243 void |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
244 toggleview(Arg *arg) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
245 { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
246 unsigned int i; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
247 |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
248 seltag[arg->i] = !seltag[arg->i]; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
249 for(i = 0; i < ntags && !seltag[i]; i++); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
250 if(i == ntags) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
251 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
|
252 reorder(); |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
253 arrange(NULL); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
254 } |
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 void |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
257 view(Arg *arg) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
258 { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
259 unsigned int i; |
381
b00cc483d13b
still something wrong with reorder()
Anselm R. Garbe <arg@10kloc.org>
parents:
380
diff
changeset
|
260 Client *c; |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
261 |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
262 for(i = 0; i < ntags; i++) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
263 seltag[i] = False; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
264 seltag[arg->i] = True; |
381
b00cc483d13b
still something wrong with reorder()
Anselm R. Garbe <arg@10kloc.org>
parents:
380
diff
changeset
|
265 reorder(); |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
266 arrange(NULL); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
267 } |
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 void |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
270 zoom(Arg *arg) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
271 { |
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
|
272 Client *c = sel; |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
273 |
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
|
274 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
|
275 return; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
276 |
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
|
277 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
|
278 if(!(c = getnext(c->next))) |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
279 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
|
280 detach(c); |
381
b00cc483d13b
still something wrong with reorder()
Anselm R. Garbe <arg@10kloc.org>
parents:
380
diff
changeset
|
281 c->next = clients; |
b00cc483d13b
still something wrong with reorder()
Anselm R. Garbe <arg@10kloc.org>
parents:
380
diff
changeset
|
282 clients->prev = c; |
b00cc483d13b
still something wrong with reorder()
Anselm R. Garbe <arg@10kloc.org>
parents:
380
diff
changeset
|
283 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
|
284 focus(c); |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
285 arrange(NULL); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
286 } |