rewrite line height feature, now works more like dwm bar height patch

This commit is contained in:
speedie 2023-02-09 18:12:03 +01:00
parent fdda27ed06
commit fe7de921bb
4 changed files with 13 additions and 11 deletions

View file

@ -40,10 +40,9 @@ spmenu.alpha: 1
spmenu.accuratewidth: 1 spmenu.accuratewidth: 1
spmenu.bordercentered: 1 spmenu.bordercentered: 1
spmenu.borderwidth: 2 spmenu.borderwidth: 2
spmenu.lineheight: 0
spmenu.lines: 0 spmenu.lines: 0
spmenu.columns: 10 spmenu.columns: 10
spmenu.lineheight: 5
spmenu.minlineheight: 5
spmenu.maxhist: 64 spmenu.maxhist: 64
spmenu.histnodup: 1 spmenu.histnodup: 1
spmenu.casesensitive: 0 spmenu.casesensitive: 0

View file

@ -36,10 +36,9 @@ static int accuratewidth = 1; /* Enable accurate width. May have a
static int fuzzy = 1; /* Whether or not to enable fuzzy matching by default */ static int fuzzy = 1; /* Whether or not to enable fuzzy matching by default */
/* Line options */ /* Line options */
static int lineheight = 0; /* Line height (0: Calculate automatically) */
static int lines = 0; /* Default number of lines */ static int lines = 0; /* Default number of lines */
static int columns = 10; /* Default number of columns */ static int columns = 10; /* Default number of columns */
static int lineheight = 20; /* Height of each line */
static int minlineheight = 5; /* Minimum line height */
/* History options */ /* History options */
static unsigned int maxhist = 64; /* Max number of history entries */ static unsigned int maxhist = 64; /* Max number of history entries */

View file

@ -98,6 +98,8 @@ static char numbers[NUMBERSBUFSIZE] = "";
static char *embed; static char *embed;
static int numlockmask = 0; static int numlockmask = 0;
static int bh, mw, mh; static int bh, mw, mh;
static int reqlineheight; /* required menu height */
static int clineheight; /* menu height added through argument */
static int dmx = 0; /* put spmenu at this x offset */ static int dmx = 0; /* put spmenu at this x offset */
static int dmy = 0; /* put spmenu at this y offset (measured from the bottom if menuposition is 0) */ static int dmy = 0; /* put spmenu at this y offset (measured from the bottom if menuposition is 0) */
static unsigned int dmw = 0; /* make spmenu this wide */ static unsigned int dmw = 0; /* make spmenu this wide */
@ -1574,9 +1576,13 @@ setup(void)
types = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False); types = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False);
dock = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DOCK", False); dock = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DOCK", False);
if (!clineheight)
reqlineheight += lineheight;
else
reqlineheight = clineheight;
/* calculate menu geometry */ /* calculate menu geometry */
bh = drw->font->h + 2; bh = drw->font->h + 2 + reqlineheight;
bh = MAX(bh, lineheight); /* make a menu line AT LEAST 'lineheight' tall */
lines = MAX(lines, 0); lines = MAX(lines, 0);
mh = (lines + 1) * bh; mh = (lines + 1) * bh;
promptw = (prompt && *prompt) ? TEXTWM(prompt) - lrpad / 4 : 0; promptw = (prompt && *prompt) ? TEXTWM(prompt) - lrpad / 4 : 0;
@ -1710,7 +1716,7 @@ usage(void)
fputs("spmenu: dynamic menu\n\n" fputs("spmenu: dynamic menu\n\n"
"- Arguments -\n" "- Arguments -\n"
"spmenu -l <line> Set line count to stdin\n" "spmenu -l <line> Set line count to stdin\n"
"spmenu -h <height> Set spmenu height to <height>\n" "spmenu -h <height> Set spmenu line height to <height>\n"
"spmenu -g <grid> Set the number of grids to <grid>\n" "spmenu -g <grid> Set the number of grids to <grid>\n"
"spmenu -rw Enable relative input width\n" "spmenu -rw Enable relative input width\n"
"spmenu -nrw Disable relative input width\n" "spmenu -nrw Disable relative input width\n"
@ -1890,8 +1896,7 @@ main(int argc, char *argv[])
} else if (!strcmp(argv[i], "-l")) { /* number of lines in grid */ } else if (!strcmp(argv[i], "-l")) { /* number of lines in grid */
lines = atoi(argv[++i]); lines = atoi(argv[++i]);
} else if (!strcmp(argv[i], "-h")) { /* minimum height of one menu line */ } else if (!strcmp(argv[i], "-h")) { /* minimum height of one menu line */
lineheight = atoi(argv[++i]); clineheight += atoi(argv[++i]);
lineheight = MAX(lineheight, minlineheight);
if (columns == 0) columns = 1; if (columns == 0) columns = 1;
} else if (!strcmp(argv[i], "-lp")) { } else if (!strcmp(argv[i], "-lp")) {
menupaddingv = atoi(argv[++i]); menupaddingv = atoi(argv[++i]);

View file

@ -101,9 +101,8 @@ ResourcePref resources[] = {
{ "bordercentered", INTEGER, &bordercentered }, { "bordercentered", INTEGER, &bordercentered },
{ "borderwidth", INTEGER, &borderwidth }, { "borderwidth", INTEGER, &borderwidth },
{ "lines", INTEGER, &lines }, { "lines", INTEGER, &lines },
{ "lineheight", INTEGER, &lineheight },
{ "columns", INTEGER, &columns }, { "columns", INTEGER, &columns },
{ "lineheight", INTEGER, &lineheight },
{ "minlineheight", INTEGER, &minlineheight },
{ "maxhist", INTEGER, &maxhist }, { "maxhist", INTEGER, &maxhist },
{ "hidematchcount", INTEGER, &hidematchcount }, { "hidematchcount", INTEGER, &hidematchcount },
{ "histnodup", INTEGER, &histnodup }, { "histnodup", INTEGER, &histnodup },