Compare commits

..

12 Commits
2.7 ... 3.1

9 changed files with 85 additions and 49 deletions

View File

@ -27,3 +27,6 @@ b6e09682c8adcb6569656bee73c311f9ab457715 2.3
1ca5d430524e838c52ede912533cb90108c5cd66 2.4.2 1ca5d430524e838c52ede912533cb90108c5cd66 2.4.2
041143e9fc544c62edc58af52cae9ac5237e5945 2.5 041143e9fc544c62edc58af52cae9ac5237e5945 2.5
775f761a5647a05038e091d1c99fc35d3034cd68 2.6 775f761a5647a05038e091d1c99fc35d3034cd68 2.6
fbd9e9d63f202afe6834ccfdf890904f1897ec0b 2.7
dd3d02b07cac44fbafc074a361c1002cebe7aae4 2.8
59b3024854db49739c6d237fa9077f04a2da847a 3.0

View File

@ -1,7 +1,7 @@
MIT/X Consortium License MIT/X Consortium License
(C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com> © 2006-2007 Anselm R. Garbe <garbeam at gmail dot com>
(C)opyright MMVI-MMVII Sander van Dijk <a dot h dot vandijk at gmail dot com> © 2006-2007 Sander van Dijk <a dot h dot vandijk at gmail dot com>
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), copy of this software and associated documentation files (the "Software"),

View File

@ -1,5 +1,5 @@
# dmenu - dynamic menu # dmenu - dynamic menu
# (C)opyright MMVI-MMVII Anselm R. Garbe # © 2006-2007 Anselm R. Garbe, Sander van Dijk
include config.mk include config.mk
@ -23,7 +23,6 @@ ${OBJ}: dmenu.h config.mk
dmenu: ${OBJ} dmenu: ${OBJ}
@echo CC -o $@ @echo CC -o $@
@${CC} -o $@ ${OBJ} ${LDFLAGS} @${CC} -o $@ ${OBJ} ${LDFLAGS}
@strip $@
clean: clean:
@echo cleaning @echo cleaning

View File

@ -1,5 +1,5 @@
# dmenu version # dmenu version
VERSION = 2.7 VERSION = 3.1
# Customize below to fit your system # Customize below to fit your system
@ -16,7 +16,7 @@ LIBS = -L/usr/lib -lc -L${X11LIB} -lX11
# flags # flags
CFLAGS = -Os ${INCS} -DVERSION=\"${VERSION}\" CFLAGS = -Os ${INCS} -DVERSION=\"${VERSION}\"
LDFLAGS = ${LIBS} LDFLAGS = -s ${LIBS}
#CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\" #CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\"
#LDFLAGS = -g ${LIBS} #LDFLAGS = -g ${LIBS}

View File

@ -1,7 +1,6 @@
/* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com> /* © 2006-2007 Anselm R. Garbe <garbeam at gmail dot com>
* See LICENSE file for license details. * © 2006-2007 Sander van Dijk <a dot h dot vandijk at gmail dot com>
*/ * See LICENSE file for license details. */
#include <X11/Xlib.h> #include <X11/Xlib.h>
#define FONT "-*-fixed-medium-r-normal-*-13-*-*-*-*-*-*-*" #define FONT "-*-fixed-medium-r-normal-*-13-*-*-*-*-*-*-*"

View File

@ -1,9 +1,30 @@
#!/bin/sh #!/bin/sh
CACHE=$HOME/.dmenu_cache
UPTODATE=1
IFS=: IFS=:
for dir in $PATH
do if test ! -f $CACHE
for file in "$dir"/* then
unset UPTODATE
fi
if test $UPTODATE
then
for dir in $PATH
do do
test -x "$file" && echo "${file##*/}" test $dir -nt $CACHE && unset UPTODATE
done done
done | sort | uniq fi
if test ! $UPTODATE
then
for dir in $PATH
do
for file in "$dir"/*
do
test -x "$file" && echo "${file##*/}"
done
done | sort | uniq > $CACHE
fi
cat $CACHE

7
draw.c
View File

@ -1,7 +1,6 @@
/* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com> /* © 2006-2007 Anselm R. Garbe <garbeam at gmail dot com>
* (C)opyright MMVI-MMVII Sander van Dijk <a dot h dot vandijk at gmail dot com> * © 2006-2007 Sander van Dijk <a dot h dot vandijk at gmail dot com>
* See LICENSE file for license details. * See LICENSE file for license details. */
*/
#include "dmenu.h" #include "dmenu.h"
#include <string.h> #include <string.h>

69
main.c
View File

@ -1,7 +1,6 @@
/* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com> /* © 2006-2007 Anselm R. Garbe <garbeam at gmail dot com>
* (C)opyright MMVI-MMVII Sander van Dijk <a dot h dot vandijk at gmail dot com> * © 2006-2007 Sander van Dijk <a dot h dot vandijk at gmail dot com>
* See LICENSE file for license details. * See LICENSE file for license details. */
*/
#include "dmenu.h" #include "dmenu.h"
#include <ctype.h> #include <ctype.h>
#include <locale.h> #include <locale.h>
@ -108,11 +107,17 @@ drawmenu(void) {
XFlush(dpy); XFlush(dpy);
} }
static void static Bool
grabkeyboard(void) { grabkeyboard(void) {
while(XGrabKeyboard(dpy, win, True, GrabModeAsync, unsigned int len;
GrabModeAsync, CurrentTime) != GrabSuccess)
for(len = 1000; len; len--) {
if(XGrabKeyboard(dpy, root, True, GrabModeAsync, GrabModeAsync, CurrentTime)
== GrabSuccess)
break;
usleep(1000); usleep(1000);
}
return len > 0;
} }
static unsigned long static unsigned long
@ -130,6 +135,8 @@ initfont(const char *fontstr) {
char *def, **missing; char *def, **missing;
int i, n; int i, n;
if(!fontstr || fontstr[0] == '\0')
eprint("error, cannot load font: '%s'\n", fontstr);
missing = NULL; missing = NULL;
if(dc.font.set) if(dc.font.set)
XFreeFontSet(dpy, dc.font.set); XFreeFontSet(dpy, dc.font.set);
@ -210,6 +217,13 @@ kpress(XKeyEvent * e) {
len = strlen(text); len = strlen(text);
buf[0] = 0; buf[0] = 0;
num = XLookupString(e, buf, sizeof buf, &ksym, 0); num = XLookupString(e, buf, sizeof buf, &ksym, 0);
if(IsKeypadKey(ksym)) {
if(ksym == XK_KP_Enter) {
ksym = XK_Return;
} else if(ksym >= XK_KP_0 && ksym <= XK_KP_9) {
ksym = (ksym - XK_KP_0) + XK_0;
}
}
if(IsFunctionKey(ksym) || IsKeypadKey(ksym) if(IsFunctionKey(ksym) || IsKeypadKey(ksym)
|| IsMiscFunctionKey(ksym) || IsPFKey(ksym) || IsMiscFunctionKey(ksym) || IsPFKey(ksym)
|| IsPrivateKeypadKey(ksym)) || IsPrivateKeypadKey(ksym))
@ -445,7 +459,7 @@ main(int argc, char *argv[]) {
if(++i < argc) selfg = argv[i]; if(++i < argc) selfg = argv[i];
} }
else if(!strncmp(argv[i], "-v", 3)) else if(!strncmp(argv[i], "-v", 3))
eprint("dmenu-"VERSION", (C)opyright MMVI-MMVII Anselm R. Garbe\n"); eprint("dmenu-"VERSION", © 2006-2007 Anselm R. Garbe, Sander van Dijk\n");
else else
usage(); usage();
setlocale(LC_CTYPE, ""); setlocale(LC_CTYPE, "");
@ -454,6 +468,24 @@ main(int argc, char *argv[]) {
eprint("dmenu: cannot open display\n"); eprint("dmenu: cannot open display\n");
screen = DefaultScreen(dpy); screen = DefaultScreen(dpy);
root = RootWindow(dpy, screen); root = RootWindow(dpy, screen);
if(isatty(STDIN_FILENO)) {
maxname = readstdin();
running = grabkeyboard();
}
else { /* prevent keypress loss */
running = grabkeyboard();
maxname = readstdin();
}
/* init modifier map */
modmap = XGetModifierMapping(dpy);
for (i = 0; i < 8; i++) {
for (j = 0; j < modmap->max_keypermod; j++) {
if(modmap->modifiermap[i * modmap->max_keypermod + j]
== XKeysymToKeycode(dpy, XK_Num_Lock))
numlockmask = (1 << i);
}
}
XFreeModifiermap(modmap);
/* style */ /* style */
dc.norm[ColBG] = initcolor(normbg); dc.norm[ColBG] = initcolor(normbg);
dc.norm[ColFG] = initcolor(normfg); dc.norm[ColFG] = initcolor(normfg);
@ -477,25 +509,6 @@ main(int argc, char *argv[]) {
XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter); XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
if(!dc.font.set) if(!dc.font.set)
XSetFont(dpy, dc.gc, dc.font.xfont->fid); XSetFont(dpy, dc.gc, dc.font.xfont->fid);
drawmenu();
XMapRaised(dpy, win);
if(isatty(STDIN_FILENO)) {
maxname = readstdin();
grabkeyboard();
}
else { /* prevent keypress loss */
grabkeyboard();
maxname = readstdin();
}
/* init modifier map */
modmap = XGetModifierMapping(dpy);
for(i = 0; i < 8; i++)
for(j = 0; j < modmap->max_keypermod; j++) {
if(modmap->modifiermap[i * modmap->max_keypermod + j]
== XKeysymToKeycode(dpy, XK_Num_Lock))
numlockmask = (1 << i);
}
XFreeModifiermap(modmap);
if(maxname) if(maxname)
cmdw = textw(maxname); cmdw = textw(maxname);
if(cmdw > mw / 3) if(cmdw > mw / 3)
@ -506,6 +519,8 @@ main(int argc, char *argv[]) {
promptw = mw / 5; promptw = mw / 5;
text[0] = 0; text[0] = 0;
match(text); match(text);
XMapRaised(dpy, win);
drawmenu();
XSync(dpy, False); XSync(dpy, False);
/* main event loop */ /* main event loop */

6
util.c
View File

@ -1,6 +1,6 @@
/* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com> /* © 2006-2007 Anselm R. Garbe <garbeam at gmail dot com>
* See LICENSE file for license details. * © 2006-2007 Sander van Dijk <a dot h dot vandijk at gmail dot com>
*/ * See LICENSE file for license details. */
#include "dmenu.h" #include "dmenu.h"
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>