about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--bar.c54
-rw-r--r--client.c230
-rw-r--r--draw.c67
-rw-r--r--dwm.h31
-rw-r--r--event.c96
-rw-r--r--key.c (renamed from dev.c)169
-rw-r--r--main.c2
-rw-r--r--screen.c100
9 files changed, 374 insertions, 377 deletions
diff --git a/Makefile b/Makefile
index 536960b..e2caadd 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@
 
 include config.mk
 
-SRC = bar.c client.c dev.c draw.c event.c main.c util.c
+SRC = client.c draw.c event.c key.c main.c screen.c util.c
 OBJ = ${SRC:.c=.o}
 MAN1 = dwm.1 
 BIN = dwm
diff --git a/bar.c b/bar.c
deleted file mode 100644
index 3027bc2..0000000
--- a/bar.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
- * See LICENSE file for license details.
- */
-
-#include "dwm.h"
-
-void
-barclick(XButtonPressedEvent *e)
-{
-	int x = 0;
-	Arg a;
-	for(a.i = 0; a.i < TLast; a.i++) {
-		x += textw(tags[a.i]) + dc.font.height;
-		if(e->x < x) {
-			view(&a);
-			return;
-		}
-	}
-}
-
-void
-draw_bar()
-{
-	int i, modw;
-	char *mode = arrange == tiling ? "#" : "~";
-
-	dc.x = dc.y = 0;
-	dc.w = bw;
-	drawtext(NULL, False, False);
-
-	modw = textw(mode) + dc.font.height;
-	dc.w = 0;
-	for(i = 0; i < TLast; i++) {
-		dc.x += dc.w;
-		dc.w = textw(tags[i]) + dc.font.height;
-		drawtext(tags[i], i == tsel, True);
-	}
-	if(sel) {
-		dc.x += dc.w;
-		dc.w = textw(sel->name) + dc.font.height;
-		drawtext(sel->name, True, True);
-	}
-	dc.w = textw(stext) + dc.font.height;
-	dc.x = bx + bw - dc.w - modw;
-	drawtext(stext, False, False);
-
-	dc.x = bx + bw - modw;
-	dc.w = modw;
-	drawtext(mode, True, True);
-
-	XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0);
-	XFlush(dpy);
-}
diff --git a/client.c b/client.c
index 5b666c9..63fb1e5 100644
--- a/client.c
+++ b/client.c
@@ -11,14 +11,12 @@
 
 #include "dwm.h"
 
-void (*arrange)(Arg *) = tiling;
-
 static Rule rule[] = {
 	/* class			instance	tags						floating */
 	{ "Firefox-bin",	"Gecko",	{ [Twww] = "www" },			False },
 };
 
-static Client *
+Client *
 next(Client *c)
 {
 	for(; c && !c->tags[tsel]; c = c->next);
@@ -26,202 +24,12 @@ next(Client *c)
 }
 
 void
-zoom(Arg *arg)
-{
-	Client **l, *c;
-
-	if(!sel)
-		return;
-
-	if(sel == next(clients) && sel->next)  {
-		if((c = next(sel->next)))
-			sel = c;
-	}
-
-	for(l = &clients; *l && *l != sel; l = &(*l)->next);
-	*l = sel->next;
-
-	sel->next = clients; /* pop */
-	clients = sel;
-	arrange(NULL);
-	focus(sel);
-}
-
-void
-max(Arg *arg)
-{
-	if(!sel)
-		return;
-	sel->x = sx;
-	sel->y = sy + bh;
-	sel->w = sw - 2 * sel->border;
-	sel->h = sh - 2 * sel->border - bh;
-	craise(sel);
-	resize(sel, False);
-}
-
-void
-view(Arg *arg)
-{
-	Client *c;
-
-	tsel = arg->i;
-	arrange(NULL);
-
-	for(c = clients; c; c = next(c->next))
-		draw_client(c);
-	draw_bar();
-}
-
-void
-tappend(Arg *arg)
-{
-	if(!sel)
-		return;
-
-	sel->tags[arg->i] = tags[arg->i];
-	arrange(NULL);
-}
-
-void
-ttrunc(Arg *arg)
-{
-	int i;
-	if(!sel)
-		return;
-
-	for(i = 0; i < TLast; i++)
-		sel->tags[i] = NULL;
-	tappend(arg);
-}
-
-static void
 ban_client(Client *c)
 {
 	XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
 	XMoveWindow(dpy, c->title, c->tx + 2 * sw, c->ty);
 }
 
-void
-floating(Arg *arg)
-{
-	Client *c;
-
-	arrange = floating;
-	for(c = clients; c; c = c->next) {
-		if(c->tags[tsel])
-			resize(c, True);
-		else
-			ban_client(c);
-	}
-	if(sel && !sel->tags[tsel]) {
-		if((sel = next(clients))) {
-			craise(sel);
-			focus(sel);
-		}
-	}
-	draw_bar();
-}
-
-void
-tiling(Arg *arg)
-{
-	Client *c;
-	int n, i, w, h;
-
-	w = sw - mw;
-	arrange = tiling;
-	for(n = 0, c = clients; c; c = c->next)
-		if(c->tags[tsel] && !c->floating)
-			n++;
-
-	if(n > 1)
-		h = (sh - bh) / (n - 1);
-	else
-		h = sh - bh;
-
-	for(i = 0, c = clients; c; c = c->next) {
-		if(c->tags[tsel]) {
-			if(c->floating) {
-				craise(c);
-				resize(c, True);
-				continue;
-			}
-			if(n == 1) {
-				c->x = sx;
-				c->y = sy + bh;
-				c->w = sw - 2 * c->border;
-				c->h = sh - 2 * c->border - bh;
-			}
-			else if(i == 0) {
-				c->x = sx;
-				c->y = sy + bh;
-				c->w = mw - 2 * c->border;
-				c->h = sh - 2 * c->border - bh;
-			}
-			else {
-				c->x = sx + mw;
-				c->y = sy + (i - 1) * h + bh;
-				c->w = w - 2 * c->border;
-				c->h = h - 2 * c->border;
-			}
-			resize(c, False);
-			i++;
-		}
-		else
-			ban_client(c);
-	}
-	if(!sel || (sel && !sel->tags[tsel])) {
-		if((sel = next(clients))) {
-			craise(sel);
-			focus(sel);
-		}
-	}
-	draw_bar();
-}
-
-void
-prevc(Arg *arg)
-{
-	Client *c;
-
-	if(!sel)
-		return;
-
-	if((c = sel->revert && sel->revert->tags[tsel] ? sel->revert : NULL)) {
-		craise(c);
-		focus(c);
-	}
-}
-
-void
-nextc(Arg *arg)
-{
-	Client *c;
-   
-	if(!sel)
-		return;
-
-	if(!(c = next(sel->next)))
-		c = next(clients);
-	if(c) {
-		craise(c);
-		c->revert = sel;
-		focus(c);
-	}
-}
-
-void
-ckill(Arg *arg)
-{
-	if(!sel)
-		return;
-	if(sel->proto & WM_PROTOCOL_DELWIN)
-		send_message(sel->win, wm_atom[WMProtocols], wm_atom[WMDelete]);
-	else
-		XKillClient(dpy, sel->win);
-}
-
 static void
 resize_title(Client *c)
 {
@@ -230,8 +38,8 @@ resize_title(Client *c)
 	c->tw = 0;
 	for(i = 0; i < TLast; i++)
 		if(c->tags[i])
-			c->tw += textw(c->tags[i]) + dc.font.height;
-	c->tw += textw(c->name) + dc.font.height;
+			c->tw += textw(c->tags[i]);
+	c->tw += textw(c->name);
 	if(c->tw > c->w)
 		c->tw = c->w + 2;
 	c->tx = c->x + c->w - c->tw + 2;
@@ -584,35 +392,3 @@ getclient(Window w)
 			return c;
 	return NULL;
 }
-
-void
-draw_client(Client *c)
-{
-	int i;
-	if(c == sel) {
-		draw_bar();
-		XUnmapWindow(dpy, c->title);
-		XSetWindowBorder(dpy, c->win, dc.fg);
-		return;
-	}
-
-	XSetWindowBorder(dpy, c->win, dc.bg);
-	XMapWindow(dpy, c->title);
-
-	dc.x = dc.y = 0;
-
-	dc.w = 0;
-	for(i = 0; i < TLast; i++) {
-		if(c->tags[i]) {
-			dc.x += dc.w;
-			dc.w = textw(c->tags[i]) + dc.font.height;
-			drawtext(c->tags[i], False, True);
-		}
-	}
-	dc.x += dc.w;
-	dc.w = textw(c->name) + dc.font.height;
-	drawtext(c->name, False, True);
-	XCopyArea(dpy, dc.drawable, c->title, dc.gc,
-			0, 0, c->tw, c->th, 0, 0);
-	XFlush(dpy);
-}
diff --git a/draw.c b/draw.c
index 3fbc85c..5bb6fc2 100644
--- a/draw.c
+++ b/draw.c
@@ -10,6 +10,71 @@
 
 #include "dwm.h"
 
+void
+draw_bar()
+{
+	int i;
+
+	dc.x = dc.y = 0;
+	dc.w = bw;
+	drawtext(NULL, False, False);
+
+	if(arrange == floating) {
+		dc.w = textw("~");
+		drawtext("~", False, False);
+	}
+	else
+		dc.w = 0;
+	for(i = 0; i < TLast; i++) {
+		dc.x += dc.w;
+		dc.w = textw(tags[i]);
+		drawtext(tags[i], i == tsel, True);
+	}
+	if(sel) {
+		dc.x += dc.w;
+		dc.w = textw(sel->name);
+		drawtext(sel->name, True, True);
+	}
+	dc.w = textw(stext);
+	dc.x = bx + bw - dc.w;
+	drawtext(stext, False, False);
+
+	XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0);
+	XFlush(dpy);
+}
+
+void
+draw_client(Client *c)
+{
+	int i;
+	if(c == sel) {
+		draw_bar();
+		XUnmapWindow(dpy, c->title);
+		XSetWindowBorder(dpy, c->win, dc.fg);
+		return;
+	}
+
+	XSetWindowBorder(dpy, c->win, dc.bg);
+	XMapWindow(dpy, c->title);
+
+	dc.x = dc.y = 0;
+
+	dc.w = 0;
+	for(i = 0; i < TLast; i++) {
+		if(c->tags[i]) {
+			dc.x += dc.w;
+			dc.w = textw(c->tags[i]);
+			drawtext(c->tags[i], False, True);
+		}
+	}
+	dc.x += dc.w;
+	dc.w = textw(c->name);
+	drawtext(c->name, False, True);
+	XCopyArea(dpy, dc.drawable, c->title, dc.gc,
+			0, 0, c->tw, c->th, 0, 0);
+	XFlush(dpy);
+}
+
 static void
 drawborder(void)
 {
@@ -103,7 +168,7 @@ textnw(char *text, unsigned int len)
 unsigned int
 textw(char *text)
 {
-	return textnw(text, strlen(text));
+	return textnw(text, strlen(text)) + dc.font.height;
 }
 
 void
diff --git a/dwm.h b/dwm.h
index 6843870..ba12527 100644
--- a/dwm.h
+++ b/dwm.h
@@ -94,6 +94,7 @@ extern Cursor cursor[CurLast];
 extern Bool running, issel;
 extern void (*handler[LASTEvent])(XEvent *);
 extern void (*arrange)(Arg *);
+extern Key key[];
 
 extern int tsel, screen, sx, sy, sw, sh, bx, by, bw, bh, mw;
 extern char *tags[TLast], stext[1024];
@@ -101,35 +102,24 @@ extern char *tags[TLast], stext[1024];
 extern DC dc;
 extern Client *clients, *sel;
 
-/* bar.c */
-extern void draw_bar();
-extern void barclick(XButtonPressedEvent *e);
-
 /* client.c */
 extern void manage(Window w, XWindowAttributes *wa);
 extern void unmanage(Client *c);
 extern Client *getclient(Window w);
 extern void focus(Client *c);
 extern void update_name(Client *c);
-extern void draw_client(Client *c);
 extern void resize(Client *c, Bool inc);
 extern void update_size(Client *c);
 extern Client *gettitle(Window w);
 extern void craise(Client *c);
 extern void lower(Client *c);
-extern void ckill(Arg *arg);
-extern void nextc(Arg *arg);
-extern void prevc(Arg *arg);
-extern void max(Arg *arg);
-extern void floating(Arg *arg);
-extern void tiling(Arg *arg);
-extern void ttrunc(Arg *arg);
-extern void tappend(Arg *arg);
-extern void view(Arg *arg);
-extern void zoom(Arg *arg);
 extern void gravitate(Client *c, Bool invert);
+extern void ban_client(Client *c);
+extern Client *next(Client *c);
 
 /* draw.c */
+extern void draw_bar();
+extern void draw_client(Client *c);
 extern void drawtext(const char *text, Bool invert, Bool border);
 extern unsigned long initcolor(const char *colstr);
 extern void initfont(const char *fontstr);
@@ -137,11 +127,9 @@ extern unsigned int textnw(char *text, unsigned int len);
 extern unsigned int textw(char *text);
 extern unsigned int texth(void);
 
-/* dev.c */
-extern void update_keys(void);
+/* key.c */
+extern void grabkeys();
 extern void keypress(XEvent *e);
-extern void mresize(Client *c);
-extern void mmove(Client *c);
 
 /* main.c */
 extern int error_handler(Display *dsply, XErrorEvent *e);
@@ -149,6 +137,11 @@ extern void send_message(Window w, Atom a, long value);
 extern int win_proto(Window w);
 extern void quit(Arg *arg);
 
+/* screen.c */
+extern void floating(Arg *arg);
+extern void tiling(Arg *arg);
+extern void view(Arg *arg);
+
 /* util.c */
 extern void error(const char *errstr, ...);
 extern void *emallocz(unsigned int size);
diff --git a/event.c b/event.c
index 61dcec5..b369ede 100644
--- a/event.c
+++ b/event.c
@@ -7,11 +7,15 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
 #include <X11/keysym.h>
 #include <X11/Xatom.h>
 
 #include "dwm.h"
 
+#define ButtonMask      (ButtonPressMask | ButtonReleaseMask)
+#define MouseMask       (ButtonMask | PointerMotionMask)
+
 /* local functions */
 static void buttonpress(XEvent *e);
 static void configurerequest(XEvent *e);
@@ -19,7 +23,6 @@ static void destroynotify(XEvent *e);
 static void enternotify(XEvent *e);
 static void leavenotify(XEvent *e);
 static void expose(XEvent *e);
-static void keymapnotify(XEvent *e);
 static void maprequest(XEvent *e);
 static void propertynotify(XEvent *e);
 static void unmapnotify(XEvent *e);
@@ -32,21 +35,100 @@ void (*handler[LASTEvent]) (XEvent *) = {
 	[LeaveNotify] = leavenotify,
 	[Expose] = expose,
 	[KeyPress] = keypress,
-	[KeymapNotify] = keymapnotify,
 	[MapRequest] = maprequest,
 	[PropertyNotify] = propertynotify,
 	[UnmapNotify] = unmapnotify
 };
 
 static void
+mresize(Client *c)
+{
+	XEvent ev;
+	int ocx, ocy;
+
+	ocx = c->x;
+	ocy = c->y;
+	if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync,
+				None, cursor[CurResize], CurrentTime) != GrabSuccess)
+		return;
+	XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h);
+	for(;;) {
+		XMaskEvent(dpy, MouseMask | ExposureMask, &ev);
+		switch(ev.type) {
+		default: break;
+		case Expose:
+			handler[Expose](&ev);
+			break;
+		case MotionNotify:
+			XFlush(dpy);
+			c->w = abs(ocx - ev.xmotion.x);
+			c->h = abs(ocy - ev.xmotion.y);
+			c->x = (ocx <= ev.xmotion.x) ? ocx : ocx - c->w;
+			c->y = (ocy <= ev.xmotion.y) ? ocy : ocy - c->h;
+			resize(c, True);
+			break;
+		case ButtonRelease:
+			XUngrabPointer(dpy, CurrentTime);
+			return;
+		}
+	}
+}
+
+static void
+mmove(Client *c)
+{
+	XEvent ev;
+	int x1, y1, ocx, ocy, di;
+	unsigned int dui;
+	Window dummy;
+
+	ocx = c->x;
+	ocy = c->y;
+	if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync,
+				None, cursor[CurMove], CurrentTime) != GrabSuccess)
+		return;
+	XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui);
+	for(;;) {
+		XMaskEvent(dpy, MouseMask | ExposureMask, &ev);
+		switch (ev.type) {
+		default: break;
+		case Expose:
+			handler[Expose](&ev);
+			break;
+		case MotionNotify:
+			XFlush(dpy);
+			c->x = ocx + (ev.xmotion.x - x1);
+			c->y = ocy + (ev.xmotion.y - y1);
+			resize(c, False);
+			break;
+		case ButtonRelease:
+			XUngrabPointer(dpy, CurrentTime);
+			return;
+		}
+	}
+}
+
+static void
 buttonpress(XEvent *e)
 {
+	int x;
+	Arg a;
 	XButtonPressedEvent *ev = &e->xbutton;
 	Client *c;
 
-	if(barwin == ev->window)
-		barclick(ev);
+	if(barwin == ev->window) {
+		x = (arrange == floating) ? textw("~") : 0;
+		for(a.i = 0; a.i < TLast; a.i++) {
+			x += textw(tags[a.i]);
+			if(ev->x < x) {
+				view(&a);
+				break;
+			}
+		}
+	}
 	else if((c = getclient(ev->window))) {
+		if(arrange == tiling && !c->floating)
+			return;
 		craise(c);
 		switch(ev->button) {
 		default:
@@ -150,12 +232,6 @@ expose(XEvent *e)
 }
 
 static void
-keymapnotify(XEvent *e)
-{
-	update_keys();
-}
-
-static void
 maprequest(XEvent *e)
 {
 	XMapRequestEvent *ev = &e->xmaprequest;
diff --git a/dev.c b/key.c
index 7f500d9..8fb1c34 100644
--- a/dev.c
+++ b/key.c
@@ -3,12 +3,23 @@
  * See LICENSE file for license details.
  */
 
-#include "dwm.h"
-
+#include <fcntl.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 #include <X11/keysym.h>
+#include <X11/Xatom.h>
+
+#include "dwm.h"
+
+static void ckill(Arg *arg);
+static void nextc(Arg *arg);
+static void prevc(Arg *arg);
+static void max(Arg *arg);
+static void ttrunc(Arg *arg);
+static void tappend(Arg *arg);
+static void zoom(Arg *arg);
 
 /********** CUSTOMIZE **********/
 
@@ -19,7 +30,7 @@ const char *term[] = {
 const char *browse[] = { "firefox", NULL };
 const char *xlock[] = { "xlock", NULL };
 
-static Key key[] = {
+Key key[] = {
 	/* modifier				key			function	arguments */
 	{ Mod1Mask,				XK_Return,	zoom,		{ 0 } },
 	{ Mod1Mask,				XK_k,		prevc,		{ 0 } },
@@ -49,7 +60,7 @@ static Key key[] = {
 /********** CUSTOMIZE **********/
 
 void
-update_keys(void)
+grabkeys()
 {
 	static unsigned int len = key ? sizeof(key) / sizeof(key[0]) : 0;
 	unsigned int i;
@@ -58,7 +69,8 @@ update_keys(void)
 	for(i = 0; i < len; i++) {
 		code = XKeysymToKeycode(dpy, key[i].keysym);
 		XUngrabKey(dpy, code, key[i].mod, root);
-		XGrabKey(dpy, code, key[i].mod, root, True, GrabModeAsync, GrabModeAsync);
+		XGrabKey(dpy, code, key[i].mod, root, True,
+				GrabModeAsync, GrabModeAsync);
 	}
 }
 
@@ -79,73 +91,102 @@ keypress(XEvent *e)
 		}
 }
 
-#define ButtonMask      (ButtonPressMask | ButtonReleaseMask)
-#define MouseMask       (ButtonMask | PointerMotionMask)
+static void
+zoom(Arg *arg)
+{
+	Client **l, *c;
 
-void
-mresize(Client *c)
+	if(!sel)
+		return;
+
+	if(sel == next(clients) && sel->next)  {
+		if((c = next(sel->next)))
+			sel = c;
+	}
+
+	for(l = &clients; *l && *l != sel; l = &(*l)->next);
+	*l = sel->next;
+
+	sel->next = clients; /* pop */
+	clients = sel;
+	arrange(NULL);
+	focus(sel);
+}
+
+static void
+max(Arg *arg)
 {
-	XEvent ev;
-	int ocx, ocy;
+	if(!sel)
+		return;
+	sel->x = sx;
+	sel->y = sy + bh;
+	sel->w = sw - 2 * sel->border;
+	sel->h = sh - 2 * sel->border - bh;
+	craise(sel);
+	resize(sel, False);
+}
 
-	ocx = c->x;
-	ocy = c->y;
-	if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync,
-				None, cursor[CurResize], CurrentTime) != GrabSuccess)
+static void
+tappend(Arg *arg)
+{
+	if(!sel)
 		return;
-	XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h);
-	for(;;) {
-		XMaskEvent(dpy, MouseMask | ExposureMask, &ev);
-		switch(ev.type) {
-		default: break;
-		case Expose:
-			handler[Expose](&ev);
-			break;
-		case MotionNotify:
-			XFlush(dpy);
-			c->w = abs(ocx - ev.xmotion.x);
-			c->h = abs(ocy - ev.xmotion.y);
-			c->x = (ocx <= ev.xmotion.x) ? ocx : ocx - c->w;
-			c->y = (ocy <= ev.xmotion.y) ? ocy : ocy - c->h;
-			resize(c, True);
-			break;
-		case ButtonRelease:
-			XUngrabPointer(dpy, CurrentTime);
-			return;
-		}
+
+	sel->tags[arg->i] = tags[arg->i];
+	arrange(NULL);
+}
+
+static void
+ttrunc(Arg *arg)
+{
+	int i;
+	if(!sel)
+		return;
+
+	for(i = 0; i < TLast; i++)
+		sel->tags[i] = NULL;
+	tappend(arg);
+}
+
+static void
+prevc(Arg *arg)
+{
+	Client *c;
+
+	if(!sel)
+		return;
+
+	if((c = sel->revert && sel->revert->tags[tsel] ? sel->revert : NULL)) {
+		craise(c);
+		focus(c);
 	}
 }
 
-void
-mmove(Client *c)
+static void
+nextc(Arg *arg)
 {
-	XEvent ev;
-	int x1, y1, ocx, ocy, di;
-	unsigned int dui;
-	Window dummy;
-
-	ocx = c->x;
-	ocy = c->y;
-	if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync,
-				None, cursor[CurMove], CurrentTime) != GrabSuccess)
+	Client *c;
+   
+	if(!sel)
 		return;
-	XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui);
-	for(;;) {
-		XMaskEvent(dpy, MouseMask | ExposureMask, &ev);
-		switch (ev.type) {
-		default: break;
-		case Expose:
-			handler[Expose](&ev);
-			break;
-		case MotionNotify:
-			XFlush(dpy);
-			c->x = ocx + (ev.xmotion.x - x1);
-			c->y = ocy + (ev.xmotion.y - y1);
-			resize(c, False);
-			break;
-		case ButtonRelease:
-			XUngrabPointer(dpy, CurrentTime);
-			return;
-		}
+
+	if(!(c = next(sel->next)))
+		c = next(clients);
+	if(c) {
+		craise(c);
+		c->revert = sel;
+		focus(c);
 	}
 }
+
+static void
+ckill(Arg *arg)
+{
+	if(!sel)
+		return;
+	if(sel->proto & WM_PROTOCOL_DELWIN)
+		send_message(sel->win, wm_atom[WMProtocols], wm_atom[WMDelete]);
+	else
+		XKillClient(dpy, sel->win);
+}
+
diff --git a/main.c b/main.c
index b59ff96..5c0ef0d 100644
--- a/main.c
+++ b/main.c
@@ -239,7 +239,7 @@ main(int argc, char *argv[])
 	cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
 	cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur);
 
-	update_keys();
+	grabkeys();
 
 	/* style */
 	dc.bg = initcolor(BGCOLOR);
diff --git a/screen.c b/screen.c
new file mode 100644
index 0000000..f2891cf
--- /dev/null
+++ b/screen.c
@@ -0,0 +1,100 @@
+/*
+ * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
+ * See LICENSE file for license details.
+ */
+
+#include "dwm.h"
+
+void (*arrange)(Arg *) = tiling;
+
+void
+view(Arg *arg)
+{
+	Client *c;
+
+	tsel = arg->i;
+	arrange(NULL);
+
+	for(c = clients; c; c = next(c->next))
+		draw_client(c);
+	draw_bar();
+}
+
+void
+floating(Arg *arg)
+{
+	Client *c;
+
+	arrange = floating;
+	for(c = clients; c; c = c->next) {
+		if(c->tags[tsel])
+			resize(c, True);
+		else
+			ban_client(c);
+	}
+	if(sel && !sel->tags[tsel]) {
+		if((sel = next(clients))) {
+			craise(sel);
+			focus(sel);
+		}
+	}
+	draw_bar();
+}
+
+void
+tiling(Arg *arg)
+{
+	Client *c;
+	int n, i, w, h;
+
+	w = sw - mw;
+	arrange = tiling;
+	for(n = 0, c = clients; c; c = c->next)
+		if(c->tags[tsel] && !c->floating)
+			n++;
+
+	if(n > 1)
+		h = (sh - bh) / (n - 1);
+	else
+		h = sh - bh;
+
+	for(i = 0, c = clients; c; c = c->next) {
+		if(c->tags[tsel]) {
+			if(c->floating) {
+				craise(c);
+				resize(c, True);
+				continue;
+			}
+			if(n == 1) {
+				c->x = sx;
+				c->y = sy + bh;
+				c->w = sw - 2 * c->border;
+				c->h = sh - 2 * c->border - bh;
+			}
+			else if(i == 0) {
+				c->x = sx;
+				c->y = sy + bh;
+				c->w = mw - 2 * c->border;
+				c->h = sh - 2 * c->border - bh;
+			}
+			else {
+				c->x = sx + mw;
+				c->y = sy + (i - 1) * h + bh;
+				c->w = w - 2 * c->border;
+				c->h = h - 2 * c->border;
+			}
+			resize(c, False);
+			i++;
+		}
+		else
+			ban_client(c);
+	}
+	if(!sel || (sel && !sel->tags[tsel])) {
+		if((sel = next(clients))) {
+			craise(sel);
+			focus(sel);
+		}
+	}
+	draw_bar();
+}
+
tik.com> 2015-05-06 00:19:03 -0700 committer Kartik K. Agaram <vc@akkartik.com> 2015-05-06 00:19:03 -0700 1279 - colorized rendering of the source files' href='/akkartik/mu/commit/html/077tangle.cc.html?h=hlt&id=672e3e50c6ed6de161e40aa256c3fc0f2b1f7cf9'>672e3e50 ^
0e4a335e ^
9570363a ^
672e3e50 ^
0e4a335e ^
9570363a ^
672e3e50 ^
0e4a335e ^
9570363a ^
672e3e50 ^
0e4a335e ^
9570363a ^
672e3e50 ^














9570363a ^
0e4a335e ^
9570363a ^
672e3e50 ^
0e4a335e ^
9570363a ^

672e3e50 ^
0e4a335e ^
9570363a ^

672e3e50 ^












eaeb9552 ^
0e4a335e ^
eaeb9552 ^




0e4a335e ^
eaeb9552 ^
672e3e50 ^
0e4a335e ^
eaeb9552 ^
672e3e50 ^
0e4a335e ^
eaeb9552 ^
672e3e50 ^
eaeb9552 ^

672e3e50 ^
eaeb9552 ^




672e3e50 ^
eaeb9552 ^







0e4a335e ^

eaeb9552 ^

0e4a335e ^
eaeb9552 ^

0e4a335e ^
eaeb9552 ^















0e4a335e ^

eaeb9552 ^

0e4a335e ^
eaeb9552 ^

0e4a335e ^
eaeb9552 ^

0e4a335e ^

eaeb9552 ^





0e4a335e ^
eaeb9552 ^

672e3e50 ^

0e4a335e ^































































672e3e50 ^



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458