aboutsummaryrefslogtreecommitdiff
path: root/dmenu.c
diff options
context:
space:
mode:
Diffstat (limited to 'dmenu.c')
-rw-r--r--dmenu.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/dmenu.c b/dmenu.c
index 5e0a19c..8d9bbb6 100644
--- a/dmenu.c
+++ b/dmenu.c
@@ -54,6 +54,7 @@ static Item *matches, *matchend;
54static Item *prev, *curr, *next, *sel; 54static Item *prev, *curr, *next, *sel;
55static Window win; 55static Window win;
56static XIC xic; 56static XIC xic;
57static int mon = -1;
57 58
58#include "config.h" 59#include "config.h"
59 60
@@ -84,6 +85,8 @@ main(int argc, char *argv[]) {
84 /* these options take one argument */ 85 /* these options take one argument */
85 else if(!strcmp(argv[i], "-l")) /* number of lines in vertical list */ 86 else if(!strcmp(argv[i], "-l")) /* number of lines in vertical list */
86 lines = atoi(argv[++i]); 87 lines = atoi(argv[++i]);
88 else if(!strcmp(argv[i], "-m"))
89 mon = atoi(argv[++i]);
87 else if(!strcmp(argv[i], "-p")) /* adds prompt to left of input field */ 90 else if(!strcmp(argv[i], "-p")) /* adds prompt to left of input field */
88 prompt = argv[++i]; 91 prompt = argv[++i];
89 else if(!strcmp(argv[i], "-fn")) /* font or font set */ 92 else if(!strcmp(argv[i], "-fn")) /* font or font set */
@@ -557,7 +560,9 @@ setup(void) {
557 XWindowAttributes wa; 560 XWindowAttributes wa;
558 561
559 XGetInputFocus(dc->dpy, &w, &di); 562 XGetInputFocus(dc->dpy, &w, &di);
560 if(w != root && w != PointerRoot && w != None) { 563 if(mon != -1 && mon < n)
564 i = mon;
565 if(!i && w != root && w != PointerRoot && w != None) {
561 /* find top-level window containing current input focus */ 566 /* find top-level window containing current input focus */
562 do { 567 do {
563 if(XQueryTree(dc->dpy, (pw = w), &dw, &w, &dws, &du) && dws) 568 if(XQueryTree(dc->dpy, (pw = w), &dw, &w, &dws, &du) && dws)
@@ -572,7 +577,7 @@ setup(void) {
572 } 577 }
573 } 578 }
574 /* no focused window is on screen, so use pointer location instead */ 579 /* no focused window is on screen, so use pointer location instead */
575 if(!area && XQueryPointer(dc->dpy, root, &dw, &dw, &x, &y, &di, &di, &du)) 580 if(mon == -1 && !area && XQueryPointer(dc->dpy, root, &dw, &dw, &x, &y, &di, &di, &du))
576 for(i = 0; i < n; i++) 581 for(i = 0; i < n; i++)
577 if(INTERSECT(x, y, 1, 1, info[i])) 582 if(INTERSECT(x, y, 1, 1, info[i]))
578 break; 583 break;
@@ -614,7 +619,7 @@ setup(void) {
614 619
615void 620void
616usage(void) { 621usage(void) {
617 fputs("usage: dmenu [-b] [-f] [-i] [-l lines] [-p prompt] [-fn font]\n" 622 fputs("usage: dmenu [-b] [-f] [-i] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
618 " [-nb color] [-nf color] [-sb color] [-sf color] [-v]\n", stderr); 623 " [-nb color] [-nf color] [-sb color] [-sf color] [-v]\n", stderr);
619 exit(EXIT_FAILURE); 624 exit(EXIT_FAILURE);
620} 625}