summaryrefslogtreecommitdiffstats
path: root/client.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--client.c55
1 files changed, 33 insertions, 22 deletions
diff --git a/client.c b/client.c
index 6777473..679e2be 100644
--- a/client.c
+++ b/client.c
@@ -11,7 +11,9 @@
11 11
12#include "wm.h" 12#include "wm.h"
13 13
14void (*arrange)(void *aux); 14static void floating(void);
15static void tiling(void);
16static void (*arrange)(void) = tiling;
15 17
16void 18void
17max(void *aux) 19max(void *aux)
@@ -26,25 +28,23 @@ max(void *aux)
26 discard_events(EnterWindowMask); 28 discard_events(EnterWindowMask);
27} 29}
28 30
29void 31static void
30floating(void *aux) 32floating(void)
31{ 33{
32 Client *c; 34 Client *c;
33 35
34 arrange = floating;
35 for(c = stack; c; c = c->snext) 36 for(c = stack; c; c = c->snext)
36 resize(c); 37 resize(c);
37 discard_events(EnterWindowMask); 38 discard_events(EnterWindowMask);
38} 39}
39 40
40void 41static void
41grid(void *aux) 42tiling(void)
42{ 43{
43 Client *c; 44 Client *c;
44 int n, cols, rows, gw, gh, i, j; 45 int n, cols, rows, gw, gh, i, j;
45 float rt, fd; 46 float rt, fd;
46 47
47 arrange = grid;
48 if(!clients) 48 if(!clients)
49 return; 49 return;
50 for(n = 0, c = clients; c; c = c->next, n++); 50 for(n = 0, c = clients; c; c = c->next, n++);
@@ -76,6 +76,17 @@ grid(void *aux)
76} 76}
77 77
78void 78void
79toggle(void *aux)
80{
81 if(arrange == floating)
82 arrange = tiling;
83 else
84 arrange = floating;
85 arrange();
86}
87
88
89void
79sel(void *aux) 90sel(void *aux)
80{ 91{
81 const char *arg = aux; 92 const char *arg = aux;
@@ -114,8 +125,8 @@ resize_title(Client *c)
114 c->tw = 0; 125 c->tw = 0;
115 for(i = 0; i < TLast; i++) 126 for(i = 0; i < TLast; i++)
116 if(c->tags[i]) 127 if(c->tags[i])
117 c->tw += textw(&brush.font, c->tags[i]) + brush.font.height; 128 c->tw += textw(&dc.font, c->tags[i]) + dc.font.height;
118 c->tw += textw(&brush.font, c->name) + brush.font.height; 129 c->tw += textw(&dc.font, c->name) + dc.font.height;
119 if(c->tw > c->w) 130 if(c->tw > c->w)
120 c->tw = c->w + 2; 131 c->tw = c->w + 2;
121 c->tx = c->x + c->w - c->tw + 2; 132 c->tx = c->x + c->w - c->tw + 2;
@@ -240,7 +251,7 @@ manage(Window w, XWindowAttributes *wa)
240 c->border = 1; 251 c->border = 1;
241 update_size(c); 252 update_size(c);
242 XSetWindowBorderWidth(dpy, c->win, 1); 253 XSetWindowBorderWidth(dpy, c->win, 1);
243 XSetWindowBorder(dpy, c->win, brush.border); 254 XSetWindowBorder(dpy, c->win, dc.border);
244 XSelectInput(dpy, c->win, 255 XSelectInput(dpy, c->win,
245 StructureNotifyMask | PropertyChangeMask | EnterWindowMask); 256 StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
246 XGetTransientForHint(dpy, c->win, &c->trans); 257 XGetTransientForHint(dpy, c->win, &c->trans);
@@ -266,7 +277,7 @@ manage(Window w, XWindowAttributes *wa)
266 GrabModeAsync, GrabModeSync, None, None); 277 GrabModeAsync, GrabModeSync, None, None);
267 XGrabButton(dpy, Button3, Mod1Mask, c->win, False, ButtonPressMask, 278 XGrabButton(dpy, Button3, Mod1Mask, c->win, False, ButtonPressMask,
268 GrabModeAsync, GrabModeSync, None, None); 279 GrabModeAsync, GrabModeSync, None, None);
269 arrange(NULL); 280 arrange();
270 focus(c); 281 focus(c);
271} 282}
272 283
@@ -385,7 +396,7 @@ unmanage(Client *c)
385 XFlush(dpy); 396 XFlush(dpy);
386 XSetErrorHandler(error_handler); 397 XSetErrorHandler(error_handler);
387 XUngrabServer(dpy); 398 XUngrabServer(dpy);
388 arrange(NULL); 399 arrange();
389 if(stack) 400 if(stack)
390 focus(stack); 401 focus(stack);
391} 402}
@@ -417,21 +428,21 @@ draw_client(Client *c)
417 if(c == stack) 428 if(c == stack)
418 return; 429 return;
419 430
420 brush.x = brush.y = 0; 431 dc.x = dc.y = 0;
421 brush.h = c->th; 432 dc.h = c->th;
422 433
423 brush.w = 0; 434 dc.w = 0;
424 for(i = 0; i < TLast; i++) { 435 for(i = 0; i < TLast; i++) {
425 if(c->tags[i]) { 436 if(c->tags[i]) {
426 brush.x += brush.w; 437 dc.x += dc.w;
427 brush.w = textw(&brush.font, c->tags[i]) + brush.font.height; 438 dc.w = textw(&dc.font, c->tags[i]) + dc.font.height;
428 draw(&brush, True, c->tags[i]); 439 draw(True, c->tags[i]);
429 } 440 }
430 } 441 }
431 brush.x += brush.w; 442 dc.x += dc.w;
432 brush.w = textw(&brush.font, c->name) + brush.font.height; 443 dc.w = textw(&dc.font, c->name) + dc.font.height;
433 draw(&brush, True, c->name); 444 draw(True, c->name);
434 XCopyArea(dpy, brush.drawable, c->title, brush.gc, 445 XCopyArea(dpy, dc.drawable, c->title, dc.gc,
435 0, 0, c->tw, c->th, 0, 0); 446 0, 0, c->tw, c->th, 0, 0);
436 XFlush(dpy); 447 XFlush(dpy);
437} 448}