diff options
Diffstat (limited to 'dmenu-5.0/dmenu.c')
| -rw-r--r-- | dmenu-5.0/dmenu.c | 83 |
1 files changed, 12 insertions, 71 deletions
diff --git a/dmenu-5.0/dmenu.c b/dmenu-5.0/dmenu.c index 018b382..65f25ce 100644 --- a/dmenu-5.0/dmenu.c +++ b/dmenu-5.0/dmenu.c @@ -10,7 +10,6 @@ #include <X11/Xlib.h> #include <X11/Xatom.h> -#include <X11/Xproto.h> #include <X11/Xutil.h> #ifdef XINERAMA #include <X11/extensions/Xinerama.h> @@ -26,8 +25,6 @@ #define LENGTH(X) (sizeof X / sizeof X[0]) #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad) -#define OPAQUE 0xffU - /* enums */ enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */ @@ -40,9 +37,6 @@ struct item { static char text[BUFSIZ] = ""; static char *embed; static int bh, mw, mh; -static int dmx = 0; /* put dmenu at this x offset */ -static int dmy = 0; /* put dmenu at this y offset (measured from the bottom if topbar is 0) */ -static unsigned int dmw = 0; /* make dmenu this wide */ static int inputw = 0, promptw; static int lrpad; /* sum of left and right padding */ static size_t cursor; @@ -59,16 +53,10 @@ static XIC xic; static Drw *drw; static Clr *scheme[SchemeLast]; -static int useargb = 0; -static Visual *visual; -static int depth; -static Colormap cmap; - #include "config.h" static int (*fstrncmp)(const char *, const char *, size_t) = strncmp; static char *(*fstrstr)(const char *, const char *) = strstr; -static void xinitvisual(); static void appenditem(struct item *item, struct item **list, struct item **last) @@ -614,7 +602,7 @@ setup(void) #endif /* init appearance */ for (j = 0; j < SchemeLast; j++) - scheme[j] = drw_scm_create(drw, colors[j], alphas[i], 2); + scheme[j] = drw_scm_create(drw, colors[j], 2); clip = XInternAtom(dpy, "CLIPBOARD", False); utf8 = XInternAtom(dpy, "UTF8_STRING", False); @@ -649,9 +637,9 @@ setup(void) if (INTERSECT(x, y, 1, 1, info[i])) break; - x = info[i].x_org + dmx; - y = info[i].y_org + (topbar ? dmy : info[i].height - mh - dmy); - mw = (dmw>0 ? dmw : info[i].width); + x = info[i].x_org; + y = info[i].y_org + (topbar ? 0 : info[i].height - mh); + mw = info[i].width; XFree(info); } else #endif @@ -659,9 +647,9 @@ setup(void) if (!XGetWindowAttributes(dpy, parentwin, &wa)) die("could not get embedding window attributes: 0x%lx", parentwin); - x = dmx; - y = topbar ? dmy : wa.height - mh - dmy; - mw = (dmw>0 ? dmw : wa.width); + x = 0; + y = topbar ? 0 : wa.height - mh; + mw = wa.width; } promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0; inputw = MIN(inputw, mw/3); @@ -669,13 +657,11 @@ setup(void) /* create menu window */ swa.override_redirect = True; - swa.background_pixel = 0; - swa.border_pixel = 0; - swa.colormap = cmap; + swa.background_pixel = scheme[SchemeNorm][ColBg].pixel; swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask; - win = XCreateWindow(dpy, parentwin, x, y, mw, mh, border_width, - depth, CopyFromParent, visual, - CWOverrideRedirect | CWBackPixel | CWBorderPixel | CWColormap | CWEventMask, &swa); + win = XCreateWindow(dpy, parentwin, x, y, mw, mh, 0, + CopyFromParent, CopyFromParent, CopyFromParent, + CWOverrideRedirect | CWBackPixel | CWEventMask, &swa); XSetClassHint(dpy, win, &ch); @@ -704,7 +690,6 @@ static void usage(void) { fputs("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n" - " [-x xoffset] [-y yoffset] [-z width]\n" " [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]\n", stderr); exit(1); } @@ -732,12 +717,6 @@ main(int argc, char *argv[]) /* these options take one argument */ else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */ lines = atoi(argv[++i]); - else if (!strcmp(argv[i], "-x")) /* window x offset */ - dmx = atoi(argv[++i]); - else if (!strcmp(argv[i], "-y")) /* window y offset (from bottom up if -b) */ - dmy = atoi(argv[++i]); - else if (!strcmp(argv[i], "-z")) /* make dmenu this wide */ - dmw = atoi(argv[++i]); else if (!strcmp(argv[i], "-m")) mon = atoi(argv[++i]); else if (!strcmp(argv[i], "-p")) /* adds prompt to left of input field */ @@ -768,8 +747,7 @@ main(int argc, char *argv[]) if (!XGetWindowAttributes(dpy, parentwin, &wa)) die("could not get embedding window attributes: 0x%lx", parentwin); - xinitvisual(); - drw = drw_create(dpy, screen, root, wa.width, wa.height, visual, depth, cmap); + drw = drw_create(dpy, screen, root, wa.width, wa.height); if (!drw_fontset_create(drw, fonts, LENGTH(fonts))) die("no fonts could be loaded."); lrpad = drw->fonts->h; @@ -791,40 +769,3 @@ main(int argc, char *argv[]) return 1; /* unreachable */ } - - void -xinitvisual() -{ - XVisualInfo *infos; - XRenderPictFormat *fmt; - int nitems; - int i; - - XVisualInfo tpl = { - .screen = screen, - .depth = 32, - .class = TrueColor - }; - long masks = VisualScreenMask | VisualDepthMask | VisualClassMask; - - infos = XGetVisualInfo(dpy, masks, &tpl, &nitems); - visual = NULL; - for(i = 0; i < nitems; i ++) { - fmt = XRenderFindVisualFormat(dpy, infos[i].visual); - if (fmt->type == PictTypeDirect && fmt->direct.alphaMask) { - visual = infos[i].visual; - depth = infos[i].depth; - cmap = XCreateColormap(dpy, root, visual, AllocNone); - useargb = 1; - break; - } - } - - XFree(infos); - - if (! visual) { - visual = DefaultVisual(dpy, screen); - depth = DefaultDepth(dpy, screen); - cmap = DefaultColormap(dpy, screen); - } -} |