dwm

dynamic window manager
git clone git://git.suckless.org/dwm
Log | Files | Refs | README | LICENSE

commit d7e17087ed2fc5eed57efa03e81460e3e41f7238
parent 8b59083eb13c0712e04d9a5b6d7bf4af5913c442
Author: Anselm R. Garbe <garbeam@wmii.de>
Date:   Thu, 13 Jul 2006 01:55:54 +0200

new stuff (some warning elimination)

Diffstat:
Mclient.c | 6+++---
Mconfig.mk | 9+++++++--
Mdraw.c | 27+++++++++++++--------------
Mkb.c | 6+++---
Mutil.c | 4++--
Mwm.c | 10++--------
Mwm.h | 29++++++++++++++---------------
7 files changed, 44 insertions(+), 47 deletions(-)

diff --git a/client.c b/client.c @@ -360,7 +360,7 @@ resize(Client *c) } static int -dummy_error_handler(Display *dpy, XErrorEvent *error) +dummy_error_handler(Display *dsply, XErrorEvent *err) { return 0; } @@ -425,12 +425,12 @@ draw_client(Client *c) if(c->tags[i]) { brush.x += brush.w; brush.w = textw(&brush.font, c->tags[i]) + brush.font.height; - draw(dpy, &brush, True, c->tags[i]); + draw(&brush, True, c->tags[i]); } } brush.x += brush.w; brush.w = textw(&brush.font, c->name) + brush.font.height; - draw(dpy, &brush, True, c->name); + draw(&brush, True, c->name); XCopyArea(dpy, brush.drawable, c->title, brush.gc, 0, 0, c->tw, c->th, 0, 0); XFlush(dpy); diff --git a/config.mk b/config.mk @@ -14,9 +14,14 @@ VERSION = 0.0 LIBS = -L${PREFIX}/lib -L/usr/lib -lc -lm -L${X11LIB} -lX11 # Linux/BSD -CFLAGS = -g -Wall -O2 -I. -I${PREFIX}/include -I/usr/include -I${X11INC} \ +CFLAGS = -Os -I. -I${PREFIX}/include -I/usr/include -I${X11INC} \ -DVERSION=\"${VERSION}\" -LDFLAGS = -g ${LIBS} +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 + +#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 @@ -11,7 +11,7 @@ #include "wm.h" static void -drawborder(Display *dpy, Brush *b) +drawborder(Brush *b) { XPoint points[5]; XSetLineAttributes(dpy, b->gc, 1, LineSolid, CapButt, JoinMiter); @@ -30,9 +30,10 @@ drawborder(Display *dpy, Brush *b) } void -draw(Display *dpy, Brush *b, Bool border, const char *text) +draw(Brush *b, Bool border, const char *text) { - unsigned int x, y, w, h, len; + int x, y, w, h; + unsigned int len; static char buf[256]; XGCValues gcv; XRectangle r = { b->x, b->y, b->w, b->h }; @@ -42,7 +43,7 @@ draw(Display *dpy, Brush *b, Bool border, const char *text) w = 0; if(border) - drawborder(dpy, b); + drawborder(b); if(!text) return; @@ -79,7 +80,7 @@ draw(Display *dpy, Brush *b, Bool border, const char *text) } static unsigned long -xloadcolors(Display *dpy, Colormap cmap, const char *colstr) +xloadcolors(Colormap cmap, const char *colstr) { XColor color; XAllocNamedColor(dpy, cmap, colstr, &color, &color); @@ -87,13 +88,13 @@ xloadcolors(Display *dpy, Colormap cmap, const char *colstr) } void -loadcolors(Display *dpy, int screen, Brush *b, +loadcolors(int scr, Brush *b, const char *bg, const char *fg, const char *border) { - Colormap cmap = DefaultColormap(dpy, screen); - b->bg = xloadcolors(dpy, cmap, bg); - b->fg = xloadcolors(dpy, cmap, fg); - b->border = xloadcolors(dpy, cmap, border); + Colormap cmap = DefaultColormap(dpy, scr); + b->bg = xloadcolors(cmap, bg); + b->fg = xloadcolors(cmap, fg); + b->border = xloadcolors(cmap, border); } unsigned int @@ -120,13 +121,12 @@ texth(Fnt *font) } void -loadfont(Display *dpy, Fnt *font, const char *fontstr) +loadfont(Fnt *font, const char *fontstr) { char **missing, *def; - int n; + int i, n; missing = NULL; - def = "?"; setlocale(LC_ALL, ""); if(font->set) XFreeFontSet(dpy, font->set); @@ -144,7 +144,6 @@ loadfont(Display *dpy, Fnt *font, const char *fontstr) XFontSetExtents *font_extents; XFontStruct **xfonts; char **font_names; - unsigned int i; font->ascent = font->descent = 0; font_extents = XExtentsOfFontSet(font->set); diff --git a/kb.c b/kb.c @@ -9,13 +9,13 @@ /********** CUSTOMIZE **********/ -char *term[] = { +const char *term[] = { "aterm", "-tr", "+sb", "-bg", "black", "-fg", "white", "-fn", "-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*",NULL }; static Key key[] = { - { Mod1Mask, XK_Return, run, term }, + { Mod1Mask, XK_Return, (void (*)(void *))spawn, term }, { Mod1Mask, XK_k, sel, "prev" }, { Mod1Mask, XK_j, sel, "next" }, { Mod1Mask, XK_g, grid, NULL }, @@ -28,7 +28,7 @@ static Key key[] = { /********** CUSTOMIZE **********/ void -update_keys() +update_keys(void) { unsigned int i, len; KeyCode code; diff --git a/util.c b/util.c @@ -14,7 +14,7 @@ #include "wm.h" void -error(char *errstr, ...) { +error(const char *errstr, ...) { va_list ap; va_start(ap, errstr); vfprintf(stderr, errstr, ap); @@ -75,7 +75,7 @@ swap(void **p1, void **p2) } void -spawn(Display *dpy, char *argv[]) +spawn(char *argv[]) { if(!argv || !argv[0]) return; diff --git a/wm.c b/wm.c @@ -174,12 +174,6 @@ cleanup() } void -run(void *aux) -{ - spawn(dpy, aux); -} - -void quit(void *aux) { running = False; @@ -250,8 +244,8 @@ main(int argc, char *argv[]) update_keys(); /* style */ - loadcolors(dpy, screen, &brush, BGCOLOR, FGCOLOR, BORDERCOLOR); - loadfont(dpy, &brush.font, FONT); + loadcolors(screen, &brush, BGCOLOR, FGCOLOR, BORDERCOLOR); + loadfont(&brush.font, FONT); th = texth(&brush.font); diff --git a/wm.h b/wm.h @@ -87,15 +87,6 @@ extern char stext[1024], *tags[TLast]; extern Brush brush; extern Client *clients, *stack; -/* draw.c */ -extern void draw(Display *dpy, Brush *b, Bool border, const char *text); -extern void loadcolors(Display *dpy, int screen, Brush *b, - const char *bg, const char *fg, const char *bo); -extern void loadfont(Display *dpy, 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); - /* client.c */ extern void manage(Window w, XWindowAttributes *wa); extern void unmanage(Client *c); @@ -115,11 +106,20 @@ extern void floating(void *aux); extern void grid(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 unsigned int textnw(Fnt *font, char *text, unsigned int len); +extern unsigned int textw(Fnt *font, char *text); +extern unsigned int texth(Fnt *font); + /* event.c */ extern void discard_events(long even_mask); -/* key.c */ -extern void update_keys(); +/* kb.c */ +extern void update_keys(void); extern void keypress(XEvent *e); /* mouse.c */ @@ -127,17 +127,16 @@ extern void mresize(Client *c); extern void mmove(Client *c); /* util.c */ -extern void error(char *errstr, ...); +extern void error(const char *errstr, ...); extern void *emallocz(unsigned int size); extern void *emalloc(unsigned int size); extern void *erealloc(void *ptr, unsigned int size); extern char *estrdup(const char *str); -extern void spawn(Display *dpy, char *argv[]); +extern void spawn(char *argv[]); extern void swap(void **p1, void **p2); /* wm.c */ -extern int error_handler(Display *dpy, XErrorEvent *error); +extern int error_handler(Display *dsply, XErrorEvent *e); extern void send_message(Window w, Atom a, long value); extern int win_proto(Window w); -extern void run(void *aux); extern void quit(void *aux);