# HG changeset patch
# User Anselm R. Garbe
# Date 1152775942 -7200
# Node ID cd30cce52b786000f9df4863e21e3d23753e0df8
# Parent e90449e0316770f2a9aeb1a8516a03535838f76d
added logo+description
diff -r e90449e03167 -r cd30cce52b78 Makefile
--- a/Makefile Thu Jul 13 01:55:54 2006 +0200
+++ b/Makefile Thu Jul 13 09:32:22 2006 +0200
@@ -1,18 +1,18 @@
-# gridwm - grid window manager
+# dwm - dynamic window manager
# (C)opyright MMVI Anselm R. Garbe
include config.mk
SRC = client.c draw.c event.c kb.c mouse.c util.c wm.c
OBJ = ${SRC:.c=.o}
-MAN1 = gridwm.1
-BIN = gridwm
+MAN1 = dwm.1
+BIN = dwm
-all: config gridwm
+all: config dwm
@echo finished
config:
- @echo gridwm build options:
+ @echo dwm build options:
@echo "LIBS = ${LIBS}"
@echo "CFLAGS = ${CFLAGS}"
@echo "LDFLAGS = ${LDFLAGS}"
@@ -24,19 +24,19 @@
${OBJ}: wm.h
-gridwm: ${OBJ}
+dwm: ${OBJ}
@echo LD $@
@${CC} -o $@ ${OBJ} ${LDFLAGS}
clean:
- rm -f gridwm *.o core
+ rm -f dwm *.o core
dist: clean
- mkdir -p gridwm-${VERSION}
- cp -R Makefile README LICENSE config.mk *.h *.c ${MAN} gridwm-${VERSION}
- tar -cf gridwm-${VERSION}.tar gridwm-${VERSION}
- gzip gridwm-${VERSION}.tar
- rm -rf gridwm-${VERSION}
+ mkdir -p dwm-${VERSION}
+ cp -R Makefile README LICENSE config.mk *.h *.c ${MAN} dwm-${VERSION}
+ tar -cf dwm-${VERSION}.tar dwm-${VERSION}
+ gzip dwm-${VERSION}.tar
+ rm -rf dwm-${VERSION}
install: all
@mkdir -p ${DESTDIR}${PREFIX}/bin
diff -r e90449e03167 -r cd30cce52b78 README
--- a/README Thu Jul 13 01:55:54 2006 +0200
+++ b/README Thu Jul 13 09:32:22 2006 +0200
@@ -1,41 +1,40 @@
-gridwm
+dwm
------
-gridwm is an extremly fast, small, and automatic X11 window manager. It
-arranges all windows in a grid.
+dwm is an extremly fast, small, and dynamic X11 window manager.
Requirements
------------
-In order to build gridwm you need the Xlib header files.
+In order to build dwm you need the Xlib header files.
Installation
------------
-Edit config.mk to match your local setup. gridwm is installed into
+Edit config.mk to match your local setup. dwm is installed into
the /usr/local namespace by default.
-Afterwards enter the following command to build and install gridwm (if
+Afterwards enter the following command to build and install dwm (if
necessary as root):
make clean install
-Running gridwm
+Running dwm
--------------
-Add the following line to your .xinitrc to start gridwm using startx:
+Add the following line to your .xinitrc to start dwm using startx:
- exec gridwm
+ exec dwm
-In order to connect gridwm to a specific display, make sure that
+In order to connect dwm to a specific display, make sure that
the DISPLAY environment variable is set correctly, e.g.:
- DISPLAY=foo.bar:1 exec gridwm
+ DISPLAY=foo.bar:1 exec dwm
-This will start gridwm on display :1 of the host foo.bar.
+This will start dwm on display :1 of the host foo.bar.
Configuration
-------------
-The configuration of gridwm is done by customizing the wm.h source file. To
+The configuration of dwm is done by customizing the wm.h source file. To
customize the key bindings edit kb.c.
diff -r e90449e03167 -r cd30cce52b78 client.c
--- a/client.c Thu Jul 13 01:55:54 2006 +0200
+++ b/client.c Thu Jul 13 09:32:22 2006 +0200
@@ -11,7 +11,9 @@
#include "wm.h"
-void (*arrange)(void *aux);
+static void floating(void);
+static void tiling(void);
+static void (*arrange)(void) = tiling;
void
max(void *aux)
@@ -26,25 +28,23 @@
discard_events(EnterWindowMask);
}
-void
-floating(void *aux)
+static void
+floating(void)
{
Client *c;
- arrange = floating;
for(c = stack; c; c = c->snext)
resize(c);
discard_events(EnterWindowMask);
}
-void
-grid(void *aux)
+static void
+tiling(void)
{
Client *c;
int n, cols, rows, gw, gh, i, j;
float rt, fd;
- arrange = grid;
if(!clients)
return;
for(n = 0, c = clients; c; c = c->next, n++);
@@ -76,6 +76,17 @@
}
void
+toggle(void *aux)
+{
+ if(arrange == floating)
+ arrange = tiling;
+ else
+ arrange = floating;
+ arrange();
+}
+
+
+void
sel(void *aux)
{
const char *arg = aux;
@@ -114,8 +125,8 @@
c->tw = 0;
for(i = 0; i < TLast; i++)
if(c->tags[i])
- c->tw += textw(&brush.font, c->tags[i]) + brush.font.height;
- c->tw += textw(&brush.font, c->name) + brush.font.height;
+ c->tw += textw(&dc.font, c->tags[i]) + dc.font.height;
+ c->tw += textw(&dc.font, c->name) + dc.font.height;
if(c->tw > c->w)
c->tw = c->w + 2;
c->tx = c->x + c->w - c->tw + 2;
@@ -240,7 +251,7 @@
c->border = 1;
update_size(c);
XSetWindowBorderWidth(dpy, c->win, 1);
- XSetWindowBorder(dpy, c->win, brush.border);
+ XSetWindowBorder(dpy, c->win, dc.border);
XSelectInput(dpy, c->win,
StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
XGetTransientForHint(dpy, c->win, &c->trans);
@@ -266,7 +277,7 @@
GrabModeAsync, GrabModeSync, None, None);
XGrabButton(dpy, Button3, Mod1Mask, c->win, False, ButtonPressMask,
GrabModeAsync, GrabModeSync, None, None);
- arrange(NULL);
+ arrange();
focus(c);
}
@@ -385,7 +396,7 @@
XFlush(dpy);
XSetErrorHandler(error_handler);
XUngrabServer(dpy);
- arrange(NULL);
+ arrange();
if(stack)
focus(stack);
}
@@ -417,21 +428,21 @@
if(c == stack)
return;
- brush.x = brush.y = 0;
- brush.h = c->th;
+ dc.x = dc.y = 0;
+ dc.h = c->th;
- brush.w = 0;
+ dc.w = 0;
for(i = 0; i < TLast; i++) {
if(c->tags[i]) {
- brush.x += brush.w;
- brush.w = textw(&brush.font, c->tags[i]) + brush.font.height;
- draw(&brush, True, c->tags[i]);
+ dc.x += dc.w;
+ dc.w = textw(&dc.font, c->tags[i]) + dc.font.height;
+ draw(True, c->tags[i]);
}
}
- brush.x += brush.w;
- brush.w = textw(&brush.font, c->name) + brush.font.height;
- draw(&brush, True, c->name);
- XCopyArea(dpy, brush.drawable, c->title, brush.gc,
+ dc.x += dc.w;
+ dc.w = textw(&dc.font, c->name) + dc.font.height;
+ draw(True, c->name);
+ XCopyArea(dpy, dc.drawable, c->title, dc.gc,
0, 0, c->tw, c->th, 0, 0);
XFlush(dpy);
}
diff -r e90449e03167 -r cd30cce52b78 config.mk
--- a/config.mk Thu Jul 13 01:55:54 2006 +0200
+++ b/config.mk Thu Jul 13 09:32:22 2006 +0200
@@ -14,14 +14,10 @@
LIBS = -L${PREFIX}/lib -L/usr/lib -lc -lm -L${X11LIB} -lX11
# Linux/BSD
-CFLAGS = -Os -I. -I${PREFIX}/include -I/usr/include -I${X11INC} \
+CFLAGS = -g -Wall -O2 -I. -I${PREFIX}/include -I/usr/include -I${X11INC} \
-DVERSION=\"${VERSION}\"
-LDFLAGS = ${LIBS}
-#CFLAGS += -W -Wstrict-prototypes -Wpointer-arith -Wcast-align -Wcast-qual -Wshadow -Waggregate-return -Wnested-externs -Winline -Wwrite-strings -Wundef -Wsign-compare -Wmissing-prototypes -Wredundant-decls
+LDFLAGS = -g ${LIBS}
-#CFLAGS = -g -Wall -O2 -I. -I${PREFIX}/include -I/usr/include -I${X11INC} \
-# -DVERSION=\"${VERSION}\"
-#LDFLAGS = -g ${LIBS}
# Solaris
#CFLAGS = -fast -xtarget=ultra ${INCLUDES} -DVERSION=\"${VERSION}\"
diff -r e90449e03167 -r cd30cce52b78 draw.c
--- a/draw.c Thu Jul 13 01:55:54 2006 +0200
+++ b/draw.c Thu Jul 13 09:32:22 2006 +0200
@@ -11,39 +11,39 @@
#include "wm.h"
static void
-drawborder(Brush *b)
+drawborder(void)
{
XPoint points[5];
- XSetLineAttributes(dpy, b->gc, 1, LineSolid, CapButt, JoinMiter);
- XSetForeground(dpy, b->gc, b->border);
- points[0].x = b->x;
- points[0].y = b->y;
- points[1].x = b->w - 1;
+ XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
+ XSetForeground(dpy, dc.gc, dc.border);
+ points[0].x = dc.x;
+ points[0].y = dc.y;
+ points[1].x = dc.w - 1;
points[1].y = 0;
points[2].x = 0;
- points[2].y = b->h - 1;
- points[3].x = -(b->w - 1);
+ points[2].y = dc.h - 1;
+ points[3].x = -(dc.w - 1);
points[3].y = 0;
points[4].x = 0;
- points[4].y = -(b->h - 1);
- XDrawLines(dpy, b->drawable, b->gc, points, 5, CoordModePrevious);
+ points[4].y = -(dc.h - 1);
+ XDrawLines(dpy, dc.drawable, dc.gc, points, 5, CoordModePrevious);
}
void
-draw(Brush *b, Bool border, const char *text)
+draw(Bool border, const char *text)
{
int x, y, w, h;
unsigned int len;
static char buf[256];
XGCValues gcv;
- XRectangle r = { b->x, b->y, b->w, b->h };
+ XRectangle r = { dc.x, dc.y, dc.w, dc.h };
- XSetForeground(dpy, b->gc, b->bg);
- XFillRectangles(dpy, b->drawable, b->gc, &r, 1);
+ XSetForeground(dpy, dc.gc, dc.bg);
+ XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
w = 0;
if(border)
- drawborder(b);
+ drawborder();
if(!text)
return;
@@ -54,33 +54,33 @@
memcpy(buf, text, len);
buf[len] = 0;
- h = b->font.ascent + b->font.descent;
- y = b->y + (b->h / 2) - (h / 2) + b->font.ascent;
- x = b->x + (h / 2);
+ h = dc.font.ascent + dc.font.descent;
+ y = dc.y + (dc.h / 2) - (h / 2) + dc.font.ascent;
+ x = dc.x + (h / 2);
/* shorten text if necessary */
- while(len && (w = textnw(&b->font, buf, len)) > b->w - h)
+ while(len && (w = textnw(&dc.font, buf, len)) > dc.w - h)
buf[--len] = 0;
- if(w > b->w)
+ if(w > dc.w)
return; /* too long */
- gcv.foreground = b->fg;
- gcv.background = b->bg;
- if(b->font.set) {
- XChangeGC(dpy, b->gc, GCForeground | GCBackground, &gcv);
- XmbDrawImageString(dpy, b->drawable, b->font.set, b->gc,
+ gcv.foreground = dc.fg;
+ gcv.background = dc.bg;
+ if(dc.font.set) {
+ XChangeGC(dpy, dc.gc, GCForeground | GCBackground, &gcv);
+ XmbDrawImageString(dpy, dc.drawable, dc.font.set, dc.gc,
x, y, buf, len);
}
else {
- gcv.font = b->font.xfont->fid;
- XChangeGC(dpy, b->gc, GCForeground | GCBackground | GCFont, &gcv);
- XDrawImageString(dpy, b->drawable, b->gc, x, y, buf, len);
+ gcv.font = dc.font.xfont->fid;
+ XChangeGC(dpy, dc.gc, GCForeground | GCBackground | GCFont, &gcv);
+ XDrawImageString(dpy, dc.drawable, dc.gc, x, y, buf, len);
}
}
static unsigned long
-xloadcolors(Colormap cmap, const char *colstr)
+xinitcolors(Colormap cmap, const char *colstr)
{
XColor color;
XAllocNamedColor(dpy, cmap, colstr, &color, &color);
@@ -88,13 +88,12 @@
}
void
-loadcolors(int scr, Brush *b,
- const char *bg, const char *fg, const char *border)
+initcolors(const char *bg, const char *fg, const char *border)
{
- Colormap cmap = DefaultColormap(dpy, scr);
- b->bg = xloadcolors(cmap, bg);
- b->fg = xloadcolors(cmap, fg);
- b->border = xloadcolors(cmap, border);
+ Colormap cmap = DefaultColormap(dpy, screen);
+ dc.bg = xinitcolors(cmap, bg);
+ dc.fg = xinitcolors(cmap, fg);
+ dc.border = xinitcolors(cmap, border);
}
unsigned int
@@ -121,7 +120,7 @@
}
void
-loadfont(Fnt *font, const char *fontstr)
+initfont(Fnt *font, const char *fontstr)
{
char **missing, *def;
int i, n;
@@ -164,7 +163,7 @@
if (!font->xfont)
font->xfont = XLoadQueryFont(dpy, "fixed");
if (!font->xfont)
- error("error, cannot load 'fixed' font\n");
+ error("error, cannot init 'fixed' font\n");
font->ascent = font->xfont->ascent;
font->descent = font->xfont->descent;
}
diff -r e90449e03167 -r cd30cce52b78 dwm.1
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dwm.1 Thu Jul 13 09:32:22 2006 +0200
@@ -0,0 +1,16 @@
+.TH GRIDWM 1 gridwm-0.0
+.SH NAME
+gridwm \- grid window manager
+.SH SYNOPSIS
+.B gridwm
+.RB [ \-v ]
+.SH DESCRIPTION
+.SS Overview
+.B gridwm
+is an automatic window manager for X11.
+.SS Options
+.TP
+.B \-v
+prints version information to stdout, then exits.
+.SH SEE ALSO
+.BR gridmenu (1)
diff -r e90449e03167 -r cd30cce52b78 dwm.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dwm.html Thu Jul 13 09:32:22 2006 +0200
@@ -0,0 +1,77 @@
+
+
+ dwm - dynamic window manager
+
+
+
+
+
+
+
+
+ dynamic window manager
+
+ Description
+
+ dwm is a dynamic window manager for X11.
+
+ Differences to wmii
+ In contrast to wmii, dwm is only a window manager, and nothing else.
+ Hence, it is much smaller, faster and simpler. dwm does
+ not include following features wmii provides:
+
+
+ - 9P support
+ - status bar
+ - menu
+ - editable tagbars
+ - shell-based config/control file
+ - small tools (selection printer, mouse warper)
+
+
+ dwm is only a single binary, it's source code is intended to never
+ exceed 2000 SLOC.
+
+
+ dwm is customized through editing its source code, that makes it
+ extremely fast and secure - it does not process any input data which
+ hasn't been known at compile time, except window title names.
+
+
+ dwm is based on tagging and dynamic window management (however simpler
+ than wmii or larswm).
+
+
+ dwm don't distinguishes between layers, there is no floating or managed
+ layer. Wether the clients of currently selected tag are managed or not
+ managed, you can re-arrange all clients on the fly. Popup- and
+ fixed-size windows are treated unmanaged.
+
+
+ dwm uses 1-pixel borders to provide the maximum of screen real
+ estate to clients. Small titlebars are only drawn in front of unfocused
+ clients.
+
+
+ garbeam don't wants any feedback to dwm. If you ask for support,
+ feature requests or if you report bugs, they will be ignored
+ with a high chance. dwm is only intended to fit garbeam's needs,
+ however you are free to download and distribute/relicense it, with the
+ conditions of the MIT/X Consortium license.
+
+ Development
+
+ dwm is actively developed in parallel to wmii. You can browse its source code repository or get a copy using Mercurial with following command:
+
+
+ hg clone http://wmii.de/cgi-bin/hgwebdir.cgi/dwm
+
+ --Anselm
+
+
diff -r e90449e03167 -r cd30cce52b78 gridwm.1
--- a/gridwm.1 Thu Jul 13 01:55:54 2006 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-.TH GRIDWM 1 gridwm-0.0
-.SH NAME
-gridwm \- grid window manager
-.SH SYNOPSIS
-.B gridwm
-.RB [ \-v ]
-.SH DESCRIPTION
-.SS Overview
-.B gridwm
-is an automatic window manager for X11.
-.SS Options
-.TP
-.B \-v
-prints version information to stdout, then exits.
-.SH SEE ALSO
-.BR gridmenu (1)
diff -r e90449e03167 -r cd30cce52b78 kb.c
--- a/kb.c Thu Jul 13 01:55:54 2006 +0200
+++ b/kb.c Thu Jul 13 09:32:22 2006 +0200
@@ -13,13 +13,14 @@
"aterm", "-tr", "+sb", "-bg", "black", "-fg", "white", "-fn",
"-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*",NULL
};
+const char *browse[] = { "firefox", NULL };
static Key key[] = {
{ Mod1Mask, XK_Return, (void (*)(void *))spawn, term },
+ { Mod1Mask, XK_w, (void (*)(void *))spawn, browse },
{ Mod1Mask, XK_k, sel, "prev" },
{ Mod1Mask, XK_j, sel, "next" },
- { Mod1Mask, XK_g, grid, NULL },
- { Mod1Mask, XK_f, floating, NULL },
+ { Mod1Mask, XK_space, toggle, NULL },
{ Mod1Mask, XK_m, max, NULL },
{ Mod1Mask | ShiftMask, XK_c, ckill, NULL },
{ Mod1Mask | ShiftMask, XK_q, quit, NULL },
diff -r e90449e03167 -r cd30cce52b78 logo.png
Binary file logo.png has changed
diff -r e90449e03167 -r cd30cce52b78 util.c
--- a/util.c Thu Jul 13 01:55:54 2006 +0200
+++ b/util.c Thu Jul 13 09:32:22 2006 +0200
@@ -85,7 +85,7 @@
close(ConnectionNumber(dpy));
setsid();
execvp(argv[0], argv);
- fprintf(stderr, "gridwm: execvp %s", argv[0]);
+ fprintf(stderr, "dwm: execvp %s", argv[0]);
perror(" failed");
}
exit (0);
diff -r e90449e03167 -r cd30cce52b78 wm.c
--- a/wm.c Thu Jul 13 01:55:54 2006 +0200
+++ b/wm.c Thu Jul 13 09:32:22 2006 +0200
@@ -37,17 +37,17 @@
int tsel = Tdev; /* default tag */
int screen, sx, sy, sw, sh, th;
-Brush brush = {0};
+DC dc = {0};
Client *clients = NULL;
Client *stack = NULL;
static Bool other_wm_running;
static const char version[] =
- "gridwm - " VERSION ", (C)opyright MMVI Anselm R. Garbe\n";
+ "dwm - " VERSION ", (C)opyright MMVI Anselm R. Garbe\n";
static int (*x_error_handler) (Display *, XErrorEvent *);
static void
-usage() { error("usage: gridwm [-v]\n"); }
+usage() { error("usage: dwm [-v]\n"); }
static void
scan_wins()
@@ -149,7 +149,7 @@
|| (error->request_code == X_GrabKey
&& error->error_code == BadAccess))
return 0;
- fprintf(stderr, "gridwm: fatal error: request code=%d, error code=%d\n",
+ fprintf(stderr, "dwm: fatal error: request code=%d, error code=%d\n",
error->request_code, error->error_code);
return x_error_handler(dpy, error); /* may call exit() */
}
@@ -203,7 +203,7 @@
dpy = XOpenDisplay(0);
if(!dpy)
- error("gridwm: cannot connect X server\n");
+ error("dwm: cannot connect X server\n");
screen = DefaultScreen(dpy);
root = RootWindow(dpy, screen);
@@ -216,7 +216,7 @@
XFlush(dpy);
if(other_wm_running)
- error("gridwm: another window manager is already running\n");
+ error("dwm: another window manager is already running\n");
sx = sy = 0;
sw = DisplayWidth(dpy, screen);
@@ -244,20 +244,19 @@
update_keys();
/* style */
- loadcolors(screen, &brush, BGCOLOR, FGCOLOR, BORDERCOLOR);
- loadfont(&brush.font, FONT);
+ initcolors(BGCOLOR, FGCOLOR, BORDERCOLOR);
+ initfont(&dc.font, FONT);
- th = texth(&brush.font);
+ th = texth(&dc.font);
- brush.drawable = XCreatePixmap(dpy, root, sw, th, DefaultDepth(dpy, screen));
- brush.gc = XCreateGC(dpy, root, 0, 0);
+ dc.drawable = XCreatePixmap(dpy, root, sw, th, DefaultDepth(dpy, screen));
+ dc.gc = XCreateGC(dpy, root, 0, 0);
wa.event_mask = SubstructureRedirectMask | EnterWindowMask \
| LeaveWindowMask;
wa.cursor = cursor[CurNormal];
XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa);
- arrange = grid;
scan_wins();
while(running) {
diff -r e90449e03167 -r cd30cce52b78 wm.h
--- a/wm.h Thu Jul 13 01:55:54 2006 +0200
+++ b/wm.h Thu Jul 13 09:32:22 2006 +0200
@@ -19,7 +19,7 @@
/********** CUSTOMIZE **********/
-typedef struct Brush Brush;
+typedef struct DC DC;
typedef struct Client Client;
typedef struct Fnt Fnt;
typedef struct Key Key;
@@ -39,7 +39,7 @@
int height;
};
-struct Brush {
+struct DC { /* draw context */
GC gc;
Drawable drawable;
int x, y, w, h;
@@ -79,12 +79,11 @@
extern Cursor cursor[CurLast];
extern Bool running, issel;
extern void (*handler[LASTEvent]) (XEvent *);
-extern void (*arrange)(void *aux);
extern int tsel, screen, sx, sy, sw, sh, th;
extern char stext[1024], *tags[TLast];
-extern Brush brush;
+extern DC dc;
extern Client *clients, *stack;
/* client.c */
@@ -102,15 +101,13 @@
extern void ckill(void *aux);
extern void sel(void *aux);
extern void max(void *aux);
-extern void floating(void *aux);
-extern void grid(void *aux);
+extern void toggle(void *aux);
extern void gravitate(Client *c, Bool invert);
/* draw.c */
-extern void draw(Brush *b, Bool border, const char *text);
-extern void loadcolors(int scr, Brush *b,
- const char *bg, const char *fg, const char *bo);
-extern void loadfont(Fnt *font, const char *fontstr);
+extern void draw(Bool border, const char *text);
+extern void initcolors(const char *bg, const char *fg, const char *bo);
+extern void initfont(Fnt *font, const char *fontstr);
extern unsigned int textnw(Fnt *font, char *text, unsigned int len);
extern unsigned int textw(Fnt *font, char *text);
extern unsigned int texth(Fnt *font);