Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
a1ad9c2a1c | |||
51224dcb79 | |||
4e74263ba0 | |||
bab59a9807 |
1
.hgtags
1
.hgtags
@ -38,3 +38,4 @@ e4c81a78ffbad6ba4d1ad119cc654da6eca63a4c 3.2
|
|||||||
0bc2751d06e8b95e0138854c7815e154c5c3d990 3.6
|
0bc2751d06e8b95e0138854c7815e154c5c3d990 3.6
|
||||||
0508a3a6ee106f36d9b8ff07bb5b28584edfa89c 3.7
|
0508a3a6ee106f36d9b8ff07bb5b28584edfa89c 3.7
|
||||||
644b0798fcccd570fd519899e1601c6857496b91 3.8
|
644b0798fcccd570fd519899e1601c6857496b91 3.8
|
||||||
|
21a1ed9a69b9541a355758a57103e294fb722c33 3.9
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# dmenu version
|
# dmenu version
|
||||||
VERSION = 3.9
|
VERSION = 4.0
|
||||||
|
|
||||||
# Customize below to fit your system
|
# Customize below to fit your system
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ INCS = -I. -I/usr/include -I${X11INC}
|
|||||||
LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 ${XINERAMALIBS}
|
LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 ${XINERAMALIBS}
|
||||||
|
|
||||||
# flags
|
# flags
|
||||||
CPPFLAGS = -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
|
CPPFLAGS = -D_BSD_SOURCE -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
|
||||||
CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS}
|
CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS}
|
||||||
LDFLAGS = -s ${LIBS}
|
LDFLAGS = -s ${LIBS}
|
||||||
|
|
||||||
|
18
dmenu.c
18
dmenu.c
@ -1,5 +1,4 @@
|
|||||||
/* See LICENSE file for copyright and license details. */
|
/* See LICENSE file for copyright and license details. */
|
||||||
#define _BSD_SOURCE
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
@ -141,7 +140,7 @@ cistrstr(const char *s, const char *sub) {
|
|||||||
do {
|
do {
|
||||||
do {
|
do {
|
||||||
if((csub = *s++) == 0)
|
if((csub = *s++) == 0)
|
||||||
return (NULL);
|
return NULL;
|
||||||
}
|
}
|
||||||
while(tolower(csub) != c);
|
while(tolower(csub) != c);
|
||||||
}
|
}
|
||||||
@ -318,7 +317,7 @@ 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, NULL);
|
||||||
if(IsKeypadKey(ksym)) {
|
if(IsKeypadKey(ksym)) {
|
||||||
if(ksym == XK_KP_Enter)
|
if(ksym == XK_KP_Enter)
|
||||||
ksym = XK_Return;
|
ksym = XK_Return;
|
||||||
@ -396,10 +395,7 @@ kpress(XKeyEvent * e) {
|
|||||||
default:
|
default:
|
||||||
if(num && !iscntrl((int) buf[0])) {
|
if(num && !iscntrl((int) buf[0])) {
|
||||||
buf[num] = 0;
|
buf[num] = 0;
|
||||||
if(len > 0)
|
strncpy(text + len, buf, sizeof text - len);
|
||||||
strncat(text, buf, sizeof text);
|
|
||||||
else
|
|
||||||
strncpy(text, buf, sizeof text);
|
|
||||||
match(text);
|
match(text);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -537,7 +533,7 @@ readstdin(void) {
|
|||||||
maxname = p;
|
maxname = p;
|
||||||
max = len;
|
max = len;
|
||||||
}
|
}
|
||||||
if((new = (Item *)malloc(sizeof(Item))) == NULL)
|
if(!(new = (Item *)malloc(sizeof(Item))))
|
||||||
eprint("fatal: could not malloc() %u bytes\n", sizeof(Item));
|
eprint("fatal: could not malloc() %u bytes\n", sizeof(Item));
|
||||||
new->next = new->left = new->right = NULL;
|
new->next = new->left = new->right = NULL;
|
||||||
new->text = p;
|
new->text = p;
|
||||||
@ -596,7 +592,7 @@ setup(Bool topbar) {
|
|||||||
initfont(font);
|
initfont(font);
|
||||||
|
|
||||||
/* menu window */
|
/* menu window */
|
||||||
wa.override_redirect = 1;
|
wa.override_redirect = True;
|
||||||
wa.background_pixmap = ParentRelative;
|
wa.background_pixmap = ParentRelative;
|
||||||
wa.event_mask = ExposureMask | ButtonPressMask | KeyPressMask;
|
wa.event_mask = ExposureMask | ButtonPressMask | KeyPressMask;
|
||||||
|
|
||||||
@ -634,7 +630,7 @@ setup(Bool topbar) {
|
|||||||
|
|
||||||
/* 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, NULL);
|
||||||
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);
|
||||||
@ -705,7 +701,7 @@ main(int argc, char *argv[]) {
|
|||||||
" [-p <prompt>] [-sb <color>] [-sf <color>] [-v]\n");
|
" [-p <prompt>] [-sb <color>] [-sf <color>] [-v]\n");
|
||||||
if(!setlocale(LC_CTYPE, "") || !XSupportsLocale())
|
if(!setlocale(LC_CTYPE, "") || !XSupportsLocale())
|
||||||
fprintf(stderr, "warning: no locale support\n");
|
fprintf(stderr, "warning: no locale support\n");
|
||||||
if(!(dpy = XOpenDisplay(0)))
|
if(!(dpy = XOpenDisplay(NULL)))
|
||||||
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);
|
||||||
|
Reference in New Issue
Block a user