From 3438af001adcb1d8ff840f89ae7cb5ef8589bde6 Mon Sep 17 00:00:00 2001 From: arg@mig29 Date: Mon, 18 Dec 2006 12:52:58 +0100 Subject: applied Stefan Tibus' sun patch, added -bottom option to dmenu which makes it appear in the bottom (for wmii compliance), slightly modified version than the patch proposed by Stefan Tibus --- main.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 1c6e57f..7fca45e 100644 --- a/main.c +++ b/main.c @@ -330,6 +330,7 @@ DC dc = {0}; int main(int argc, char *argv[]) { + Bool bottom = False; char *font = FONT; char *maxname; char *normbg = NORMBGCOLOR; @@ -347,7 +348,10 @@ main(int argc, char *argv[]) { timeout.tv_sec = 3; /* command line args */ for(i = 1; i < argc; i++) - if(!strncmp(argv[i], "-font", 6)) { + if(!strncmp(argv[i], "-bottom", 8)) { + bottom = True; + } + else if(!strncmp(argv[i], "-font", 6)) { if(++i < argc) font = argv[i]; } else if(!strncmp(argv[i], "-normbg", 8)) { @@ -373,7 +377,8 @@ main(int argc, char *argv[]) { exit(EXIT_SUCCESS); } else - eprint("usage: dmenu [-font ] [-{norm,sel}{bg,fg} ] [-p ] [-t ] [-v]\n", stdout); + eprint("usage: dmenu [-bottom] [-font ] [-{norm,sel}{bg,fg} ]\n" + " [-p ] [-t ] [-v]\n", stdout); setlocale(LC_CTYPE, ""); dpy = XOpenDisplay(0); if(!dpy) @@ -406,7 +411,12 @@ main(int argc, char *argv[]) { wa.event_mask = ExposureMask | ButtonPressMask | KeyPressMask; mx = my = 0; mw = DisplayWidth(dpy, screen); - mh = dc.font.height + 2; + if(bottom) { + mh = dc.font.ascent + dc.font.descent + 3; // match wmii + my = DisplayHeight(dpy, screen) - mh; + } + else + mh = dc.font.height + 2; win = XCreateWindow(dpy, root, mx, my, mw, mh, 0, DefaultDepth(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen), -- cgit v1.2.3