From 2bee467b7dc416bc4adacf1c6b1ff211006e10df Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Mon, 1 Sep 2025 15:00:29 -0400 Subject: [PATCH] Applied lineheight patch Patch-Source: https://tools.suckless.org/dmenu/patches/line-height/dmenu-lineheight-5.2.diff --- config.def.h | 3 +++ dmenu.1 | 5 +++++ dmenu.c | 11 ++++++++--- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/config.def.h b/config.def.h index 4d66415..d71c6a9 100644 --- a/config.def.h +++ b/config.def.h @@ -16,6 +16,9 @@ static const char *colors[SchemeLast][2] = { }; /* -l option; if nonzero, dmenu uses vertical list with given number of lines */ static unsigned int lines = 0; +/* -h option; minimum height of a menu line */ +static unsigned int lineheight = 0; +static unsigned int min_lineheight = 8; /* * Characters not considered part of a word while deleting words diff --git a/dmenu.1 b/dmenu.1 index e2c5ef4..68d1719 100644 --- a/dmenu.1 +++ b/dmenu.1 @@ -6,6 +6,8 @@ dmenu \- dynamic menu .RB [ \-bFfiv ] .RB [ \-l .IR lines ] +.RB [ \-h +.IR height ] .RB [ \-m .IR monitor ] .RB [ \-p @@ -53,6 +55,9 @@ dmenu matches menu items case insensitively. .BI \-l " lines" dmenu lists items vertically, with the given number of lines. .TP +.BI \-h " height" +dmenu uses a menu line of at least 'height' pixels tall, but no less than 8. +.TP .BI \-m " monitor" dmenu is displayed on the monitor number supplied. Monitor numbers are starting from 0. diff --git a/dmenu.c b/dmenu.c index ee363e8..ddbee57 100644 --- a/dmenu.c +++ b/dmenu.c @@ -149,7 +149,7 @@ drawmenu(void) { unsigned int curpos; struct item *item; - int x = 0, y = 0, w; + int x = 0, y = 0, fh = drw->fonts->h, w; drw_setscheme(drw, scheme[SchemeNorm]); drw_rect(drw, 0, 0, mw, mh, 1, 1); @@ -166,7 +166,7 @@ drawmenu(void) curpos = TEXTW(text) - TEXTW(&text[cursor]); if ((curpos += lrpad / 2 - 1) < w) { drw_setscheme(drw, scheme[SchemeNorm]); - drw_rect(drw, x + curpos, 2, 2, bh - 4, 1, 0); + drw_rect(drw, x + curpos, 2 + (bh - fh) / 2, 2, fh - 4, 1, 0); } if (lines > 0) { @@ -720,6 +720,7 @@ setup(void) /* calculate menu geometry */ bh = drw->fonts->h + 2; + bh = MAX(bh,lineheight); /* make a menu line AT LEAST 'lineheight' tall */ lines = MAX(lines, 0); mh = (lines + 1) * bh; #ifdef XINERAMA @@ -802,7 +803,7 @@ setup(void) static void usage(void) { - die("usage: dmenu [-bFfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n" + die("usage: dmenu [-bFfiv] [-l lines] [-h height] [-p prompt] [-fn font] [-m monitor]\n" " [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]"); } @@ -831,6 +832,10 @@ 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], "-h")) { /* minimum height of one menu line */ + lineheight = atoi(argv[++i]); + lineheight = MAX(lineheight, min_lineheight); + } else if (!strcmp(argv[i], "-m")) mon = atoi(argv[++i]); else if (!strcmp(argv[i], "-p")) /* adds prompt to left of input field */