aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile19
-rw-r--r--config.mk6
-rw-r--r--dmenu.14
-rw-r--r--draw.c8
4 files changed, 18 insertions, 19 deletions
diff --git a/Makefile b/Makefile
index 60e53d1..5871fa7 100644
--- a/Makefile
+++ b/Makefile
@@ -3,6 +3,9 @@
3 3
4include config.mk 4include config.mk
5 5
6SRC = dmenu.c draw.c
7OBJ = ${SRC:.c=.o}
8
6all: options dmenu 9all: options dmenu
7 10
8options: 11options:
@@ -11,22 +14,24 @@ options:
11 @echo "LDFLAGS = ${LDFLAGS}" 14 @echo "LDFLAGS = ${LDFLAGS}"
12 @echo "CC = ${CC}" 15 @echo "CC = ${CC}"
13 16
14dmenu: 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
23dmenu: ${OBJ}
24 @echo CC -o $@
25 @${CC} -o $@ ${OBJ} ${LDFLAGS}
26
22clean: 27clean:
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
26dist: clean 31dist: 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}
diff --git a/config.mk b/config.mk
index aedd13c..126bd79 100644
--- a/config.mk
+++ b/config.mk
@@ -1,10 +1,6 @@
1# dmenu version 1# dmenu version
2VERSION = 4.3 2VERSION = 4.3
3 3
4# dmenu_path cache (absolute or relative to $HOME)
5CACHE = .dmenu_cache
6
7
8# paths 4# paths
9PREFIX = /usr/local 5PREFIX = /usr/local
10MANPREFIX = ${PREFIX}/share/man 6MANPREFIX = ${PREFIX}/share/man
@@ -21,7 +17,7 @@ INCS = -I${X11INC}
21LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} 17LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS}
22 18
23# flags 19# flags
24CPPFLAGS = -D_BSD_SOURCE -DVERSION=\"${VERSION}\" -DCACHE=\"${CACHE}\" ${XINERAMAFLAGS} 20CPPFLAGS = -D_BSD_SOURCE -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
25CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS} 21CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS}
26LDFLAGS = -s ${LIBS} 22LDFLAGS = -s ${LIBS}
27 23
diff --git a/dmenu.1 b/dmenu.1
index 5f138c8..e5aa8cd 100644
--- a/dmenu.1
+++ b/dmenu.1
@@ -31,9 +31,9 @@ dmenu \- dynamic menu
31.B dmenu 31.B dmenu
32is a dynamic menu for X, originally designed for 32is a dynamic menu for X, originally designed for
33.BR dwm (1). 33.BR dwm (1).
34It manages huge numbers of user-defined menu items efficiently. 34It manages huge numbers of user\-defined menu items efficiently.
35.P 35.P
36dmenu reads a list of newline-separated items from stdin and creates a menu. 36dmenu reads a list of newline\-separated items from stdin and creates a menu.
37When the user selects an item or enters any text and presses Return, their 37When the user selects an item or enters any text and presses Return, their
38choice is printed to stdout and dmenu terminates. 38choice is printed to stdout and dmenu terminates.
39.P 39.P
diff --git a/draw.c b/draw.c
index f9b8957..95ff072 100644
--- a/draw.c
+++ b/draw.c
@@ -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
29void 28void
30drawtext(DC *dc, const char *text, unsigned long col[ColLast]) { 29drawtext(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
157resizedc(DC *dc, unsigned int w, unsigned int h) { 156resizedc(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
168int 166int