about summary refs log tree commit diff
path: root/dmenu.c
diff options
context:
space:
mode:
authorAnselm R Garbe <anselm@garbe.us>2013-08-02 22:30:20 +0200
committerAnselm R Garbe <anselm@garbe.us>2013-08-02 22:30:20 +0200
commit13f787306f46a5f838987e3b546d85d1bb1c3c01 (patch)
tree707936c71ac586efa397fda75ab2de0b40512e25 /dmenu.c
parentaccepted vi'is exit approach ^[ (suggested by Arkaduisz) (diff)
downloaddmenu-13f787306f46a5f838987e3b546d85d1bb1c3c01.tar.gz
dmenu-13f787306f46a5f838987e3b546d85d1bb1c3c01.tar.bz2
dmenu-13f787306f46a5f838987e3b546d85d1bb1c3c01.zip
applied Martti Kühne's dmenu monitor patch
https://gist.github.com/mar77i/3349298/raw/f6581ca96627f4c71c0bd1faf531daaf2a613b95/monarg.patch becomes upstream now
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;
 static Item *prev, *curr, *next, *sel;
 static Window win;
 static XIC xic;
+static int mon = -1;
 
 #include "config.h"
 
@@ -84,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 */
@@ -557,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)
@@ -572,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;
@@ -614,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);
 }