summaryrefslogtreecommitdiffstats
path: root/client.c
diff options
context:
space:
mode:
authorAnselm R. Garbe <garbeam@wmii.de>2006-07-14 22:33:38 +0200
committerAnselm R. Garbe <garbeam@wmii.de>2006-07-14 22:33:38 +0200
commit29355bd38284ed9aec8d3ffabde61db73947c9f9 (patch)
treee8c9d94e52b57df9c93bc58bdd5c37b9e3262e65 /client.c
parentI prefer the tiled/floating indicator on the right side (diff)
downloaddwm-29355bd38284ed9aec8d3ffabde61db73947c9f9.tar.gz
dwm-29355bd38284ed9aec8d3ffabde61db73947c9f9.zip
rearranged
Diffstat (limited to '')
-rw-r--r--client.c230
1 files changed, 3 insertions, 227 deletions
diff --git a/client.c b/client.c
index 5b666c9..63fb1e5 100644
--- a/client.c
+++ b/client.c
@@ -11,14 +11,12 @@
11 11
12#include "dwm.h" 12#include "dwm.h"
13 13
14void (*arrange)(Arg *) = tiling;
15
16static Rule rule[] = { 14static Rule rule[] = {
17 /* class instance tags floating */ 15 /* class instance tags floating */
18 { "Firefox-bin", "Gecko", { [Twww] = "www" }, False }, 16 { "Firefox-bin", "Gecko", { [Twww] = "www" }, False },
19}; 17};
20 18
21static Client * 19Client *
22next(Client *c) 20next(Client *c)
23{ 21{
24 for(; c && !c->tags[tsel]; c = c->next); 22 for(; c && !c->tags[tsel]; c = c->next);
@@ -26,202 +24,12 @@ next(Client *c)
26} 24}
27 25
28void 26void
29zoom(Arg *arg)
30{
31 Client **l, *c;
32
33 if(!sel)
34 return;
35
36 if(sel == next(clients) && sel->next) {
37 if((c = next(sel->next)))
38 sel = c;
39 }
40
41 for(l = &clients; *l && *l != sel; l = &(*l)->next);
42 *l = sel->next;
43
44 sel->next = clients; /* pop */
45 clients = sel;
46 arrange(NULL);
47 focus(sel);
48}
49
50void
51max(Arg *arg)
52{
53 if(!sel)
54 return;
55 sel->x = sx;
56 sel->y = sy + bh;
57 sel->w = sw - 2 * sel->border;
58 sel->h = sh - 2 * sel->border - bh;
59 craise(sel);
60 resize(sel, False);
61}
62
63void
64view(Arg *arg)
65{
66 Client *c;
67
68 tsel = arg->i;
69 arrange(NULL);
70
71 for(c = clients; c; c = next(c->next))
72 draw_client(c);
73 draw_bar();
74}
75
76void
77tappend(Arg *arg)
78{
79 if(!sel)
80 return;
81
82 sel->tags[arg->i] = tags[arg->i];
83 arrange(NULL);
84}
85
86void
87ttrunc(Arg *arg)
88{
89 int i;
90 if(!sel)
91 return;
92
93 for(i = 0; i < TLast; i++)
94 sel->tags[i] = NULL;
95 tappend(arg);
96}
97
98static void
99ban_client(Client *c) 27ban_client(Client *c)
100{ 28{
101 XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); 29 XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
102 XMoveWindow(dpy, c->title, c->tx + 2 * sw, c->ty); 30 XMoveWindow(dpy, c->title, c->tx + 2 * sw, c->ty);
103} 31}
104 32
105void
106floating(Arg *arg)
107{
108 Client *c;
109
110 arrange = floating;
111 for(c = clients; c; c = c->next) {
112 if(c->tags[tsel])
113 resize(c, True);
114 else
115 ban_client(c);
116 }
117 if(sel && !sel->tags[tsel]) {
118 if((sel = next(clients))) {
119 craise(sel);
120 focus(sel);
121 }
122 }
123 draw_bar();
124}
125
126void
127tiling(Arg *arg)
128{
129 Client *c;
130 int n, i, w, h;
131
132 w = sw - mw;
133 arrange = tiling;
134 for(n = 0, c = clients; c; c = c->next)
135 if(c->tags[tsel] && !c->floating)
136 n++;
137
138 if(n > 1)
139 h = (sh - bh) / (n - 1);
140 else
141 h = sh - bh;
142
143 for(i = 0, c = clients; c; c = c->next) {
144 if(c->tags[tsel]) {
145 if(c->floating) {
146 craise(c);
147 resize(c, True);
148 continue;
149 }
150 if(n == 1) {
151 c->x = sx;
152 c->y = sy + bh;
153 c->w = sw - 2 * c->border;
154 c->h = sh - 2 * c->border - bh;
155 }
156 else if(i == 0) {
157 c->x = sx;
158 c->y = sy + bh;
159 c->w = mw - 2 * c->border;
160 c->h = sh - 2 * c->border - bh;
161 }
162 else {
163 c->x = sx + mw;
164 c->y = sy + (i - 1) * h + bh;
165 c->w = w - 2 * c->border;
166 c->h = h - 2 * c->border;
167 }
168 resize(c, False);
169 i++;
170 }
171 else
172 ban_client(c);
173 }
174 if(!sel || (sel && !sel->tags[tsel])) {
175 if((sel = next(clients))) {
176 craise(sel);
177 focus(sel);
178 }
179 }
180 draw_bar();
181}
182
183void
184prevc(Arg *arg)
185{
186 Client *c;
187
188 if(!sel)
189 return;
190
191 if((c = sel->revert && sel->revert->tags[tsel] ? sel->revert : NULL)) {
192 craise(c);
193 focus(c);
194 }
195}
196
197void
198nextc(Arg *arg)
199{
200 Client *c;
201
202 if(!sel)
203 return;
204
205 if(!(c = next(sel->next)))
206 c = next(clients);
207 if(c) {
208 craise(c);
209 c->revert = sel;
210 focus(c);
211 }
212}
213
214void
215ckill(Arg *arg)
216{
217 if(!sel)
218 return;
219 if(sel->proto & WM_PROTOCOL_DELWIN)
220 send_message(sel->win, wm_atom[WMProtocols], wm_atom[WMDelete]);
221 else
222 XKillClient(dpy, sel->win);
223}
224
225static void 33static void
226resize_title(Client *c) 34resize_title(Client *c)
227{ 35{
@@ -230,8 +38,8 @@ resize_title(Client *c)
230 c->tw = 0; 38 c->tw = 0;
231 for(i = 0; i < TLast; i++) 39 for(i = 0; i < TLast; i++)
232 if(c->tags[i]) 40 if(c->tags[i])
233 c->tw += textw(c->tags[i]) + dc.font.height; 41 c->tw += textw(c->tags[i]);
234 c->tw += textw(c->name) + dc.font.height; 42 c->tw += textw(c->name);
235 if(c->tw > c->w) 43 if(c->tw > c->w)
236 c->tw = c->w + 2; 44 c->tw = c->w + 2;
237 c->tx = c->x + c->w - c->tw + 2; 45 c->tx = c->x + c->w - c->tw + 2;
@@ -584,35 +392,3 @@ getclient(Window w)
584 return c; 392 return c;
585 return NULL; 393 return NULL;
586} 394}
587
588void
589draw_client(Client *c)
590{
591 int i;
592 if(c == sel) {
593 draw_bar();
594 XUnmapWindow(dpy, c->title);
595 XSetWindowBorder(dpy, c->win, dc.fg);
596 return;
597 }
598
599 XSetWindowBorder(dpy, c->win, dc.bg);
600 XMapWindow(dpy, c->title);
601
602 dc.x = dc.y = 0;
603
604 dc.w = 0;
605 for(i = 0; i < TLast; i++) {
606 if(c->tags[i]) {
607 dc.x += dc.w;
608 dc.w = textw(c->tags[i]) + dc.font.height;
609 drawtext(c->tags[i], False, True);
610 }
611 }
612 dc.x += dc.w;
613 dc.w = textw(c->name) + dc.font.height;
614 drawtext(c->name, False, True);
615 XCopyArea(dpy, dc.drawable, c->title, dc.gc,
616 0, 0, c->tw, c->th, 0, 0);
617 XFlush(dpy);
618}