| dmenu-xyw-20160903-026827f.diff - sites - public wiki contents of suckless.org | |
| git clone git://git.suckless.org/sites | |
| Log | |
| Files | |
| Refs | |
| --- | |
| dmenu-xyw-20160903-026827f.diff (2946B) | |
| --- | |
| 1 diff --git a/dmenu.1 b/dmenu.1 | |
| 2 index d3ab805..5301910 100644 | |
| 3 --- a/dmenu.1 | |
| 4 +++ b/dmenu.1 | |
| 5 @@ -51,6 +51,24 @@ dmenu matches menu items case insensitively. | |
| 6 .BI \-l " lines" | |
| 7 dmenu lists items vertically, with the given number of lines. | |
| 8 .TP | |
| 9 +.BI \-x " xoffset" | |
| 10 +dmenu is placed at this offset measured from the left side of the monit… | |
| 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. I… | |
| 18 +.B \-b | |
| 19 +option is used, the offset is measured from the bottom. Can be negativ… | |
| 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 … | |
| 29 from 0. | |
| 30 diff --git a/dmenu.c b/dmenu.c | |
| 31 index 3b05752..add4364 100644 | |
| 32 --- a/dmenu.c | |
| 33 +++ b/dmenu.c | |
| 34 @@ -36,6 +36,9 @@ struct item { | |
| 35 static char text[BUFSIZ] = ""; | |
| 36 static int bh, mw, mh; | |
| 37 static int sw, sh; /* X display screen geometry width, height */ | |
| 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 bo… | |
| 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 @@ -563,16 +566,16 @@ 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… | |
| 53 + mw = (dmw>0 ? dmw : info[i].width); | |
| 54 XFree(info); | |
| 55 } else | |
| 56 #endif | |
| 57 { | |
| 58 - x = 0; | |
| 59 - y = topbar ? 0 : sh - mh; | |
| 60 - mw = sw; | |
| 61 + x = dmx; | |
| 62 + y = topbar ? dmy : sh - mh - dmy; | |
| 63 + mw = (dmw>0 ? dmw : sw); | |
| 64 } | |
| 65 promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0; | |
| 66 inputw = MIN(inputw, mw/3); | |
| 67 @@ -601,6 +604,7 @@ static void | |
| 68 usage(void) | |
| 69 { | |
| 70 fputs("usage: dmenu [-b] [-f] [-i] [-l lines] [-p prompt] [-fn … | |
| 71 + " [-x xoffset] [-y yoffset] [-w width]\n" | |
| 72 " [-nb color] [-nf color] [-sb color] [-sf co… | |
| 73 exit(1); | |
| 74 } | |
| 75 @@ -627,6 +631,12 @@ main(int argc, char *argv[]) | |
| 76 /* these options take one argument */ | |
| 77 else if (!strcmp(argv[i], "-l")) /* number of lines i… | |
| 78 lines = atoi(argv[++i]); | |
| 79 + else if (!strcmp(argv[i], "-x")) /* window x offset */ | |
| 80 + dmx = atoi(argv[++i]); | |
| 81 + else if (!strcmp(argv[i], "-y")) /* window y offset (… | |
| 82 + dmy = atoi(argv[++i]); | |
| 83 + else if (!strcmp(argv[i], "-w")) /* make dmenu this w… | |
| 84 + dmw = atoi(argv[++i]); | |
| 85 else if (!strcmp(argv[i], "-m")) | |
| 86 mon = atoi(argv[++i]); | |
| 87 else if (!strcmp(argv[i], "-p")) /* adds prompt to le… |