1 /* See LICENSE file for copyright and license details. */
5 #include <X11/keysym.h>
7 #include <X11/extensions/Xinerama.h>
16 unsigned int numlockmask = 0;
18 unsigned long normcol[ColLast];
19 unsigned long selcol[ColLast];
29 for(len = 1000; len; len--) {
30 if(XGrabKeyboard(dpy, root, True, GrabModeAsync, GrabModeAsync, CurrentTime)
44 while(!XNextEvent(dpy, &ev))
50 if(ev.xexpose.count == 0)
53 case VisibilityNotify:
54 if(ev.xvisibility.state != VisibilityUnobscured)
55 XRaiseWindow(dpy, win);
62 setup(unsigned int lines) {
66 XineramaScreenInfo *info = NULL;
68 XModifierKeymap *modmap;
69 XSetWindowAttributes wa;
71 /* init modifier map */
72 modmap = XGetModifierMapping(dpy);
73 for(i = 0; i < 8; i++)
74 for(j = 0; j < modmap->max_keypermod; j++) {
75 if(modmap->modifiermap[i * modmap->max_keypermod + j]
76 == XKeysymToKeycode(dpy, XK_Num_Lock))
77 numlockmask = (1 << i);
79 XFreeModifiermap(modmap);
82 normcol[ColBG] = getcolor(&dc, normbgcolor);
83 normcol[ColFG] = getcolor(&dc, normfgcolor);
84 selcol[ColBG] = getcolor(&dc, selbgcolor);
85 selcol[ColFG] = getcolor(&dc, selfgcolor);
89 wa.override_redirect = True;
90 wa.background_pixmap = ParentRelative;
91 wa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask;
93 /* input window geometry */
94 mh = (dc.font.height + 2) * (lines + 1);
96 if(XineramaIsActive(dpy) && (info = XineramaQueryScreens(dpy, &n))) {
102 if(XQueryPointer(dpy, root, &dummy, &dummy, &x, &y, &di, &di, &dui))
103 for(i = 0; i < n; i++)
104 if(INRECT(x, y, info[i].x_org, info[i].y_org, info[i].width, info[i].height))
108 y = topbar ? info[i].y_org : info[i].y_org + info[i].height - mh;
116 y = topbar ? 0 : DisplayHeight(dpy, screen) - mh;
117 mw = DisplayWidth(dpy, screen);
120 win = XCreateWindow(dpy, root, x, y, mw, mh, 0,
121 DefaultDepth(dpy, screen), CopyFromParent,
122 DefaultVisual(dpy, screen),
123 CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
127 promptw = MIN(textw(&dc, prompt), mw / 5);
128 XMapRaised(dpy, win);