X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=dmenu.c;h=f105b5679d38cb0d10f2239f3a4836076662af5f;hb=c71abdc65c8a7ff9597f7b6b5bf60a59be174224;hp=1cd9f611312064ef7e4449b03661b9e75e040e49;hpb=4c8d43ab7382910f3577d6ed03ebaf3026db8419;p=dmenu.git diff --git a/dmenu.c b/dmenu.c index 1cd9f61..f105b56 100644 --- a/dmenu.c +++ b/dmenu.c @@ -454,6 +454,7 @@ readstdin(void) { if(items) items[i].text = NULL; inputw = maxstr ? textw(dc, maxstr) : 0; + lines = MIN(lines, i); } void @@ -484,7 +485,7 @@ void setup(void) { int x, y, screen = DefaultScreen(dc->dpy); Window root = RootWindow(dc->dpy, screen); - XSetWindowAttributes wa; + XSetWindowAttributes swa; #ifdef XINERAMA int n; XineramaScreenInfo *info; @@ -505,9 +506,14 @@ setup(void) { if((info = XineramaQueryScreens(dc->dpy, &n))) { int i, di; unsigned int du; - Window dw; + Window w, dw; + XWindowAttributes wa; - XQueryPointer(dc->dpy, root, &dw, &dw, &x, &y, &di, &di, &du); + XGetInputFocus(dc->dpy, &w, &di); + if(w != root && w != PointerRoot && w != None && XGetWindowAttributes(dc->dpy, w, &wa)) + XTranslateCoordinates(dc->dpy, w, root, wa.x, wa.y, &x, &y, &dw); + else + XQueryPointer(dc->dpy, root, &dw, &dw, &x, &y, &di, &di, &du); for(i = 0; i < n-1; i++) if(INRECT(x, y, info[i].x_org, info[i].y_org, info[i].width, info[i].height)) break; @@ -528,13 +534,13 @@ setup(void) { match(); /* menu window */ - wa.override_redirect = True; - wa.background_pixmap = ParentRelative; - wa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask; + swa.override_redirect = True; + swa.background_pixmap = ParentRelative; + swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask; win = XCreateWindow(dc->dpy, root, x, y, mw, mh, 0, DefaultDepth(dc->dpy, screen), CopyFromParent, DefaultVisual(dc->dpy, screen), - CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); + CWOverrideRedirect | CWBackPixmap | CWEventMask, &swa); XMapRaised(dc->dpy, win); resizedc(dc, mw, mh);