From d7e17087ed2fc5eed57efa03e81460e3e41f7238 Mon Sep 17 00:00:00 2001 From: "Anselm R. Garbe" Date: Thu, 13 Jul 2006 01:55:54 +0200 Subject: new stuff (some warning elimination) --- client.c | 6 +++--- config.mk | 9 +++++++-- draw.c | 27 +++++++++++++-------------- kb.c | 6 +++--- util.c | 4 ++-- wm.c | 10 ++-------- wm.h | 29 ++++++++++++++--------------- 7 files changed, 44 insertions(+), 47 deletions(-) diff --git a/client.c b/client.c index 46e6e83a..67774732 100644 --- 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 index 41cb0708..9857f93c 100644 --- 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 index 53af1cda..1046322c 100644 --- 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 index 2f16910f..f93f69fe 100644 --- 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 index 1d379061..09fd8720 100644 --- 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 index 18950159..6d67bfc7 100644 --- a/wm.c +++ b/wm.c @@ -173,12 +173,6 @@ cleanup() XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime); } -void -run(void *aux) -{ - spawn(dpy, aux); -} - void quit(void *aux) { @@ -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 index 831c1784..b5e1f711 100644 --- 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); -- cgit v1.2.3