My dmenu build
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

95 lines
3.2 KiB

  1. From 87f92a561c31246f6f9effc0e89ef92677c87746 Mon Sep 17 00:00:00 2001
  2. From: astier <aleksandrs.stier@uni-bielefeld.de>
  3. Date: Wed, 27 Feb 2019 21:44:55 +0100
  4. Subject: [PATCH] Add an option which defines the lineheight
  5. Despite both the panel and dmenu using the same font (a Terminus 12),
  6. dmenu is shorter and the panel is visible from under the dmenu bar.
  7. The appearance can be even more distracting when using similar colors
  8. for background and selections. With the option added by this patch,
  9. dmenu can be launched with a '-h 24', thus completely covering the panel.
  10. ---
  11. config.def.h | 1 +
  12. dmenu.1 | 3 +++
  13. dmenu.c | 10 ++++++++--
  14. 3 files changed, 12 insertions(+), 2 deletions(-)
  15. diff --git a/config.def.h b/config.def.h
  16. index 1edb647..317fa2f 100644
  17. --- a/config.def.h
  18. +++ b/config.def.h
  19. @@ -15,6 +15,7 @@ static const char *colors[SchemeLast][2] = {
  20. };
  21. /* -l option; if nonzero, dmenu uses vertical list with given number of lines */
  22. static unsigned int lines = 0;
  23. +static unsigned int lineheight = 0; /* -h option; minimum height of a menu line */
  24. /*
  25. * Characters not considered part of a word while deleting words
  26. diff --git a/dmenu.1 b/dmenu.1
  27. index 323f93c..7ef34d2 100644
  28. --- a/dmenu.1
  29. +++ b/dmenu.1
  30. @@ -50,6 +50,9 @@ dmenu matches menu items case insensitively.
  31. .BI \-l " lines"
  32. dmenu lists items vertically, with the given number of lines.
  33. .TP
  34. +.BI \-h " height"
  35. +dmenu uses a menu line of at least 'height' pixels tall, but no less than 8.
  36. +.TP
  37. .BI \-m " monitor"
  38. dmenu is displayed on the monitor number supplied. Monitor numbers are starting
  39. from 0.
  40. diff --git a/dmenu.c b/dmenu.c
  41. index 6b8f51b..45d1946 100644
  42. --- a/dmenu.c
  43. +++ b/dmenu.c
  44. @@ -131,7 +131,7 @@ drawmenu(void)
  45. {
  46. unsigned int curpos;
  47. struct item *item;
  48. - int x = 0, y = 0, w;
  49. + int x = 0, y = 0, fh = drw->fonts->h, w;
  50. drw_setscheme(drw, scheme[SchemeNorm]);
  51. drw_rect(drw, 0, 0, mw, mh, 1, 1);
  52. @@ -148,7 +148,7 @@ drawmenu(void)
  53. curpos = TEXTW(text) - TEXTW(&text[cursor]);
  54. if ((curpos += lrpad / 2 - 1) < w) {
  55. drw_setscheme(drw, scheme[SchemeNorm]);
  56. - drw_rect(drw, x + curpos, 2, 2, bh - 4, 1, 0);
  57. + drw_rect(drw, x + curpos, 2 + (bh-fh)/2, 2, fh - 4, 1, 0);
  58. }
  59. if (lines > 0) {
  60. @@ -604,6 +604,7 @@ setup(void)
  61. /* calculate menu geometry */
  62. bh = drw->fonts->h + 2;
  63. + bh = MAX(bh,lineheight); /* make a menu line AT LEAST 'lineheight' tall */
  64. lines = MAX(lines, 0);
  65. mh = (lines + 1) * bh;
  66. #ifdef XINERAMA
  67. @@ -683,6 +684,7 @@ static void
  68. usage(void)
  69. {
  70. fputs("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
  71. + " [-h height]\n"
  72. " [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]\n", stderr);
  73. exit(1);
  74. }
  75. @@ -716,6 +718,10 @@ main(int argc, char *argv[])
  76. prompt = argv[++i];
  77. else if (!strcmp(argv[i], "-fn")) /* font or font set */
  78. fonts[0] = argv[++i];
  79. + else if(!strcmp(argv[i], "-h")) { /* minimum height of one menu line */
  80. + lineheight = atoi(argv[++i]);
  81. + lineheight = MAX(lineheight,8); /* reasonable default in case of value too small/negative */
  82. + }
  83. else if (!strcmp(argv[i], "-nb")) /* normal background color */
  84. colors[SchemeNorm][ColBg] = argv[++i];
  85. else if (!strcmp(argv[i], "-nf")) /* normal foreground color */
  86. --
  87. 2.21.0