new stuff (some warning elimination)
d7e17087
7 file(s) · +44 −47
| 360 | 360 | } |
|
| 361 | 361 | ||
| 362 | 362 | static int |
|
| 363 | - | dummy_error_handler(Display *dpy, XErrorEvent *error) |
|
| 363 | + | dummy_error_handler(Display *dsply, XErrorEvent *err) |
|
| 364 | 364 | { |
|
| 365 | 365 | return 0; |
|
| 366 | 366 | } |
|
| 425 | 425 | if(c->tags[i]) { |
|
| 426 | 426 | brush.x += brush.w; |
|
| 427 | 427 | brush.w = textw(&brush.font, c->tags[i]) + brush.font.height; |
|
| 428 | - | draw(dpy, &brush, True, c->tags[i]); |
|
| 428 | + | draw(&brush, True, c->tags[i]); |
|
| 429 | 429 | } |
|
| 430 | 430 | } |
|
| 431 | 431 | brush.x += brush.w; |
|
| 432 | 432 | brush.w = textw(&brush.font, c->name) + brush.font.height; |
|
| 433 | - | draw(dpy, &brush, True, c->name); |
|
| 433 | + | draw(&brush, True, c->name); |
|
| 434 | 434 | XCopyArea(dpy, brush.drawable, c->title, brush.gc, |
|
| 435 | 435 | 0, 0, c->tw, c->th, 0, 0); |
|
| 436 | 436 | XFlush(dpy); |
|
| 14 | 14 | LIBS = -L${PREFIX}/lib -L/usr/lib -lc -lm -L${X11LIB} -lX11 |
|
| 15 | 15 | ||
| 16 | 16 | # Linux/BSD |
|
| 17 | - | CFLAGS = -g -Wall -O2 -I. -I${PREFIX}/include -I/usr/include -I${X11INC} \ |
|
| 17 | + | CFLAGS = -Os -I. -I${PREFIX}/include -I/usr/include -I${X11INC} \ |
|
| 18 | 18 | -DVERSION=\"${VERSION}\" |
|
| 19 | - | LDFLAGS = -g ${LIBS} |
|
| 19 | + | LDFLAGS = ${LIBS} |
|
| 20 | + | #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 |
|
| 21 | + | ||
| 22 | + | #CFLAGS = -g -Wall -O2 -I. -I${PREFIX}/include -I/usr/include -I${X11INC} \ |
|
| 23 | + | # -DVERSION=\"${VERSION}\" |
|
| 24 | + | #LDFLAGS = -g ${LIBS} |
|
| 20 | 25 | ||
| 21 | 26 | # Solaris |
|
| 22 | 27 | #CFLAGS = -fast -xtarget=ultra ${INCLUDES} -DVERSION=\"${VERSION}\" |
| 11 | 11 | #include "wm.h" |
|
| 12 | 12 | ||
| 13 | 13 | static void |
|
| 14 | - | drawborder(Display *dpy, Brush *b) |
|
| 14 | + | drawborder(Brush *b) |
|
| 15 | 15 | { |
|
| 16 | 16 | XPoint points[5]; |
|
| 17 | 17 | XSetLineAttributes(dpy, b->gc, 1, LineSolid, CapButt, JoinMiter); |
|
| 30 | 30 | } |
|
| 31 | 31 | ||
| 32 | 32 | void |
|
| 33 | - | draw(Display *dpy, Brush *b, Bool border, const char *text) |
|
| 33 | + | draw(Brush *b, Bool border, const char *text) |
|
| 34 | 34 | { |
|
| 35 | - | unsigned int x, y, w, h, len; |
|
| 35 | + | int x, y, w, h; |
|
| 36 | + | unsigned int len; |
|
| 36 | 37 | static char buf[256]; |
|
| 37 | 38 | XGCValues gcv; |
|
| 38 | 39 | XRectangle r = { b->x, b->y, b->w, b->h }; |
|
| 42 | 43 | ||
| 43 | 44 | w = 0; |
|
| 44 | 45 | if(border) |
|
| 45 | - | drawborder(dpy, b); |
|
| 46 | + | drawborder(b); |
|
| 46 | 47 | ||
| 47 | 48 | if(!text) |
|
| 48 | 49 | return; |
|
| 79 | 80 | } |
|
| 80 | 81 | ||
| 81 | 82 | static unsigned long |
|
| 82 | - | xloadcolors(Display *dpy, Colormap cmap, const char *colstr) |
|
| 83 | + | xloadcolors(Colormap cmap, const char *colstr) |
|
| 83 | 84 | { |
|
| 84 | 85 | XColor color; |
|
| 85 | 86 | XAllocNamedColor(dpy, cmap, colstr, &color, &color); |
|
| 87 | 88 | } |
|
| 88 | 89 | ||
| 89 | 90 | void |
|
| 90 | - | loadcolors(Display *dpy, int screen, Brush *b, |
|
| 91 | + | loadcolors(int scr, Brush *b, |
|
| 91 | 92 | const char *bg, const char *fg, const char *border) |
|
| 92 | 93 | { |
|
| 93 | - | Colormap cmap = DefaultColormap(dpy, screen); |
|
| 94 | - | b->bg = xloadcolors(dpy, cmap, bg); |
|
| 95 | - | b->fg = xloadcolors(dpy, cmap, fg); |
|
| 96 | - | b->border = xloadcolors(dpy, cmap, border); |
|
| 94 | + | Colormap cmap = DefaultColormap(dpy, scr); |
|
| 95 | + | b->bg = xloadcolors(cmap, bg); |
|
| 96 | + | b->fg = xloadcolors(cmap, fg); |
|
| 97 | + | b->border = xloadcolors(cmap, border); |
|
| 97 | 98 | } |
|
| 98 | 99 | ||
| 99 | 100 | unsigned int |
|
| 120 | 121 | } |
|
| 121 | 122 | ||
| 122 | 123 | void |
|
| 123 | - | loadfont(Display *dpy, Fnt *font, const char *fontstr) |
|
| 124 | + | loadfont(Fnt *font, const char *fontstr) |
|
| 124 | 125 | { |
|
| 125 | 126 | char **missing, *def; |
|
| 126 | - | int n; |
|
| 127 | + | int i, n; |
|
| 127 | 128 | ||
| 128 | 129 | missing = NULL; |
|
| 129 | - | def = "?"; |
|
| 130 | 130 | setlocale(LC_ALL, ""); |
|
| 131 | 131 | if(font->set) |
|
| 132 | 132 | XFreeFontSet(dpy, font->set); |
|
| 144 | 144 | XFontSetExtents *font_extents; |
|
| 145 | 145 | XFontStruct **xfonts; |
|
| 146 | 146 | char **font_names; |
|
| 147 | - | unsigned int i; |
|
| 148 | 147 | ||
| 149 | 148 | font->ascent = font->descent = 0; |
|
| 150 | 149 | font_extents = XExtentsOfFontSet(font->set); |
|
| 9 | 9 | ||
| 10 | 10 | /********** CUSTOMIZE **********/ |
|
| 11 | 11 | ||
| 12 | - | char *term[] = { |
|
| 12 | + | const char *term[] = { |
|
| 13 | 13 | "aterm", "-tr", "+sb", "-bg", "black", "-fg", "white", "-fn", |
|
| 14 | 14 | "-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*",NULL |
|
| 15 | 15 | }; |
|
| 16 | 16 | ||
| 17 | 17 | static Key key[] = { |
|
| 18 | - | { Mod1Mask, XK_Return, run, term }, |
|
| 18 | + | { Mod1Mask, XK_Return, (void (*)(void *))spawn, term }, |
|
| 19 | 19 | { Mod1Mask, XK_k, sel, "prev" }, |
|
| 20 | 20 | { Mod1Mask, XK_j, sel, "next" }, |
|
| 21 | 21 | { Mod1Mask, XK_g, grid, NULL }, |
|
| 28 | 28 | /********** CUSTOMIZE **********/ |
|
| 29 | 29 | ||
| 30 | 30 | void |
|
| 31 | - | update_keys() |
|
| 31 | + | update_keys(void) |
|
| 32 | 32 | { |
|
| 33 | 33 | unsigned int i, len; |
|
| 34 | 34 | KeyCode code; |
|
| 14 | 14 | #include "wm.h" |
|
| 15 | 15 | ||
| 16 | 16 | void |
|
| 17 | - | error(char *errstr, ...) { |
|
| 17 | + | error(const char *errstr, ...) { |
|
| 18 | 18 | va_list ap; |
|
| 19 | 19 | va_start(ap, errstr); |
|
| 20 | 20 | vfprintf(stderr, errstr, ap); |
|
| 75 | 75 | } |
|
| 76 | 76 | ||
| 77 | 77 | void |
|
| 78 | - | spawn(Display *dpy, char *argv[]) |
|
| 78 | + | spawn(char *argv[]) |
|
| 79 | 79 | { |
|
| 80 | 80 | if(!argv || !argv[0]) |
|
| 81 | 81 | return; |
|
| 174 | 174 | } |
|
| 175 | 175 | ||
| 176 | 176 | void |
|
| 177 | - | run(void *aux) |
|
| 178 | - | { |
|
| 179 | - | spawn(dpy, aux); |
|
| 180 | - | } |
|
| 181 | - | ||
| 182 | - | void |
|
| 183 | 177 | quit(void *aux) |
|
| 184 | 178 | { |
|
| 185 | 179 | running = False; |
|
| 250 | 244 | update_keys(); |
|
| 251 | 245 | ||
| 252 | 246 | /* style */ |
|
| 253 | - | loadcolors(dpy, screen, &brush, BGCOLOR, FGCOLOR, BORDERCOLOR); |
|
| 254 | - | loadfont(dpy, &brush.font, FONT); |
|
| 247 | + | loadcolors(screen, &brush, BGCOLOR, FGCOLOR, BORDERCOLOR); |
|
| 248 | + | loadfont(&brush.font, FONT); |
|
| 255 | 249 | ||
| 256 | 250 | th = texth(&brush.font); |
|
| 257 | 251 | ||
| 87 | 87 | extern Brush brush; |
|
| 88 | 88 | extern Client *clients, *stack; |
|
| 89 | 89 | ||
| 90 | - | /* draw.c */ |
|
| 91 | - | extern void draw(Display *dpy, Brush *b, Bool border, const char *text); |
|
| 92 | - | extern void loadcolors(Display *dpy, int screen, Brush *b, |
|
| 93 | - | const char *bg, const char *fg, const char *bo); |
|
| 94 | - | extern void loadfont(Display *dpy, Fnt *font, const char *fontstr); |
|
| 95 | - | extern unsigned int textnw(Fnt *font, char *text, unsigned int len); |
|
| 96 | - | extern unsigned int textw(Fnt *font, char *text); |
|
| 97 | - | extern unsigned int texth(Fnt *font); |
|
| 98 | - | ||
| 99 | 90 | /* client.c */ |
|
| 100 | 91 | extern void manage(Window w, XWindowAttributes *wa); |
|
| 101 | 92 | extern void unmanage(Client *c); |
|
| 115 | 106 | extern void grid(void *aux); |
|
| 116 | 107 | extern void gravitate(Client *c, Bool invert); |
|
| 117 | 108 | ||
| 109 | + | /* draw.c */ |
|
| 110 | + | extern void draw(Brush *b, Bool border, const char *text); |
|
| 111 | + | extern void loadcolors(int scr, Brush *b, |
|
| 112 | + | const char *bg, const char *fg, const char *bo); |
|
| 113 | + | extern void loadfont(Fnt *font, const char *fontstr); |
|
| 114 | + | extern unsigned int textnw(Fnt *font, char *text, unsigned int len); |
|
| 115 | + | extern unsigned int textw(Fnt *font, char *text); |
|
| 116 | + | extern unsigned int texth(Fnt *font); |
|
| 117 | + | ||
| 118 | 118 | /* event.c */ |
|
| 119 | 119 | extern void discard_events(long even_mask); |
|
| 120 | 120 | ||
| 121 | - | /* key.c */ |
|
| 122 | - | extern void update_keys(); |
|
| 121 | + | /* kb.c */ |
|
| 122 | + | extern void update_keys(void); |
|
| 123 | 123 | extern void keypress(XEvent *e); |
|
| 124 | 124 | ||
| 125 | 125 | /* mouse.c */ |
|
| 127 | 127 | extern void mmove(Client *c); |
|
| 128 | 128 | ||
| 129 | 129 | /* util.c */ |
|
| 130 | - | extern void error(char *errstr, ...); |
|
| 130 | + | extern void error(const char *errstr, ...); |
|
| 131 | 131 | extern void *emallocz(unsigned int size); |
|
| 132 | 132 | extern void *emalloc(unsigned int size); |
|
| 133 | 133 | extern void *erealloc(void *ptr, unsigned int size); |
|
| 134 | 134 | extern char *estrdup(const char *str); |
|
| 135 | - | extern void spawn(Display *dpy, char *argv[]); |
|
| 135 | + | extern void spawn(char *argv[]); |
|
| 136 | 136 | extern void swap(void **p1, void **p2); |
|
| 137 | 137 | ||
| 138 | 138 | /* wm.c */ |
|
| 139 | - | extern int error_handler(Display *dpy, XErrorEvent *error); |
|
| 139 | + | extern int error_handler(Display *dsply, XErrorEvent *e); |
|
| 140 | 140 | extern void send_message(Window w, Atom a, long value); |
|
| 141 | 141 | extern int win_proto(Window w); |
|
| 142 | - | extern void run(void *aux); |
|
| 143 | 142 | extern void quit(void *aux); |
|