Compare commits

..

14 Commits
0.4 ... 0.5

9 changed files with 28 additions and 17 deletions

View File

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

View File

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

3
README
View File

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

View File

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

View File

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

View File

@ -7,7 +7,7 @@ dmenu \- dynamic menu
.SH DESCRIPTION
.SS Overview
.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
.BR dwm (1).
It supports arbitrary, user defined menu contents.

3
draw.c
View File

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

20
main.c
View File

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

6
util.c
View File

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