applied Martti Kühne's dmenu monitor patch

f6581ca966/monarg.patch becomes upstream now
This commit is contained in:
Anselm R Garbe 2013-08-02 22:30:20 +02:00
parent 597d4b4337
commit 13f787306f
3 changed files with 14 additions and 4 deletions

View File

@ -1,7 +1,7 @@
MIT/X Consortium License MIT/X Consortium License
© 2006-2013 Anselm R Garbe <anselm@garbe.us>
© 2010-2012 Connor Lane Smith <cls@lubutu.com> © 2010-2012 Connor Lane Smith <cls@lubutu.com>
© 2006-2012 Anselm R Garbe <anselm@garbe.us>
© 2009 Gottox <gottox@s01.de> © 2009 Gottox <gottox@s01.de>
© 2009 Markus Schnalke <meillo@marmaro.de> © 2009 Markus Schnalke <meillo@marmaro.de>
© 2009 Evan Gates <evan.gates@gmail.com> © 2009 Evan Gates <evan.gates@gmail.com>

View File

@ -7,6 +7,8 @@ dmenu \- dynamic menu
.RB [ \-f ] .RB [ \-f ]
.RB [ \-i ] .RB [ \-i ]
.RB [ \-l .RB [ \-l
.RB [ \-m
.IR monitor ]
.IR lines ] .IR lines ]
.RB [ \-p .RB [ \-p
.IR prompt ] .IR prompt ]
@ -49,6 +51,9 @@ dmenu matches menu items case insensitively.
.BI \-l " lines" .BI \-l " lines"
dmenu lists items vertically, with the given number of lines. dmenu lists items vertically, with the given number of lines.
.TP .TP
.BI \-m " monitor"
dmenu is displayed on the monitor supplied.
.TP
.BI \-p " prompt" .BI \-p " prompt"
defines the prompt to be displayed to the left of the input field. defines the prompt to be displayed to the left of the input field.
.TP .TP

11
dmenu.c
View File

@ -54,6 +54,7 @@ static Item *matches, *matchend;
static Item *prev, *curr, *next, *sel; static Item *prev, *curr, *next, *sel;
static Window win; static Window win;
static XIC xic; static XIC xic;
static int mon = -1;
#include "config.h" #include "config.h"
@ -84,6 +85,8 @@ main(int argc, char *argv[]) {
/* these options take one argument */ /* these options take one argument */
else if(!strcmp(argv[i], "-l")) /* number of lines in vertical list */ else if(!strcmp(argv[i], "-l")) /* number of lines in vertical list */
lines = atoi(argv[++i]); 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 */ else if(!strcmp(argv[i], "-p")) /* adds prompt to left of input field */
prompt = argv[++i]; prompt = argv[++i];
else if(!strcmp(argv[i], "-fn")) /* font or font set */ else if(!strcmp(argv[i], "-fn")) /* font or font set */
@ -557,7 +560,9 @@ setup(void) {
XWindowAttributes wa; XWindowAttributes wa;
XGetInputFocus(dc->dpy, &w, &di); 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 */ /* find top-level window containing current input focus */
do { do {
if(XQueryTree(dc->dpy, (pw = w), &dw, &w, &dws, &du) && dws) 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 */ /* 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++) for(i = 0; i < n; i++)
if(INTERSECT(x, y, 1, 1, info[i])) if(INTERSECT(x, y, 1, 1, info[i]))
break; break;
@ -614,7 +619,7 @@ setup(void) {
void void
usage(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); " [-nb color] [-nf color] [-sb color] [-sf color] [-v]\n", stderr);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }