diff options
-rw-r--r-- | Makefile | 19 | ||||
-rw-r--r-- | config.mk | 6 | ||||
-rw-r--r-- | dmenu.1 | 4 | ||||
-rw-r--r-- | draw.c | 8 |
4 files changed, 18 insertions, 19 deletions
@@ -3,6 +3,9 @@ | |||
3 | 3 | ||
4 | include config.mk | 4 | include config.mk |
5 | 5 | ||
6 | SRC = dmenu.c draw.c | ||
7 | OBJ = ${SRC:.c=.o} | ||
8 | |||
6 | all: options dmenu | 9 | all: options dmenu |
7 | 10 | ||
8 | options: | 11 | options: |
@@ -11,22 +14,24 @@ options: | |||
11 | @echo "LDFLAGS = ${LDFLAGS}" | 14 | @echo "LDFLAGS = ${LDFLAGS}" |
12 | @echo "CC = ${CC}" | 15 | @echo "CC = ${CC}" |
13 | 16 | ||
14 | dmenu: dmenu.o draw.o | 17 | .c.o: |
15 | @echo CC -o $@ | ||
16 | @${CC} -o $@ dmenu.o draw.o ${LDFLAGS} | ||
17 | |||
18 | .c.o: config.mk | ||
19 | @echo CC -c $< | 18 | @echo CC -c $< |
20 | @${CC} -c $< ${CFLAGS} | 19 | @${CC} -c $< ${CFLAGS} |
21 | 20 | ||
21 | ${OBJ}: config.mk | ||
22 | |||
23 | dmenu: ${OBJ} | ||
24 | @echo CC -o $@ | ||
25 | @${CC} -o $@ ${OBJ} ${LDFLAGS} | ||
26 | |||
22 | clean: | 27 | clean: |
23 | @echo cleaning | 28 | @echo cleaning |
24 | @rm -f dmenu dmenu.o draw.o dmenu-${VERSION}.tar.gz | 29 | @rm -f dmenu ${OBJ} dmenu-${VERSION}.tar.gz |
25 | 30 | ||
26 | dist: clean | 31 | dist: clean |
27 | @echo creating dist tarball | 32 | @echo creating dist tarball |
28 | @mkdir -p dmenu-${VERSION} | 33 | @mkdir -p dmenu-${VERSION} |
29 | @cp LICENSE Makefile README config.mk dmenu.1 dmenu.c draw.c draw.h dmenu_path dmenu_run dmenu-${VERSION} | 34 | @cp LICENSE Makefile README config.mk dmenu.1 draw.h dmenu_path dmenu_run ${SRC} dmenu-${VERSION} |
30 | @tar -cf dmenu-${VERSION}.tar dmenu-${VERSION} | 35 | @tar -cf dmenu-${VERSION}.tar dmenu-${VERSION} |
31 | @gzip dmenu-${VERSION}.tar | 36 | @gzip dmenu-${VERSION}.tar |
32 | @rm -rf dmenu-${VERSION} | 37 | @rm -rf dmenu-${VERSION} |
@@ -1,10 +1,6 @@ | |||
1 | # dmenu version | 1 | # dmenu version |
2 | VERSION = 4.3 | 2 | VERSION = 4.3 |
3 | 3 | ||
4 | # dmenu_path cache (absolute or relative to $HOME) | ||
5 | CACHE = .dmenu_cache | ||
6 | |||
7 | |||
8 | # paths | 4 | # paths |
9 | PREFIX = /usr/local | 5 | PREFIX = /usr/local |
10 | MANPREFIX = ${PREFIX}/share/man | 6 | MANPREFIX = ${PREFIX}/share/man |
@@ -21,7 +17,7 @@ INCS = -I${X11INC} | |||
21 | LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} | 17 | LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} |
22 | 18 | ||
23 | # flags | 19 | # flags |
24 | CPPFLAGS = -D_BSD_SOURCE -DVERSION=\"${VERSION}\" -DCACHE=\"${CACHE}\" ${XINERAMAFLAGS} | 20 | CPPFLAGS = -D_BSD_SOURCE -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} |
25 | CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS} | 21 | CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS} |
26 | LDFLAGS = -s ${LIBS} | 22 | LDFLAGS = -s ${LIBS} |
27 | 23 | ||
@@ -31,9 +31,9 @@ dmenu \- dynamic menu | |||
31 | .B dmenu | 31 | .B dmenu |
32 | is a dynamic menu for X, originally designed for | 32 | is a dynamic menu for X, originally designed for |
33 | .BR dwm (1). | 33 | .BR dwm (1). |
34 | It manages huge numbers of user-defined menu items efficiently. | 34 | It manages huge numbers of user\-defined menu items efficiently. |
35 | .P | 35 | .P |
36 | dmenu reads a list of newline-separated items from stdin and creates a menu. | 36 | dmenu reads a list of newline\-separated items from stdin and creates a menu. |
37 | When the user selects an item or enters any text and presses Return, their | 37 | When the user selects an item or enters any text and presses Return, their |
38 | choice is printed to stdout and dmenu terminates. | 38 | choice is printed to stdout and dmenu terminates. |
39 | .P | 39 | .P |
@@ -25,14 +25,13 @@ drawrect(DC *dc, int x, int y, unsigned int w, unsigned int h, Bool fill, unsign | |||
25 | (fill ? XFillRectangles : XDrawRectangles)(dc->dpy, dc->canvas, dc->gc, &r, 1); | 25 | (fill ? XFillRectangles : XDrawRectangles)(dc->dpy, dc->canvas, dc->gc, &r, 1); |
26 | } | 26 | } |
27 | 27 | ||
28 | |||
29 | void | 28 | void |
30 | drawtext(DC *dc, const char *text, unsigned long col[ColLast]) { | 29 | drawtext(DC *dc, const char *text, unsigned long col[ColLast]) { |
31 | char buf[256]; | 30 | char buf[BUFSIZ]; |
32 | size_t mn, n = strlen(text); | 31 | size_t mn, n = strlen(text); |
33 | 32 | ||
34 | /* shorten text if necessary */ | 33 | /* shorten text if necessary */ |
35 | for(mn = MIN(n, sizeof buf); textnw(dc, text, mn) > dc->w - dc->font.height/2; mn--) | 34 | for(mn = MIN(n, sizeof buf); textnw(dc, text, mn) + dc->font.height/2 > dc->w; mn--) |
36 | if(mn == 0) | 35 | if(mn == 0) |
37 | return; | 36 | return; |
38 | memcpy(buf, text, mn); | 37 | memcpy(buf, text, mn); |
@@ -157,12 +156,11 @@ void | |||
157 | resizedc(DC *dc, unsigned int w, unsigned int h) { | 156 | resizedc(DC *dc, unsigned int w, unsigned int h) { |
158 | if(dc->canvas) | 157 | if(dc->canvas) |
159 | XFreePixmap(dc->dpy, dc->canvas); | 158 | XFreePixmap(dc->dpy, dc->canvas); |
159 | |||
160 | dc->canvas = XCreatePixmap(dc->dpy, DefaultRootWindow(dc->dpy), w, h, | 160 | dc->canvas = XCreatePixmap(dc->dpy, DefaultRootWindow(dc->dpy), w, h, |
161 | DefaultDepth(dc->dpy, DefaultScreen(dc->dpy))); | 161 | DefaultDepth(dc->dpy, DefaultScreen(dc->dpy))); |
162 | dc->x = dc->y = 0; | ||
163 | dc->w = w; | 162 | dc->w = w; |
164 | dc->h = h; | 163 | dc->h = h; |
165 | dc->invert = False; | ||
166 | } | 164 | } |
167 | 165 | ||
168 | int | 166 | int |