+ }
+}
+
+void
+setup(void) {
+ int x, y, screen = DefaultScreen(dc->dpy);
+ Window root = RootWindow(dc->dpy, screen);
+ XSetWindowAttributes swa;
+ XIM xim;
+#ifdef XINERAMA
+ int n;
+ XineramaScreenInfo *info;
+#endif
+
+ normcol[ColBG] = getcolor(dc, normbgcolor);
+ normcol[ColFG] = getcolor(dc, normfgcolor);
+ selcol[ColBG] = getcolor(dc, selbgcolor);
+ selcol[ColFG] = getcolor(dc, selfgcolor);
+ outcol[ColBG] = getcolor(dc, outbgcolor);
+ outcol[ColFG] = getcolor(dc, outfgcolor);
+
+ clip = XInternAtom(dc->dpy, "CLIPBOARD", False);
+ utf8 = XInternAtom(dc->dpy, "UTF8_STRING", False);
+
+ /* calculate menu geometry */
+ bh = dc->font.height + 2;
+ lines = MAX(lines, 0);
+ mh = (lines + 1) * bh;
+#ifdef XINERAMA
+ if((info = XineramaQueryScreens(dc->dpy, &n))) {
+ int a, j, di, i = 0, area = 0;
+ unsigned int du;
+ Window w, pw, dw, *dws;
+ XWindowAttributes wa;
+
+ XGetInputFocus(dc->dpy, &w, &di);
+ if(w != root && w != PointerRoot && w != None) {
+ /* find top-level window containing current input focus */
+ do {
+ if(XQueryTree(dc->dpy, (pw = w), &dw, &w, &dws, &du) && dws)
+ XFree(dws);
+ } while(w != root && w != pw);
+ /* find xinerama screen with which the window intersects most */
+ if(XGetWindowAttributes(dc->dpy, pw, &wa))
+ for(j = 0; j < n; j++)
+ if((a = INTERSECT(wa.x, wa.y, wa.width, wa.height, info[j])) > area) {
+ area = a;
+ i = j;
+ }