aboutsummaryrefslogtreecommitdiffstats
path: root/dmenu.c
diff options
context:
space:
mode:
Diffstat (limited to 'dmenu.c')
-rw-r--r--dmenu.c40
1 files changed, 33 insertions, 7 deletions
diff --git a/dmenu.c b/dmenu.c
index 071e8c7..643b9b9 100644
--- a/dmenu.c
+++ b/dmenu.c
@@ -39,6 +39,7 @@ enum {
SchemeNormHighlight,
SchemeSelHighlight,
SchemeOut,
+ SchemeMid,
SchemeLast
}; /* color schemes */
@@ -58,6 +59,9 @@ static char separator;
static int separator_greedy;
static int separator_reverse;
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;
@@ -204,6 +208,8 @@ static int drawitem(struct item *item, int x, int y, int w) {
int r;
if (item == sel)
drw_setscheme(drw, scheme[SchemeSel]);
+ else if (item->left == sel || item->right == sel)
+ drw_setscheme(drw, scheme[SchemeMid]);
else if (item->out)
drw_setscheme(drw, scheme[SchemeOut]);
else
@@ -984,7 +990,8 @@ static void setup(void) {
utf8 = XInternAtom(dpy, "UTF8_STRING", False);
/* calculate menu geometry */
- bh = drw->fonts->h + 2;
+ bh = drw->fonts->h;
+ bh = user_bh ? bh + user_bh : bh + 2;
lines = MAX(lines, 0);
mh = (lines + 1) * bh;
#ifdef XINERAMA
@@ -1015,18 +1022,24 @@ static void setup(void) {
if (INTERSECT(x, y, 1, 1, info[i]))
break;
- 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; */
+ /* 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
{
if (!XGetWindowAttributes(dpy, parentwin, &wa))
die("could not get embedding window attributes: 0x%lx", parentwin);
- x = 0;
- y = topbar ? 0 : wa.height - mh;
- mw = wa.width;
+ /* 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;
inputw = MIN(inputw, mw / 3);
@@ -1040,6 +1053,8 @@ static void setup(void) {
win = XCreateWindow(dpy, parentwin, x, y, mw, mh, border_width,
CopyFromParent, CopyFromParent, CopyFromParent,
CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
+ if (border_width)
+ XSetWindowBorder(dpy, win, scheme[SchemeSel][ColBg].pixel);
XSetWindowBorder(dpy, win, scheme[SchemeSel][ColBg].pixel);
XSetClassHint(dpy, win, &ch);
@@ -1066,6 +1081,7 @@ static void setup(void) {
static void usage(void) {
fputs("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]\n"
" [-nhb color] [-nhf color] [-shb color] [-shf color]\n"
" [-d separator] [-D separator] [-dy command] [-w "
@@ -1088,6 +1104,8 @@ int main(int argc, char *argv[]) {
exit(0);
} else if (!strcmp(argv[i], "-b")) /* appears at the bottom of the screen */
topbar = 0;
+ else if (!strcmp(argv[i], "-t")) /* appears at the top of the screen */
+ topbar = 1;
else if (!strcmp(argv[i], "-f")) /* grabs keyboard before reading stdin */
fast = 1;
else if (!strcmp(argv[i], "-F")) /* grabs keyboard before reading stdin */
@@ -1106,6 +1124,12 @@ int main(int argc, char *argv[]) {
lines = atoi(argv[++i]);
if (columns == 0)
columns = 1;
+ }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 */
@@ -1136,6 +1160,8 @@ int main(int argc, char *argv[]) {
embed = argv[++i];
else if (!strcmp(argv[i], "-dy")) /* dynamic command to run */
dynamic = argv[++i] && *argv[i] ? argv[i] : NULL;
+ else if (!strcmp(argv[i], "-bw"))
+ border_width = atoi(argv[++i]); /* border width */
else
usage();