summaryrefslogtreecommitdiffstats
path: root/client.c
diff options
context:
space:
mode:
authorAnselm R. Garbe <garbeam@wmii.de>2006-07-12 16:00:51 +0200
committerAnselm R. Garbe <garbeam@wmii.de>2006-07-12 16:00:51 +0200
commit4641aa2925731ac180b08c80f57db176391ea4a9 (patch)
tree0908650ef67b9dc4040d026fdd4492ac29f75d7d /client.c
parentsimplified several portions of code through replacing rect structs with x,y,h... (diff)
downloaddwm-4641aa2925731ac180b08c80f57db176391ea4a9.tar.gz
dwm-4641aa2925731ac180b08c80f57db176391ea4a9.zip
added grid mode on Mod1Mask g
Diffstat (limited to 'client.c')
-rw-r--r--client.c70
1 files changed, 69 insertions, 1 deletions
diff --git a/client.c b/client.c
index 84fbce5..b961d86 100644
--- a/client.c
+++ b/client.c
@@ -3,6 +3,7 @@
3 * See LICENSE file for license details. 3 * See LICENSE file for license details.
4 */ 4 */
5 5
6#include <math.h>
6#include <stdlib.h> 7#include <stdlib.h>
7#include <string.h> 8#include <string.h>
8#include <X11/Xatom.h> 9#include <X11/Xatom.h>
@@ -10,6 +11,73 @@
10#include "util.h" 11#include "util.h"
11#include "wm.h" 12#include "wm.h"
12 13
14void
15arrange(void *aux)
16{
17 Client *c;
18 int n, cols, rows, gw, gh, i, j;
19 float rt, fd;
20
21 if(!clients)
22 return;
23 for(n = 0, c = clients; c; c = c->next, n++);
24 rt = sqrt(n);
25 if(modff(rt, &fd) < 0.5)
26 rows = floor(rt);
27 else
28 rows = ceil(rt);
29 if(rows * rows < n)
30 cols = rows + 1;
31 else
32 cols = rows;
33
34 gw = (sw - 1) / cols;
35 gh = (sh - bh - 1) / rows;
36
37 for(i = j = 0, c = clients; c; c = c->next) {
38 c->x = i * gw;
39 c->y = j * gh + bh;
40 c->w = gw;
41 c->h = gh;
42 resize(c);
43 if(++i == cols) {
44 j++;
45 i = 0;
46 }
47 }
48}
49
50void
51sel(void *aux)
52{
53 const char *arg = aux;
54 Client *c = NULL;
55
56 if(!arg || !stack)
57 return;
58 if(!strncmp(arg, "next", 5))
59 c = stack->snext ? stack->snext : stack;
60 else if(!strncmp(arg, "prev", 5))
61 for(c = stack; c && c->snext; c = c->snext);
62 if(!c)
63 c = stack;
64 raise(c);
65 focus(c);
66}
67
68void
69kill(void *aux)
70{
71 Client *c = stack;
72
73 if(!c)
74 return;
75 if(c->proto & WM_PROTOCOL_DELWIN)
76 send_message(c->win, wm_atom[WMProtocols], wm_atom[WMDelete]);
77 else
78 XKillClient(dpy, c->win);
79}
80
13static void 81static void
14resize_title(Client *c) 82resize_title(Client *c)
15{ 83{
@@ -113,7 +181,7 @@ focus(Client *c)
113 draw_client(old); 181 draw_client(old);
114 } 182 }
115 XUnmapWindow(dpy, c->title); 183 XUnmapWindow(dpy, c->title);
116 draw_client(old); 184 draw_client(c);
117 XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); 185 XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
118 XFlush(dpy); 186 XFlush(dpy);
119} 187}