diff options
author | Anselm R Garbe <anselm@garbe.us> | 2013-08-02 22:30:20 +0200 |
---|---|---|
committer | Anselm R Garbe <anselm@garbe.us> | 2013-08-02 22:30:20 +0200 |
commit | 13f787306f46a5f838987e3b546d85d1bb1c3c01 (patch) | |
tree | 707936c71ac586efa397fda75ab2de0b40512e25 | |
parent | 597d4b43379433a5bf86d490f747c0eeda38bba8 (diff) |
applied Martti Kühne's dmenu monitor patch
https://gist.github.com/mar77i/3349298/raw/f6581ca96627f4c71c0bd1faf531daaf2a613b95/monarg.patch becomes upstream now
-rw-r--r-- | LICENSE | 2 | ||||
-rw-r--r-- | dmenu.1 | 5 | ||||
-rw-r--r-- | dmenu.c | 11 |
3 files changed, 14 insertions, 4 deletions
@@ -1,7 +1,7 @@ | |||
1 | MIT/X Consortium License | 1 | MIT/X Consortium License |
2 | 2 | ||
3 | © 2006-2013 Anselm R Garbe <anselm@garbe.us> | ||
3 | © 2010-2012 Connor Lane Smith <cls@lubutu.com> | 4 | © 2010-2012 Connor Lane Smith <cls@lubutu.com> |
4 | © 2006-2012 Anselm R Garbe <anselm@garbe.us> | ||
5 | © 2009 Gottox <gottox@s01.de> | 5 | © 2009 Gottox <gottox@s01.de> |
6 | © 2009 Markus Schnalke <meillo@marmaro.de> | 6 | © 2009 Markus Schnalke <meillo@marmaro.de> |
7 | © 2009 Evan Gates <evan.gates@gmail.com> | 7 | © 2009 Evan Gates <evan.gates@gmail.com> |
@@ -7,6 +7,8 @@ dmenu \- dynamic menu | |||
7 | .RB [ \-f ] | 7 | .RB [ \-f ] |
8 | .RB [ \-i ] | 8 | .RB [ \-i ] |
9 | .RB [ \-l | 9 | .RB [ \-l |
10 | .RB [ \-m | ||
11 | .IR monitor ] | ||
10 | .IR lines ] | 12 | .IR lines ] |
11 | .RB [ \-p | 13 | .RB [ \-p |
12 | .IR prompt ] | 14 | .IR prompt ] |
@@ -49,6 +51,9 @@ dmenu matches menu items case insensitively. | |||
49 | .BI \-l " lines" | 51 | .BI \-l " lines" |
50 | dmenu lists items vertically, with the given number of lines. | 52 | dmenu lists items vertically, with the given number of lines. |
51 | .TP | 53 | .TP |
54 | .BI \-m " monitor" | ||
55 | dmenu is displayed on the monitor supplied. | ||
56 | .TP | ||
52 | .BI \-p " prompt" | 57 | .BI \-p " prompt" |
53 | defines the prompt to be displayed to the left of the input field. | 58 | defines the prompt to be displayed to the left of the input field. |
54 | .TP | 59 | .TP |
@@ -54,6 +54,7 @@ static Item *matches, *matchend; | |||
54 | static Item *prev, *curr, *next, *sel; | 54 | static Item *prev, *curr, *next, *sel; |
55 | static Window win; | 55 | static Window win; |
56 | static XIC xic; | 56 | static XIC xic; |
57 | static 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 | ||
615 | void | 620 | void |
616 | usage(void) { | 621 | usage(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 | } |