annotate view.c @ 380:4bf79305d675

this algorithm seems to keep order for any scenario
author Anselm R. Garbe <arg@10kloc.org>
date Tue, 29 Aug 2006 09:57:57 +0200
parents 83576f5f0a90
children b00cc483d13b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
4bf79305d675 this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents: 378
diff changeset
9 static Client *
4bf79305d675 this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents: 378
diff changeset
10 getslot(Client *c)
4bf79305d675 this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents: 378
diff changeset
11 {
4bf79305d675 this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents: 378
diff changeset
12 unsigned int i, tic;
4bf79305d675 this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents: 378
diff changeset
13 Client *p;
4bf79305d675 this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents: 378
diff changeset
14
4bf79305d675 this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents: 378
diff changeset
15 for(tic = 0; tic < ntags && !c->tags[tic]; tic++);
4bf79305d675 this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents: 378
diff changeset
16 for(p = clients; p; p = p->next) {
4bf79305d675 this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents: 378
diff changeset
17 for(i = 0; i < ntags && !p->tags[i]; i++);
4bf79305d675 this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents: 378
diff changeset
18 if(tic < i)
4bf79305d675 this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents: 378
diff changeset
19 return p;
4bf79305d675 this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents: 378
diff changeset
20 }
4bf79305d675 this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents: 378
diff changeset
21 return p;
4bf79305d675 this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents: 378
diff changeset
22 }
4bf79305d675 this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents: 378
diff changeset
23
4bf79305d675 this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents: 378
diff changeset
24 static Client *
4bf79305d675 this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents: 378
diff changeset
25 tail()
4bf79305d675 this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents: 378
diff changeset
26 {
4bf79305d675 this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents: 378
diff changeset
27 Client *c;
4bf79305d675 this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents: 378
diff changeset
28 for(c = clients; c && c->next; c = c->next);
4bf79305d675 this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents: 378
diff changeset
29 return c;
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
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
32 /* extern */
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
33
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
34 void (*arrange)(Arg *) = DEFMODE;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
35
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
36 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
37 attach(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
38 {
380
4bf79305d675 this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents: 378
diff changeset
39 Client *p;
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
40
380
4bf79305d675 this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents: 378
diff changeset
41 if(!clients) {
4bf79305d675 this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents: 378
diff changeset
42 clients = c;
4bf79305d675 this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents: 378
diff changeset
43 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
44 }
380
4bf79305d675 this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents: 378
diff changeset
45 if(!(p = getnext(clients)) && !(p = getslot(c))) {
4bf79305d675 this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents: 378
diff changeset
46 p = tail();
4bf79305d675 this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents: 378
diff changeset
47 c->prev = p;
4bf79305d675 this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents: 378
diff changeset
48 p->next = c;
4bf79305d675 this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents: 378
diff changeset
49 return;
4bf79305d675 this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents: 378
diff changeset
50 }
4bf79305d675 this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents: 378
diff changeset
51
4bf79305d675 this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents: 378
diff changeset
52 if(p == clients) {
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
53 c->next = 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
54 clients->prev = 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
55 clients = 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
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 else {
380
4bf79305d675 this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents: 378
diff changeset
58 p->prev->next = c;
4bf79305d675 this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents: 378
diff changeset
59 c->prev = p->prev;
4bf79305d675 this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents: 378
diff changeset
60 p->prev = c;
4bf79305d675 this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents: 378
diff changeset
61 c->next = p;
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
62 }
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
63 }
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
64
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
65 void
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
66 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
67 {
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
68 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
69 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
70 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
71 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
72 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
73 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
74 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
75 }
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
76
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
77 void
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
78 dofloat(Arg *arg)
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
79 {
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
80 Client *c;
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 for(c = clients; c; c = c->next) {
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
83 c->ismax = False;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
84 if(isvisible(c)) {
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
85 resize(c, True, TopLeft);
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 else
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
88 ban(c);
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(!sel || !isvisible(sel))
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
91 sel = getnext(clients);
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
92 if(sel)
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
93 focus(sel);
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
94 else
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
95 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
96 restack();
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
97 }
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
98
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
99 void
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
100 dotile(Arg *arg)
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 int h, i, n, w;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
103 Client *c;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
104
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
105 w = sw - mw;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
106 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
107 if(isvisible(c) && !c->isfloat)
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
108 n++;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
109
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
110 if(n > 1)
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
111 h = (sh - bh) / (n - 1);
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 h = sh - bh;
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 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
116 c->ismax = False;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
117 if(isvisible(c)) {
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
118 if(c->isfloat) {
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
119 resize(c, True, TopLeft);
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
120 continue;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
121 }
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
122 if(n == 1) {
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
123 c->x = sx;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
124 c->y = sy + bh;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
125 c->w = sw - 2;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
126 c->h = sh - 2 - bh;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
127 }
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
128 else if(i == 0) {
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
129 c->x = sx;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
130 c->y = sy + bh;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
131 c->w = mw - 2;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
132 c->h = sh - 2 - bh;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
133 }
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
134 else if(h > bh) {
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
135 c->x = sx + mw;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
136 c->y = sy + (i - 1) * h + bh;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
137 c->w = w - 2;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
138 if(i + 1 == n)
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
139 c->h = sh - c->y - 2;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
140 else
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
141 c->h = h - 2;
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 else { /* fallback if h < bh */
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
144 c->x = sx + mw;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
145 c->y = sy + bh;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
146 c->w = w - 2;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
147 c->h = sh - 2 - bh;
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 resize(c, False, TopLeft);
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
150 i++;
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 else
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
153 ban(c);
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 if(!sel || !isvisible(sel))
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
156 sel = getnext(clients);
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 focus(sel);
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
159 else
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
160 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
161 restack();
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
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
164 void
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
165 focusnext(Arg *arg)
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
166 {
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
167 Client *c;
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 if(!sel)
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
170 return;
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 = getnext(sel->next)))
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
173 c = getnext(clients);
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
174 if(c) {
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
175 focus(c);
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
176 restack();
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 }
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 void
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
181 focusprev(Arg *arg)
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 Client *c;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
184
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
185 if(!sel)
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
186 return;
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 if(!(c = getprev(sel->prev))) {
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
189 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
190 c = getprev(c);
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 if(c) {
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
193 focus(c);
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
194 restack();
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
195 }
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
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
198 Bool
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
199 isvisible(Client *c)
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 unsigned int i;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
202
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
203 for(i = 0; i < ntags; i++)
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
204 if(c->tags[i] && seltag[i])
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
205 return True;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
206 return False;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
207 }
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 void
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
210 restack()
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 static unsigned int nwins = 0;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
213 static Window *wins = NULL;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
214 unsigned int f, fi, m, mi, n;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
215 Client *c;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
216 XEvent ev;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
217
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
218 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
219 if(isvisible(c)) {
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
220 if(c->isfloat || arrange == dofloat)
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
221 f++;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
222 else
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
223 m++;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
224 }
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
225 if(!(n = 2 * (f + m))) {
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
226 drawstatus();
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
227 return;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
228 }
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
229 if(nwins < n) {
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
230 nwins = n;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
231 wins = erealloc(wins, nwins * sizeof(Window));
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
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
234 fi = 0;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
235 mi = 2 * f;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
236 if(sel->isfloat || arrange == dofloat) {
342
a1901753deef updated man page
Anselm R. Garbe <arg@10kloc.org>
parents: 333
diff changeset
237 wins[fi++] = sel->twin;
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
238 wins[fi++] = sel->win;
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 else {
342
a1901753deef updated man page
Anselm R. Garbe <arg@10kloc.org>
parents: 333
diff changeset
241 wins[mi++] = sel->twin;
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
242 wins[mi++] = sel->win;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
243 }
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
244 for(c = clients; c; c = c->next)
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
245 if(isvisible(c) && c != sel) {
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
246 if(c->isfloat || arrange == dofloat) {
342
a1901753deef updated man page
Anselm R. Garbe <arg@10kloc.org>
parents: 333
diff changeset
247 wins[fi++] = c->twin;
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
248 wins[fi++] = c->win;
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 else {
342
a1901753deef updated man page
Anselm R. Garbe <arg@10kloc.org>
parents: 333
diff changeset
251 wins[mi++] = c->twin;
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
252 wins[mi++] = c->win;
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 }
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
255 XRestackWindows(dpy, wins, n);
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
256 drawall();
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
257 XSync(dpy, False);
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
258 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
259 }
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
260
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
261 void
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
262 togglemode(Arg *arg)
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
263 {
333
827f8f6c9e97 separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents: 327
diff changeset
264 arrange = (arrange == dofloat) ? dotile : dofloat;
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
265 if(sel)
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 else
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
268 drawstatus();
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
269 }
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
270
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
271 void
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
272 toggleview(Arg *arg)
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
273 {
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
274 unsigned int i;
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 seltag[arg->i] = !seltag[arg->i];
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
277 for(i = 0; i < ntags && !seltag[i]; i++);
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
278 if(i == ntags)
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
279 seltag[arg->i] = True; /* cannot toggle last view */
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
280 arrange(NULL);
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
281 }
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
282
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
283 void
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
284 view(Arg *arg)
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
285 {
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
286 unsigned int i;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
287
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
288 for(i = 0; i < ntags; i++)
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
289 seltag[i] = False;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
290 seltag[arg->i] = True;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
291 arrange(NULL);
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
292 }
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
293
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
294 void
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
295 zoom(Arg *arg)
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
296 {
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 Client *c = sel;
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
298
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
299 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
300 return;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
301
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
302 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
303 if(!(c = getnext(c->next)))
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
304 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
305 detach(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
306 attach(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
307 focus(c);
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
308 arrange(NULL);
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
309 }