X-Git-Url: https://git.armaanb.net/?a=blobdiff_plain;f=dmenu.c;h=8d9bbb65e868147e028df42954d77a867181b9eb;hb=5ed5e90bfb7760f24661281cf7156087afbe49d3;hp=c25dc82373f623757393c593eff6bf6292a76151;hpb=ec64f273fb7660d3746eb765dc02e40726a54294;p=dmenu.git diff --git a/dmenu.c b/dmenu.c index c25dc82..8d9bbb6 100644 --- a/dmenu.c +++ b/dmenu.c @@ -44,26 +44,19 @@ static char text[BUFSIZ] = ""; static int bh, mw, mh; static int inputw, promptw; static size_t cursor = 0; -static const char *font = NULL; -static const char *prompt = NULL; -static const char *normbgcolor = "#222222"; -static const char *normfgcolor = "#bbbbbb"; -static const char *selbgcolor = "#005577"; -static const char *selfgcolor = "#eeeeee"; -static const char *outbgcolor = "#00ffff"; -static const char *outfgcolor = "#000000"; -static unsigned int lines = 0; static unsigned long normcol[ColLast]; static unsigned long selcol[ColLast]; static unsigned long outcol[ColLast]; static Atom clip, utf8; -static Bool topbar = True; static DC *dc; static Item *items = NULL; static Item *matches, *matchend; static Item *prev, *curr, *next, *sel; static Window win; static XIC xic; +static int mon = -1; + +#include "config.h" static int (*fstrncmp)(const char *, const char *, size_t) = strncmp; static char *(*fstrstr)(const char *, const char *) = strstr; @@ -92,6 +85,8 @@ main(int argc, char *argv[]) { /* these options take one argument */ else if(!strcmp(argv[i], "-l")) /* number of lines in vertical list */ lines = atoi(argv[++i]); + else if(!strcmp(argv[i], "-m")) + mon = atoi(argv[++i]); else if(!strcmp(argv[i], "-p")) /* adds prompt to left of input field */ prompt = argv[++i]; else if(!strcmp(argv[i], "-fn")) /* font or font set */ @@ -287,6 +282,8 @@ keypress(XKeyEvent *ev) { case XK_Return: case XK_KP_Enter: break; + case XK_bracketleft: + exit(EXIT_FAILURE); default: return; } @@ -563,7 +560,9 @@ setup(void) { XWindowAttributes wa; XGetInputFocus(dc->dpy, &w, &di); - if(w != root && w != PointerRoot && w != None) { + if(mon != -1 && mon < n) + i = mon; + if(!i && 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) @@ -578,7 +577,7 @@ setup(void) { } } /* no focused window is on screen, so use pointer location instead */ - if(!area && XQueryPointer(dc->dpy, root, &dw, &dw, &x, &y, &di, &di, &du)) + if(mon == -1 && !area && XQueryPointer(dc->dpy, root, &dw, &dw, &x, &y, &di, &di, &du)) for(i = 0; i < n; i++) if(INTERSECT(x, y, 1, 1, info[i])) break; @@ -620,7 +619,7 @@ setup(void) { void usage(void) { - fputs("usage: dmenu [-b] [-f] [-i] [-l lines] [-p prompt] [-fn font]\n" + fputs("usage: dmenu [-b] [-f] [-i] [-l lines] [-p prompt] [-fn font] [-m monitor]\n" " [-nb color] [-nf color] [-sb color] [-sf color] [-v]\n", stderr); exit(EXIT_FAILURE); }