-void
-setup(int x, int y, int w) {
- unsigned int i, j;
- XModifierKeymap *modmap;
- XSetWindowAttributes wa;
-
- /* 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 */
- dc.norm[ColBG] = getcolor(normbg);
- dc.norm[ColFG] = getcolor(normfg);
- dc.sel[ColBG] = getcolor(selbg);
- dc.sel[ColFG] = getcolor(selfg);
- initfont(font);
-
- /* menu window */
- wa.override_redirect = 1;
- wa.background_pixmap = ParentRelative;
- wa.event_mask = ExposureMask | ButtonPressMask | KeyPressMask;
- mw = w ? w : DisplayWidth(dpy, screen);
- mh = dc.font.height + 2;
- win = XCreateWindow(dpy, root, x, y, mw, mh, 0,
- DefaultDepth(dpy, screen), CopyFromParent,
- DefaultVisual(dpy, screen),
- CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
-
- /* pixmap */
- dc.drawable = XCreatePixmap(dpy, root, mw, mh, DefaultDepth(dpy, screen));
- dc.gc = XCreateGC(dpy, root, 0, 0);
- XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
- if(!dc.font.set)
- XSetFont(dpy, dc.gc, dc.font.xfont->fid);
- if(maxname)
- cmdw = textw(maxname);
- if(cmdw > mw / 3)
- cmdw = mw / 3;
- if(prompt)
- promptw = textw(prompt);
- if(promptw > mw / 5)
- promptw = mw / 5;
- text[0] = 0;
- match(text);
- XMapRaised(dpy, win);
-}
-
-char *
-cistrstr(const char *s, const char *sub) {
- int c, csub;
- unsigned int len;
-
- if(!sub)
- return (char *)s;
- if((c = *sub++) != 0) {
- c = tolower(c);
- len = strlen(sub);
- do {
+static void
+setup(void)
+{
+ int x, y;
+ XSetWindowAttributes swa;
+ XIM xim;
+#ifdef XINERAMA
+ XineramaScreenInfo *info;
+ Window w, pw, dw, *dws;
+ XWindowAttributes wa;
+ int a, j, di, n, i = 0, area = 0;
+ unsigned int du;
+#endif
+
+ /* init appearance */
+ scheme[SchemeNorm].bg = drw_clr_create(drw, normbgcolor);
+ scheme[SchemeNorm].fg = drw_clr_create(drw, normfgcolor);
+ scheme[SchemeSel].bg = drw_clr_create(drw, selbgcolor);
+ scheme[SchemeSel].fg = drw_clr_create(drw, selfgcolor);
+ scheme[SchemeOut].bg = drw_clr_create(drw, outbgcolor);
+ scheme[SchemeOut].fg = drw_clr_create(drw, outfgcolor);
+
+ clip = XInternAtom(dpy, "CLIPBOARD", False);
+ utf8 = XInternAtom(dpy, "UTF8_STRING", False);
+
+ /* calculate menu geometry */
+ bh = drw->fonts[0]->h + 2;
+ lines = MAX(lines, 0);
+ mh = (lines + 1) * bh;
+#ifdef XINERAMA
+ if ((info = XineramaQueryScreens(dpy, &n))) {
+ XGetInputFocus(dpy, &w, &di);
+ if (mon != -1 && mon < n)
+ i = mon;
+ else if (w != root && w != PointerRoot && w != None) {
+ /* find top-level window containing current input focus */