merge default -> lsx
Connor Lane Smith cls@lubutu.com
Sun, 16 Oct 2011 18:13:29 +0100
M
Makefile
→
Makefile
@@ -30,12 +30,12 @@ @${CC} -o $@ lsx.o ${LDFLAGS}
clean: @echo cleaning - @rm -f dmenu ${OBJ} dmenu-${VERSION}.tar.gz + @rm -f dmenu lsx ${OBJ} dmenu-${VERSION}.tar.gz dist: clean @echo creating dist tarball @mkdir -p dmenu-${VERSION} - @cp LICENSE Makefile README config.mk dmenu.1 draw.h dmenu_run ${SRC} dmenu-${VERSION} + @cp LICENSE Makefile README config.mk dmenu.1 draw.h dmenu_run lsx.1 ${SRC} dmenu-${VERSION} @tar -cf dmenu-${VERSION}.tar dmenu-${VERSION} @gzip dmenu-${VERSION}.tar @rm -rf dmenu-${VERSION}
M
draw.c
→
draw.c
@@ -96,7 +96,7 @@ initdc(void) {
DC *dc; if(!setlocale(LC_CTYPE, "") || !XSupportsLocale()) - fprintf(stderr, "no locale support\n"); + fputs("no locale support\n", stderr); if(!(dc = calloc(1, sizeof *dc))) eprintf("cannot malloc %u bytes:", sizeof *dc); if(!(dc->dpy = XOpenDisplay(NULL)))@@ -120,28 +120,28 @@ }
Bool loadfont(DC *dc, const char *fontstr) { - char *def, **missing; + char *def, **missing, **names; int i, n; + XFontStruct **xfonts; if(!*fontstr) return False; if((dc->font.set = XCreateFontSet(dc->dpy, fontstr, &missing, &n, &def))) { - char **names; - XFontStruct **xfonts; - n = XFontsOfFontSet(dc->font.set, &xfonts, &names); - for(i = dc->font.ascent = dc->font.descent = 0; i < n; i++) { - dc->font.ascent = MAX(dc->font.ascent, xfonts[i]->ascent); + for(i = 0; i < n; i++) { + dc->font.ascent = MAX(dc->font.ascent, xfonts[i]->ascent); dc->font.descent = MAX(dc->font.descent, xfonts[i]->descent); + dc->font.width = MAX(dc->font.width, xfonts[i]->max_bounds.width); } } else if((dc->font.xfont = XLoadQueryFont(dc->dpy, fontstr))) { - dc->font.ascent = dc->font.xfont->ascent; + dc->font.ascent = dc->font.xfont->ascent; dc->font.descent = dc->font.xfont->descent; + dc->font.width = dc->font.xfont->max_bounds.width; } if(missing) XFreeStringList(missing); - return (dc->font.set || dc->font.xfont); + return dc->font.set || dc->font.xfont; } void@@ -154,10 +154,10 @@ resizedc(DC *dc, unsigned int w, unsigned int h) {
if(dc->canvas) XFreePixmap(dc->dpy, dc->canvas); + dc->w = w; + dc->h = h; dc->canvas = XCreatePixmap(dc->dpy, DefaultRootWindow(dc->dpy), w, h, DefaultDepth(dc->dpy, DefaultScreen(dc->dpy))); - dc->w = w; - dc->h = h; } int
M
lsx.c
→
lsx.c
@@ -1,8 +1,8 @@
/* See LICENSE file for copyright and license details. */ #include <dirent.h> +#include <limits.h> #include <stdio.h> #include <stdlib.h> -#include <string.h> #include <unistd.h> #include <sys/stat.h>@@ -31,7 +31,7 @@ perror(dir);
return; } while((d = readdir(dp))) - if(snprintf(buf, sizeof buf, "%s/%s", dir, d->d_name) < sizeof buf + if(snprintf(buf, sizeof buf, "%s/%s", dir, d->d_name) < (int)sizeof buf && !stat(buf, &st) && S_ISREG(st.st_mode) && access(buf, X_OK) == 0) puts(d->d_name); closedir(dp);