From 650a1fb4e1a798aca48a53739f5bb2649191bc1c Mon Sep 17 00:00:00 2001 From: "Anselm R. Garbe" Date: Thu, 13 Jul 2006 09:32:22 +0200 Subject: [PATCH] added logo+description --- Makefile | 24 +++++++++---------- README | 25 ++++++++++---------- client.c | 55 +++++++++++++++++++++++++------------------ config.mk | 8 ++----- draw.c | 73 +++++++++++++++++++++++++++++---------------------------- dwm.1 | 16 +++++++++++++ dwm.html | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ gridwm.1 | 16 ------------- kb.c | 5 ++-- logo.png | Bin 0 -> 387 bytes util.c | 2 +- wm.c | 23 +++++++++--------- wm.h | 17 ++++++-------- 13 files changed, 210 insertions(+), 131 deletions(-) create mode 100644 dwm.1 create mode 100644 dwm.html delete mode 100644 gridwm.1 create mode 100644 logo.png diff --git a/Makefile b/Makefile index 74ef9ed..35963ce 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ config: ${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 --git a/README b/README index 55fe9cd..c8e24ef 100644 --- a/README +++ b/README @@ -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 --git a/client.c b/client.c index 6777473..679e2be 100644 --- a/client.c +++ b/client.c @@ -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 @@ max(void *aux) 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 @@ grid(void *aux) } 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 @@ resize_title(Client *c) 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 @@ manage(Window w, XWindowAttributes *wa) 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 @@ manage(Window w, XWindowAttributes *wa) 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 @@ unmanage(Client *c) XFlush(dpy); XSetErrorHandler(error_handler); XUngrabServer(dpy); - arrange(NULL); + arrange(); if(stack) focus(stack); } @@ -417,21 +428,21 @@ draw_client(Client *c) 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 --git a/config.mk b/config.mk index 9857f93..33edcd7 100644 --- a/config.mk +++ b/config.mk @@ -14,14 +14,10 @@ VERSION = 0.0 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 --git a/draw.c b/draw.c index 1046322..455c137 100644 --- a/draw.c +++ b/draw.c @@ -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 @@ draw(Brush *b, Bool border, const char *text) 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 @@ xloadcolors(Colormap cmap, const char *colstr) } 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 @@ texth(Fnt *font) } void -loadfont(Fnt *font, const char *fontstr) +initfont(Fnt *font, const char *fontstr) { char **missing, *def; int i, n; @@ -164,7 +163,7 @@ loadfont(Fnt *font, const char *fontstr) 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 --git a/dwm.1 b/dwm.1 new file mode 100644 index 0000000..02a6b6a --- /dev/null +++ b/dwm.1 @@ -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 --git a/dwm.html b/dwm.html new file mode 100644 index 0000000..b617c8c --- /dev/null +++ b/dwm.html @@ -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 --git a/gridwm.1 b/gridwm.1 deleted file mode 100644 index 02a6b6a..0000000 --- a/gridwm.1 +++ /dev/null @@ -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 --git a/kb.c b/kb.c index f93f69f..5999c6e 100644 --- a/kb.c +++ b/kb.c @@ -13,13 +13,14 @@ const char *term[] = { "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 --git a/logo.png b/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..ebfc8ed302f579f3f0cd9be9831879c5d0619180 GIT binary patch literal 387 zcmeAS@N?(olHy`uVBq!ia0vp^2Y@($gAGXf@2YYEQfx`y?k)`fL2$v|<&%LToCO|{ z#S9GG!XV7ZFl&wkP>{XE)7O>#8apqWq2Pm=Tx)?svL&t&CC>S|xv6<249-QVi6yBi z3gww4844j8sS56%z5(x3RP%repL@DEhE&{od-oz|g8`4jLAPE1PZhE=w@uj1=%U;I zZSmC;XN)6VrpPH6Ki+Wdv8V!r00RdD3j-4aV*`T&1JT?A_IY1_|GHiJfBu0VGZ}Gc z1R9yJGk#J{QmyWJZX4b_MlljLrZ4u Uzb?=1Krb_Ry85}Sb4q9e0GhUC{r~^~ literal 0 HcmV?d00001 diff --git a/util.c b/util.c index 09fd872..0a5bd96 100644 --- a/util.c +++ b/util.c @@ -85,7 +85,7 @@ spawn(char *argv[]) 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 --git a/wm.c b/wm.c index 6d67bfc..ed002f7 100644 --- a/wm.c +++ b/wm.c @@ -37,17 +37,17 @@ char stext[1024]; 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_handler(Display *dpy, XErrorEvent *error) || (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 @@ main(int argc, char *argv[]) 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 @@ main(int argc, char *argv[]) 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 @@ main(int argc, char *argv[]) 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 --git a/wm.h b/wm.h index b5e1f71..9172dea 100644 --- a/wm.h +++ b/wm.h @@ -19,7 +19,7 @@ enum { Tscratch, Tdev, Tirc, Twww, Twork, TLast }; /********** 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 @@ struct Fnt { int height; }; -struct Brush { +struct DC { /* draw context */ GC gc; Drawable drawable; int x, y, w, h; @@ -79,12 +79,11 @@ extern Atom wm_atom[WMLast], net_atom[NetLast]; 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 lower(Client *c); 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); -- 1.7.10.4