dmenu-xyw-4.7.diff (3113B)
1 diff --git a/dmenu.1 b/dmenu.1 2 index d3ab805..5301910 100644 3 --- a/dmenu.1 4 +++ b/dmenu.1 5 @@ -53,6 +53,24 @@ dmenu matches menu items case insensitively. 6 .BI \-h " height" 7 dmenu uses a menu line of at least 'height' pixels tall, but no less than 8. 8 .TP 9 +.BI \-x " xoffset" 10 +dmenu is placed at this offset measured from the left side of the monitor. 11 +Can be negative. 12 +If option 13 +.B \-m 14 +is present, the measurement will use the given monitor. 15 +.TP 16 +.BI \-y " yoffset" 17 +dmenu is placed at this offset measured from the top of the monitor. If the 18 +.B \-b 19 +option is used, the offset is measured from the bottom. Can be negative. 20 +If option 21 +.B \-m 22 +is present, the measurement will use the given monitor. 23 +.TP 24 +.BI \-w " width" 25 +sets the width of the dmenu window. 26 +.TP 27 .BI \-m " monitor" 28 dmenu is displayed on the monitor number supplied. Monitor numbers are starting 29 from 0. 30 diff --git a/dmenu.c b/dmenu.c 31 index a07f8e3..9e0c51c 100644 32 --- a/dmenu.c 33 +++ b/dmenu.c 34 @@ -36,6 +36,9 @@ struct item { 35 static char text[BUFSIZ] = ""; 36 static char *embed; 37 static int bh, mw, mh; 38 +static int dmx = 0; /* put dmenu at this x offset */ 39 +static int dmy = 0; /* put dmenu at this y offset (measured from the bottom if topbar is 0) */ 40 +static unsigned int dmw = 0; /* make dmenu this wide */ 41 static int inputw = 0, promptw; 42 static int lrpad; /* sum of left and right padding */ 43 static size_t cursor; 44 @@ -705,19 +708,19 @@ setup(void) 45 if (INTERSECT(x, y, 1, 1, info[i])) 46 break; 47 48 - x = info[i].x_org; 49 - y = info[i].y_org + (topbar ? 0 : info[i].height - mh); 50 - mw = info[i].width; 51 + x = info[i].x_org + dmx; 52 + y = info[i].y_org + (topbar ? dmy : info[i].height - mh - dmy); 53 + mw = (dmw>0 ? dmw : info[i].width); 54 XFree(info); 55 } else 56 #endif 57 { 58 if (!XGetWindowAttributes(dpy, parentwin, &wa)) 59 die("could not get embedding window attributes: 0x%lx", 60 parentwin); 61 - x = 0; 62 - y = topbar ? 0 : wa.height - mh; 63 - mw = wa.width; 64 + x = dmx; 65 + y = topbar ? dmy : wa.height - mh - dmy; 66 + mw = (dmw>0 ? dmw : wa.width); 67 } 68 promptw = (prompt && *prompt) ? TEXTW(prompt) : 0; 69 inputw = MIN(inputw, mw/3); 70 @@ -755,7 +758,7 @@ static void 71 usage(void) 72 { 73 fputs("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n" 74 - " [-h height]\n" 75 + " [-h height] [-x xoffset] [-y yoffset] [-w width]\n" 76 " [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]\n", stderr); 77 exit(1); 78 } 79 @@ -783,6 +786,12 @@ main(int argc, char *argv[]) 80 /* these options take one argument */ 81 else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */ 82 lines = atoi(argv[++i]); 83 + else if (!strcmp(argv[i], "-x")) /* window x offset */ 84 + dmx = atoi(argv[++i]); 85 + else if (!strcmp(argv[i], "-y")) /* window y offset (from bottom up if -b) */ 86 + dmy = atoi(argv[++i]); 87 + else if (!strcmp(argv[i], "-w")) /* make dmenu this wide */ 88 + dmw = atoi(argv[++i]); 89 else if (!strcmp(argv[i], "-m")) 90 mon = atoi(argv[++i]); 91 else if (!strcmp(argv[i], "-p")) /* adds prompt to left of input field */