Compare commits

..

14 Commits
0.4 ... 0.5

9 changed files with 28 additions and 17 deletions

@ -1,3 +1,4 @@
fcc8a282cb52c6a9343b461026b386825590cd31 0.1 fcc8a282cb52c6a9343b461026b386825590cd31 0.1
656be0f47df545dfdd2e1e0663663b8b1b26f031 0.2 656be0f47df545dfdd2e1e0663663b8b1b26f031 0.2
d352e9dc112ee96aa5cad961a0ed880ae9ce7276 0.3 d352e9dc112ee96aa5cad961a0ed880ae9ce7276 0.3
7acf0dde1120542917bae12e0e42293f9d2cc899 0.4

@ -19,7 +19,7 @@ options:
@echo CC $< @echo CC $<
@${CC} -c ${CFLAGS} $< @${CC} -c ${CFLAGS} $<
${OBJ}: dmenu.h config.h ${OBJ}: dmenu.h config.h config.mk
config.h: config.h:
@echo creating $@ from config.default.h @echo creating $@ from config.default.h

3
README

@ -1,7 +1,6 @@
dmenu - dynamic menu dmenu - dynamic menu
-------------------- --------------------
dmenu is a generic, highly customizable, and efficient menu for the dmenu is a generic, highly customizable, and efficient menu for X.
X Window System.
Requirements Requirements

@ -4,6 +4,6 @@
*/ */
#define FONT "-*-terminus-medium-*-*-*-12-*-*-*-*-*-iso10646-*" #define FONT "-*-terminus-medium-*-*-*-12-*-*-*-*-*-iso10646-*"
#define BGCOLOR "#0d121d" #define BGCOLOR "#666699"
#define FGCOLOR "#eeeeee" #define FGCOLOR "#eeeeee"
#define BORDERCOLOR "#3f484d" #define BORDERCOLOR "#9999CC"

@ -1,5 +1,5 @@
# dmenu version # dmenu version
VERSION = 0.4 VERSION = 0.5
# Customize below to fit your system # Customize below to fit your system
@ -11,7 +11,7 @@ X11INC = /usr/X11R6/include
X11LIB = /usr/X11R6/lib X11LIB = /usr/X11R6/lib
# includes and libs # includes and libs
INCS = -I/usr/lib -I${X11INC} INCS = -I. -I/usr/include -I${X11INC}
LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 LIBS = -L/usr/lib -lc -L${X11LIB} -lX11
# flags # flags

@ -7,7 +7,7 @@ dmenu \- dynamic menu
.SH DESCRIPTION .SH DESCRIPTION
.SS Overview .SS Overview
.B dmenu .B dmenu
is a generic, highly customizable, and efficient menu for the X Window System, is a generic, highly customizable, and efficient menu for X,
originally designed for originally designed for
.BR dwm (1). .BR dwm (1).
It supports arbitrary, user defined menu contents. It supports arbitrary, user defined menu contents.

3
draw.c

@ -38,8 +38,6 @@ drawtext(const char *text, Bool invert, Bool border)
w = 0; w = 0;
if(border) { if(border) {
XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
XSetForeground(dpy, dc.gc, dc.border);
points[0].x = dc.x; points[0].x = dc.x;
points[0].y = dc.y; points[0].y = dc.y;
points[1].x = dc.w - 1; points[1].x = dc.w - 1;
@ -50,6 +48,7 @@ drawtext(const char *text, Bool invert, Bool border)
points[3].y = 0; points[3].y = 0;
points[4].x = 0; points[4].x = 0;
points[4].y = -(dc.h - 1); points[4].y = -(dc.h - 1);
XSetForeground(dpy, dc.gc, dc.border);
XDrawLines(dpy, dc.drawable, dc.gc, points, 5, CoordModePrevious); XDrawLines(dpy, dc.drawable, dc.gc, points, 5, CoordModePrevious);
} }

20
main.c

@ -29,7 +29,7 @@ static int mx, my, mw, mh;
static int ret = 0; static int ret = 0;
static int nitem = 0; static int nitem = 0;
static unsigned int cmdw = 0; static unsigned int cmdw = 0;
static Bool done = False; static Bool running = True;
static Item *allitems = NULL; /* first of all items */ static Item *allitems = NULL; /* first of all items */
static Item *item = NULL; /* first of pattern matching items */ static Item *item = NULL; /* first of pattern matching items */
static Item *sel = NULL; static Item *sel = NULL;
@ -219,11 +219,11 @@ kpress(XKeyEvent * e)
else if(text) else if(text)
fprintf(stdout, "%s", text); fprintf(stdout, "%s", text);
fflush(stdout); fflush(stdout);
done = True; running = False;
break; break;
case XK_Escape: case XK_Escape:
ret = 1; ret = 1;
done = True; running = False;
break; break;
case XK_BackSpace: case XK_BackSpace:
if((i = len)) { if((i = len)) {
@ -290,6 +290,7 @@ int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
char *maxname; char *maxname;
Item *i;
XEvent ev; XEvent ev;
XSetWindowAttributes wa; XSetWindowAttributes wa;
@ -336,6 +337,7 @@ main(int argc, char *argv[])
/* pixmap */ /* pixmap */
dc.drawable = XCreatePixmap(dpy, root, mw, mh, DefaultDepth(dpy, screen)); dc.drawable = XCreatePixmap(dpy, root, mw, mh, DefaultDepth(dpy, screen));
dc.gc = XCreateGC(dpy, root, 0, 0); dc.gc = XCreateGC(dpy, root, 0, 0);
XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
if(maxname) if(maxname)
cmdw = textw(maxname); cmdw = textw(maxname);
@ -349,7 +351,7 @@ main(int argc, char *argv[])
XSync(dpy, False); XSync(dpy, False);
/* main event loop */ /* main event loop */
while(!done && !XNextEvent(dpy, &ev)) { while(running && !XNextEvent(dpy, &ev)) {
switch (ev.type) { switch (ev.type) {
case KeyPress: case KeyPress:
kpress(&ev.xkey); kpress(&ev.xkey);
@ -364,6 +366,16 @@ main(int argc, char *argv[])
} }
XUngrabKeyboard(dpy, CurrentTime); XUngrabKeyboard(dpy, CurrentTime);
while(allitems) {
i = allitems->next;
free(allitems->text);
free(allitems);
allitems = i;
}
if(dc.font.set)
XFreeFontSet(dpy, dc.font.set);
else
XFreeFont(dpy, dc.font.xfont);
XFreePixmap(dpy, dc.drawable); XFreePixmap(dpy, dc.drawable);
XFreeGC(dpy, dc.gc); XFreeGC(dpy, dc.gc);
XDestroyWindow(dpy, win); XDestroyWindow(dpy, win);

6
util.c

@ -13,7 +13,7 @@
/* static */ /* static */
static void static void
bad_malloc(unsigned int size) badmalloc(unsigned int size)
{ {
eprint("fatal: could not malloc() %u bytes\n", size); eprint("fatal: could not malloc() %u bytes\n", size);
} }
@ -25,7 +25,7 @@ emalloc(unsigned int size)
{ {
void *res = malloc(size); void *res = malloc(size);
if(!res) if(!res)
bad_malloc(size); badmalloc(size);
return res; return res;
} }
@ -45,6 +45,6 @@ estrdup(const char *str)
{ {
void *res = strdup(str); void *res = strdup(str);
if(!res) if(!res)
bad_malloc(strlen(str)); badmalloc(strlen(str));
return res; return res;
} }