X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=dinput.c;h=15f5e26c762f16fb332e6a0bf4b9530ff79e4f0a;hb=6c1d0e4d60b239e9533def6feaf8eb2138858c3e;hp=52118e58dd75747a3c86cf69deee9eb8aad05b44;hpb=bba30e26863c75e66678f9d028d394883d86150a;p=dmenu.git diff --git a/dinput.c b/dinput.c index 52118e5..15f5e26 100644 --- a/dinput.c +++ b/dinput.c @@ -25,32 +25,33 @@ static void cleanup(void); static void drawcursor(void); static void drawinput(void); -static void eprint(const char *errstr, ...); static Bool grabkeyboard(void); static void kpress(XKeyEvent * e); static void run(void); static void setup(Bool topbar); #include "config.h" +#include "draw.h" /* variables */ static char *prompt = NULL; static char text[4096]; static int promptw = 0; static int ret = 0; -static int screen; -static unsigned int mw, mh; static unsigned int cursor = 0; static unsigned int numlockmask = 0; static Bool running = True; -static Display *dpy; -static Window parent, win; +static Window win; -#include "draw.c" +Display *dpy; +DC dc; +int screen; +unsigned int mw, mh; +Window parent; void cleanup(void) { - dccleanup(); + drawcleanup(); XDestroyWindow(dpy, win); XUngrabKeyboard(dpy, CurrentTime); } @@ -86,16 +87,6 @@ drawinput(void) XFlush(dpy); } -void -eprint(const char *errstr, ...) { - va_list ap; - - va_start(ap, errstr); - vfprintf(stderr, errstr, ap); - va_end(ap); - exit(EXIT_FAILURE); -} - Bool grabkeyboard(void) { unsigned int len; @@ -173,7 +164,7 @@ kpress(XKeyEvent * e) { FILE *fp; char *s; if(!(fp = popen("sselp", "r"))) - eprint("dinput: cannot popen sselp\n"); + eprint("cannot popen sselp\n"); s = fgets(buf, sizeof buf, fp); pclose(fp); if(s == NULL) @@ -318,7 +309,7 @@ setup(Bool topbar) { DefaultVisual(dpy, screen), CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); - dcsetup(); + drawsetup(); if(prompt) promptw = MIN(textw(prompt), mw / 5); cursor = strlen(text); @@ -331,6 +322,7 @@ main(int argc, char *argv[]) { Bool topbar = True; /* command line args */ + progname = argv[0]; for(i = 1; i < argc; i++) if(!strcmp(argv[i], "-b")) topbar = False; @@ -365,7 +357,7 @@ main(int argc, char *argv[]) { if(!setlocale(LC_CTYPE, "") || !XSupportsLocale()) fprintf(stderr, "dinput: warning: no locale support\n"); if(!(dpy = XOpenDisplay(NULL))) - eprint("dinput: cannot open display\n"); + eprint("cannot open display\n"); screen = DefaultScreen(dpy); if(!parent) parent = RootWindow(dpy, screen);