aboutsummaryrefslogtreecommitdiff
path: root/dmenu.c
diff options
context:
space:
mode:
Diffstat (limited to 'dmenu.c')
-rw-r--r--dmenu.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/dmenu.c b/dmenu.c
index 67ccc27..b0e3492 100644
--- a/dmenu.c
+++ b/dmenu.c
@@ -38,6 +38,9 @@ struct item {
static char text[BUFSIZ] = "";
static char *embed;
static int bh, mw, mh;
+static int dmx = 0; /* put dmenu at this x offset */
+static int dmy = 0; /* put dmenu at this y offset (measured from the bottom if topbar is 0) */
+static unsigned int dmw = 0; /* make dmenu this wide */
static int inputw = 0, promptw;
static int lrpad; /* sum of left and right padding */
static size_t cursor;
@@ -101,6 +104,7 @@ calcoffsets(void)
break;
}
+/*
static int
max_textw(void)
{
@@ -109,6 +113,8 @@ max_textw(void)
len = MAX(item->width, len);
return len;
}
+*/
+
static void
cleanup(void)
@@ -827,16 +833,17 @@ setup(void)
break;
if (centered) {
- mw = MIN(MAX(max_textw() + promptw, min_width), info[i].width);
+ /* mw = MIN(MAX(max_textw() + promptw, min_width), info[i].width); */
+ mw = MAX((dmw>0 ? dmw : info[i].width), min_width);
x = info[i].x_org + ((info[i].width - mw) / 2);
y = info[i].y_org + ((info[i].height - mh) / menu_height_ratio);
} else {
- x = info[i].x_org;
- y = info[i].y_org + (topbar ? 0 : info[i].height - mh);
- mw = info[i].width;
+ x = info[i].x_org + dmx;
+ y = info[i].y_org + (topbar ? dmy : info[i].height - mh - dmy);
+ mw = (dmw>0 ? dmw : info[i].width);
}
-
XFree(info);
+
} else
#endif
{
@@ -845,13 +852,14 @@ setup(void)
parentwin);
if (centered) {
- mw = MIN(MAX(max_textw() + promptw, min_width), wa.width);
+ /* mw = MIN(MAX(max_textw() + promptw, min_width), wa.width); */
+ mw = MAX((dmw>0 ? dmw : wa.width), min_width);
x = (wa.width - mw) / 2;
y = (wa.height - mh) / 2;
} else {
- x = 0;
- y = topbar ? 0 : wa.height - mh;
- mw = wa.width;
+ x = dmx;
+ y = topbar ? dmy : wa.height - mh - dmy;
+ mw = (dmw>0 ? dmw : wa.width);
}
}
promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
@@ -897,6 +905,7 @@ static void
usage(void)
{
die("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
+ " [-x xoffset] [-y yoffset] [-z width]\n"
" [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]");
}
@@ -960,6 +969,12 @@ 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], "-x")) /* window x offset */
+ dmx = atoi(argv[++i]);
+ else if (!strcmp(argv[i], "-y")) /* window y offset (from bottom up if -b) */
+ dmy = atoi(argv[++i]);
+ else if (!strcmp(argv[i], "-z")) /* make dmenu this wide */
+ dmw = 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 */