fixed bad parenting, simpler vlist
518c9b72
1 file(s) · +20 −21
| 91 | 91 | static Item *next = NULL; |
|
| 92 | 92 | static Item *prev = NULL; |
|
| 93 | 93 | static Item *curr = NULL; |
|
| 94 | - | static Window root, win; |
|
| 94 | + | static Window parent, win; |
|
| 95 | 95 | static int (*fstrncmp)(const char *, const char *, size_t n) = strncmp; |
|
| 96 | 96 | static char *(*fstrstr)(const char *, const char *) = strstr; |
|
| 97 | - | static Bool vlist = False; |
|
| 98 | - | static unsigned int lines = 5; |
|
| 97 | + | static unsigned int lines = 0; |
|
| 99 | 98 | static void (*calcoffsets)(void) = calcoffsetsh; |
|
| 100 | 99 | ||
| 101 | 100 | void |
|
| 220 | 219 | dc.x += promptw; |
|
| 221 | 220 | dc.w = mw - promptw; |
|
| 222 | 221 | /* print command */ |
|
| 223 | - | if(cmdw && item && !vlist) |
|
| 222 | + | if(cmdw && item && lines == 0) |
|
| 224 | 223 | dc.w = cmdw; |
|
| 225 | 224 | drawtext(text[0] ? text : NULL, dc.norm); |
|
| 226 | 225 | drawcursor(); |
|
| 227 | - | dc.x += cmdw; |
|
| 228 | 226 | if(curr) { |
|
| 229 | - | if(vlist) |
|
| 227 | + | if(lines > 0) |
|
| 230 | 228 | drawmenuv(); |
|
| 231 | 229 | else |
|
| 232 | 230 | drawmenuh(); |
|
| 239 | 237 | drawmenuh(void) { |
|
| 240 | 238 | Item *i; |
|
| 241 | 239 | ||
| 240 | + | dc.x += cmdw; |
|
| 242 | 241 | dc.w = spaceitem; |
|
| 243 | - | drawtext((curr && curr->left) ? "<" : NULL, dc.norm); |
|
| 242 | + | drawtext(curr->left ? "<" : NULL, dc.norm); |
|
| 244 | 243 | dc.x += dc.w; |
|
| 245 | 244 | /* determine maximum items */ |
|
| 246 | 245 | for(i = curr; i != next; i=i->right) { |
|
| 321 | 320 | unsigned int len; |
|
| 322 | 321 | ||
| 323 | 322 | for(len = 1000; len; len--) { |
|
| 324 | - | if(XGrabKeyboard(dpy, root, True, GrabModeAsync, GrabModeAsync, CurrentTime) |
|
| 323 | + | if(XGrabKeyboard(dpy, parent, True, GrabModeAsync, GrabModeAsync, CurrentTime) |
|
| 325 | 324 | == GrabSuccess) |
|
| 326 | 325 | break; |
|
| 327 | 326 | usleep(1000); |
|
| 675 | 674 | #endif |
|
| 676 | 675 | XModifierKeymap *modmap; |
|
| 677 | 676 | XSetWindowAttributes wa; |
|
| 677 | + | XWindowAttributes pwa; |
|
| 678 | 678 | ||
| 679 | 679 | /* init modifier map */ |
|
| 680 | 680 | modmap = XGetModifierMapping(dpy); |
|
| 699 | 699 | wa.event_mask = ExposureMask | ButtonPressMask | KeyPressMask | VisibilityChangeMask; |
|
| 700 | 700 | ||
| 701 | 701 | /* menu window geometry */ |
|
| 702 | - | mh = dc.font.height + 2; |
|
| 703 | - | mh = vlist ? mh * (lines+1) : mh; |
|
| 702 | + | mh = (dc.font.height + 2) * (lines + 1); |
|
| 704 | 703 | #if XINERAMA |
|
| 705 | - | if(XineramaIsActive(dpy) && (info = XineramaQueryScreens(dpy, &n))) { |
|
| 704 | + | if(parent == RootWindow(dpy, screen) && XineramaIsActive(dpy) && (info = XineramaQueryScreens(dpy, &n))) { |
|
| 706 | 705 | i = 0; |
|
| 707 | 706 | if(n > 1) { |
|
| 708 | 707 | int di; |
|
| 709 | 708 | unsigned int dui; |
|
| 710 | 709 | Window dummy; |
|
| 711 | - | if(XQueryPointer(dpy, root, &dummy, &dummy, &x, &y, &di, &di, &dui)) |
|
| 710 | + | if(XQueryPointer(dpy, parent, &dummy, &dummy, &x, &y, &di, &di, &dui)) |
|
| 712 | 711 | for(i = 0; i < n; i++) |
|
| 713 | 712 | if(INRECT(x, y, info[i].x_org, info[i].y_org, info[i].width, info[i].height)) |
|
| 714 | 713 | break; |
|
| 721 | 720 | else |
|
| 722 | 721 | #endif |
|
| 723 | 722 | { |
|
| 723 | + | XGetWindowAttributes(dpy, parent, &pwa); |
|
| 724 | 724 | x = 0; |
|
| 725 | - | y = topbar ? 0 : DisplayHeight(dpy, screen) - mh; |
|
| 726 | - | mw = DisplayWidth(dpy, screen); |
|
| 725 | + | y = topbar ? 0 : pwa.height - mh; |
|
| 726 | + | mw = pwa.width; |
|
| 727 | 727 | } |
|
| 728 | 728 | ||
| 729 | - | win = XCreateWindow(dpy, root, x, y, mw, mh, 0, |
|
| 729 | + | win = XCreateWindow(dpy, parent, x, y, mw, mh, 0, |
|
| 730 | 730 | DefaultDepth(dpy, screen), CopyFromParent, |
|
| 731 | 731 | DefaultVisual(dpy, screen), |
|
| 732 | 732 | CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); |
|
| 733 | 733 | ||
| 734 | 734 | /* pixmap */ |
|
| 735 | - | dc.drawable = XCreatePixmap(dpy, root, mw, mh, DefaultDepth(dpy, screen)); |
|
| 736 | - | dc.gc = XCreateGC(dpy, root, 0, NULL); |
|
| 735 | + | dc.drawable = XCreatePixmap(dpy, parent, mw, mh, DefaultDepth(dpy, screen)); |
|
| 736 | + | dc.gc = XCreateGC(dpy, parent, 0, NULL); |
|
| 737 | 737 | XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter); |
|
| 738 | 738 | if(!dc.font.set) |
|
| 739 | 739 | XSetFont(dpy, dc.gc, dc.font.xfont->fid); |
|
| 776 | 776 | else if(!strcmp(argv[i], "-b")) |
|
| 777 | 777 | topbar = False; |
|
| 778 | 778 | else if(!strcmp(argv[i], "-e")) { |
|
| 779 | - | if(++i < argc) root = atoi(argv[i]); |
|
| 779 | + | if(++i < argc) parent = atoi(argv[i]); |
|
| 780 | 780 | } |
|
| 781 | 781 | else if(!strcmp(argv[i], "-l")) { |
|
| 782 | - | vlist = True; |
|
| 783 | 782 | calcoffsets = calcoffsetsv; |
|
| 784 | 783 | if(++i < argc) lines = atoi(argv[i]); |
|
| 785 | 784 | } |
|
| 811 | 810 | if(!(dpy = XOpenDisplay(NULL))) |
|
| 812 | 811 | eprint("dmenu: cannot open display\n"); |
|
| 813 | 812 | screen = DefaultScreen(dpy); |
|
| 814 | - | if(!root) |
|
| 815 | - | root = RootWindow(dpy, screen); |
|
| 813 | + | if(!parent) |
|
| 814 | + | parent = RootWindow(dpy, screen); |
|
| 816 | 815 | ||
| 817 | 816 | readstdin(); |
|
| 818 | 817 | running = grabkeyboard(); |
|