23 resize(stack); |
25 resize(stack); |
24 discard_events(EnterWindowMask); |
26 discard_events(EnterWindowMask); |
25 } |
27 } |
26 |
28 |
27 void |
29 void |
28 arrange(void *aux) |
30 floating(void *aux) |
|
31 { |
|
32 Client *c; |
|
33 |
|
34 arrange = floating; |
|
35 for(c = stack; c; c = c->snext) |
|
36 resize(c); |
|
37 discard_events(EnterWindowMask); |
|
38 } |
|
39 |
|
40 void |
|
41 grid(void *aux) |
29 { |
42 { |
30 Client *c; |
43 Client *c; |
31 int n, cols, rows, gw, gh, i, j; |
44 int n, cols, rows, gw, gh, i, j; |
32 float rt, fd; |
45 float rt, fd; |
33 |
46 |
|
47 arrange = grid; |
34 if(!clients) |
48 if(!clients) |
35 return; |
49 return; |
36 for(n = 0, c = clients; c; c = c->next, n++); |
50 for(n = 0, c = clients; c; c = c->next, n++); |
37 rt = sqrt(n); |
51 rt = sqrt(n); |
38 if(modff(rt, &fd) < 0.5) |
52 if(modff(rt, &fd) < 0.5) |
228 XGetTransientForHint(dpy, c->win, &c->trans); |
248 XGetTransientForHint(dpy, c->win, &c->trans); |
229 twa.override_redirect = 1; |
249 twa.override_redirect = 1; |
230 twa.background_pixmap = ParentRelative; |
250 twa.background_pixmap = ParentRelative; |
231 twa.event_mask = ExposureMask; |
251 twa.event_mask = ExposureMask; |
232 |
252 |
|
253 c->tags[tsel] = tags[tsel]; |
233 c->title = XCreateWindow(dpy, root, c->tx, c->ty, c->tw, c->th, |
254 c->title = XCreateWindow(dpy, root, c->tx, c->ty, c->tw, c->th, |
234 0, DefaultDepth(dpy, screen), CopyFromParent, |
255 0, DefaultDepth(dpy, screen), CopyFromParent, |
235 DefaultVisual(dpy, screen), |
256 DefaultVisual(dpy, screen), |
236 CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa); |
257 CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa); |
|
258 |
237 update_name(c); |
259 update_name(c); |
238 |
|
239 for(l=&clients; *l; l=&(*l)->next); |
260 for(l=&clients; *l; l=&(*l)->next); |
240 c->next = *l; /* *l == nil */ |
261 c->next = *l; /* *l == nil */ |
241 *l = c; |
262 *l = c; |
242 c->snext = stack; |
|
243 stack = c; |
|
244 XMapRaised(dpy, c->win); |
263 XMapRaised(dpy, c->win); |
245 XMapRaised(dpy, c->title); |
264 XMapRaised(dpy, c->title); |
246 XGrabButton(dpy, Button1, Mod1Mask, c->win, False, ButtonPressMask, |
265 XGrabButton(dpy, Button1, Mod1Mask, c->win, False, ButtonPressMask, |
247 GrabModeAsync, GrabModeSync, None, None); |
266 GrabModeAsync, GrabModeSync, None, None); |
248 XGrabButton(dpy, Button2, Mod1Mask, c->win, False, ButtonPressMask, |
267 XGrabButton(dpy, Button2, Mod1Mask, c->win, False, ButtonPressMask, |
249 GrabModeAsync, GrabModeSync, None, None); |
268 GrabModeAsync, GrabModeSync, None, None); |
250 XGrabButton(dpy, Button3, Mod1Mask, c->win, False, ButtonPressMask, |
269 XGrabButton(dpy, Button3, Mod1Mask, c->win, False, ButtonPressMask, |
251 GrabModeAsync, GrabModeSync, None, None); |
270 GrabModeAsync, GrabModeSync, None, None); |
252 resize(c); |
271 arrange(NULL); |
253 focus(c); |
272 focus(c); |
254 } |
273 } |
255 |
274 |
256 void |
275 void |
257 gravitate(Client *c, Bool invert) |
276 gravitate(Client *c, Bool invert) |
382 } |
415 } |
383 |
416 |
384 void |
417 void |
385 draw_client(Client *c) |
418 draw_client(Client *c) |
386 { |
419 { |
|
420 int i; |
387 if(c == stack) { |
421 if(c == stack) { |
388 draw_bar(); |
422 draw_bar(); |
389 return; |
423 return; |
390 } |
424 } |
391 |
425 |
392 brush.x = brush.y = 0; |
426 brush.x = brush.y = 0; |
393 brush.w = c->tw; |
|
394 brush.h = c->th; |
427 brush.h = c->th; |
395 |
428 |
|
429 brush.w = 0; |
|
430 for(i = 0; i < TLast; i++) { |
|
431 if(c->tags[i]) { |
|
432 brush.x += brush.w; |
|
433 brush.w = textw(&brush.font, c->tags[i]) + bh; |
|
434 draw(dpy, &brush, True, c->tags[i]); |
|
435 } |
|
436 } |
|
437 brush.x += brush.w; |
|
438 brush.w = textw(&brush.font, c->name) + bh; |
396 draw(dpy, &brush, True, c->name); |
439 draw(dpy, &brush, True, c->name); |
397 XCopyArea(dpy, brush.drawable, c->title, brush.gc, |
440 XCopyArea(dpy, brush.drawable, c->title, brush.gc, |
398 0, 0, c->tw, c->th, 0, 0); |
441 0, 0, c->tw, c->th, 0, 0); |
399 XFlush(dpy); |
442 XFlush(dpy); |
400 } |
443 } |