Return to repo list

suckless-gf-dmenu

Gentoo-friendly patches for Suckless's dmenu.
Return to HMagellan.com

commit 1719ef85f72dcc8c1fe8b830c54f19030cb9a827
parent 0ae8b7b9bc2d6d4b65fdc8aebc59b418ad64991a
Author: Erik Letson <hmagellan@hmagellan.com>
Date:   Fri, 21 Aug 2020 13:50:34 -0500

Added lineheight

Diffstat:
MREADME | 2+-
Apatches/lineheight/USAGE | 43+++++++++++++++++++++++++++++++++++++++++++
Apatches/lineheight/lineheight-nodoc.patch | 44++++++++++++++++++++++++++++++++++++++++++++
Apatches/lineheight/lineheight.patch | 66++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 154 insertions(+), 1 deletion(-)

diff --git a/README b/README @@ -42,7 +42,7 @@ patches! (1). https://tools.suckless.org/dmenu/patches/ - CURRENT PROGRESS: 9/32 patches supported + CURRENT PROGRESS: 10/32 patches supported 3/32 patches unsupported USUPPORTED PATCHES: diff --git a/patches/lineheight/USAGE b/patches/lineheight/USAGE @@ -0,0 +1,43 @@ +lineheight - Set dmenu line height with -h option +Source: https://tools.suckless.org/dmenu/patches/line-height/dmenu-lineheight-4.9.diff +Original Authors: Xarchus + Jonathon Fernyhough (jonathon at manjaro-dot-org) (4.7 rewrite) + Aleksandrs Stier (4.9 port) + +Description from source: + """ + The patch adds a '-h' option, which sets the minimum height of a dmenu line. This helps integrate dmenu with other + UI elements that require a particular vertical size. + + Example: + + By default, dmenu calculates its height as the height of the font used plus 2. So when opening dmenu over a panel + bar that is 24 pixels high, it would look like this: + + Screenshot dmenu default height + + Despite both the panel and dmenu using the same font (a Terminus 12), dmenu is shorter and the panel is visible from + under the dmenu bar. The appearance can be even more distracting when using similar colors for background and selections. + + With the option added by this patch, dmenu can be launched with a '-h 24', thus completely covering the panel, as shown + below: + + Screenshot dmenu with line height patch + + The line height value is also used when dmenu is used in 'vertical' mode ('-l' option). + """ + +== YOU MUST == +(1). Place the patch file in /etc/portage/patches/x11-misc/dmenu/ and run 'emerge dmenu' + +== YOU PROBABLY SHOULD == +No further action is required. + +== PATCH MODIFICATIONS == +(1). Removed all changes made to 'config.def.h' +(2). Added a 'nodoc' patch version which strips out added documentation + +== INCOMPATIBILITIES == +THIS PATCH MAKES CHANGES TO DMENU'S BUILT-IN DOCUMENTATION, WHICH CAN CAUSE CONFLICTS WITH OTHER PATCHES! +If you encounter such conflicts, try emerging with the 'lineheight-nodoc.patch' file instead. It is the +same as the 'lineheight.patch' file except it makes no changes to the documentation. diff --git a/patches/lineheight/lineheight-nodoc.patch b/patches/lineheight/lineheight-nodoc.patch @@ -0,0 +1,44 @@ +diff --git a/dmenu.c b/dmenu.c +index 6b8f51b..45d1946 100644 +--- a/dmenu.c ++++ b/dmenu.c +@@ -131,7 +131,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); +@@ -148,7 +148,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) { +@@ -604,6 +604,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 +@@ -716,6 +718,10 @@ main(int argc, char *argv[]) + prompt = argv[++i]; + else if (!strcmp(argv[i], "-fn")) /* font or font set */ + fonts[0] = argv[++i]; ++ else if(!strcmp(argv[i], "-h")) { /* minimum height of one menu line */ ++ lineheight = atoi(argv[++i]); ++ lineheight = MAX(lineheight,8); /* reasonable default in case of value too small/negative */ ++ } + else if (!strcmp(argv[i], "-nb")) /* normal background color */ + colors[SchemeNorm][ColBg] = argv[++i]; + else if (!strcmp(argv[i], "-nf")) /* normal foreground color */ +-- +2.21.0 + diff --git a/patches/lineheight/lineheight.patch b/patches/lineheight/lineheight.patch @@ -0,0 +1,66 @@ +diff --git a/dmenu.1 b/dmenu.1 +index 323f93c..7ef34d2 100644 +--- a/dmenu.1 ++++ b/dmenu.1 +@@ -50,6 +50,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 6b8f51b..45d1946 100644 +--- a/dmenu.c ++++ b/dmenu.c +@@ -131,7 +131,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); +@@ -148,7 +148,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) { +@@ -604,6 +604,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 +@@ -683,6 +684,7 @@ static void + usage(void) + { + fputs("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n" ++ " [-h height]\n" + " [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]\n", stderr); + exit(1); + } +@@ -716,6 +718,10 @@ main(int argc, char *argv[]) + prompt = argv[++i]; + else if (!strcmp(argv[i], "-fn")) /* font or font set */ + fonts[0] = argv[++i]; ++ else if(!strcmp(argv[i], "-h")) { /* minimum height of one menu line */ ++ lineheight = atoi(argv[++i]); ++ lineheight = MAX(lineheight,8); /* reasonable default in case of value too small/negative */ ++ } + else if (!strcmp(argv[i], "-nb")) /* normal background color */ + colors[SchemeNorm][ColBg] = argv[++i]; + else if (!strcmp(argv[i], "-nf")) /* normal foreground color */ +-- +2.21.0 +