aboutsummaryrefslogtreecommitdiffstats
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
parentdfd84f9bf3b9d949412a73bc62a43109b340d395 (diff)
downloaddwm-4641aa2925731ac180b08c80f57db176391ea4a9.tar.zst
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 @@
* See LICENSE file for license details.
*/
+#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <X11/Xatom.h>
@@ -10,6 +11,73 @@
#include "util.h"
#include "wm.h"
+void
+arrange(void *aux)
+{
+ Client *c;
+ int n, cols, rows, gw, gh, i, j;
+ float rt, fd;
+
+ if(!clients)
+ return;
+ for(n = 0, c = clients; c; c = c->next, n++);
+ rt = sqrt(n);
+ if(modff(rt, &fd) < 0.5)
+ rows = floor(rt);
+ else
+ rows = ceil(rt);
+ if(rows * rows < n)
+ cols = rows + 1;
+ else
+ cols = rows;
+
+ gw = (sw - 1) / cols;
+ gh = (sh - bh - 1) / rows;
+
+ for(i = j = 0, c = clients; c; c = c->next) {
+ c->x = i * gw;
+ c->y = j * gh + bh;
+ c->w = gw;
+ c->h = gh;
+ resize(c);
+ if(++i == cols) {
+ j++;
+ i = 0;
+ }
+ }
+}
+
+void
+sel(void *aux)
+{
+ const char *arg = aux;
+ Client *c = NULL;
+
+ if(!arg || !stack)
+ return;
+ if(!strncmp(arg, "next", 5))
+ c = stack->snext ? stack->snext : stack;
+ else if(!strncmp(arg, "prev", 5))
+ for(c = stack; c && c->snext; c = c->snext);
+ if(!c)
+ c = stack;
+ raise(c);
+ focus(c);
+}
+
+void
+kill(void *aux)
+{
+ Client *c = stack;
+
+ if(!c)
+ return;
+ if(c->proto & WM_PROTOCOL_DELWIN)
+ send_message(c->win, wm_atom[WMProtocols], wm_atom[WMDelete]);
+ else
+ XKillClient(dpy, c->win);
+}
+
static void
resize_title(Client *c)
{
@@ -113,7 +181,7 @@ focus(Client *c)
draw_client(old);
}
XUnmapWindow(dpy, c->title);
- draw_client(old);
+ draw_client(c);
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
XFlush(dpy);
}