Another copy of my dotfiles. Because I don't completely trust GitHub.
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.

106 lines
3.4 KiB

  1. From ba103e38ea4ab07f9a3ee90627714b9bea17c329 Mon Sep 17 00:00:00 2001
  2. From: pskry <peter@skrypalle.dk>
  3. Date: Sun, 8 Nov 2020 22:04:22 +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 | 3 +++
  12. dmenu.1 | 5 +++++
  13. dmenu.c | 11 ++++++++---
  14. 3 files changed, 16 insertions(+), 3 deletions(-)
  15. diff --git a/config.def.h b/config.def.h
  16. index 1edb647..4394dec 100644
  17. --- a/config.def.h
  18. +++ b/config.def.h
  19. @@ -15,6 +15,9 @@ 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. +/* -h option; minimum height of a menu line */
  24. +static unsigned int lineheight = 0;
  25. +static unsigned int min_lineheight = 8;
  26. /*
  27. * Characters not considered part of a word while deleting words
  28. diff --git a/dmenu.1 b/dmenu.1
  29. index 323f93c..f2a82b4 100644
  30. --- a/dmenu.1
  31. +++ b/dmenu.1
  32. @@ -6,6 +6,8 @@ dmenu \- dynamic menu
  33. .RB [ \-bfiv ]
  34. .RB [ \-l
  35. .IR lines ]
  36. +.RB [ \-h
  37. +.IR height ]
  38. .RB [ \-m
  39. .IR monitor ]
  40. .RB [ \-p
  41. @@ -50,6 +52,9 @@ dmenu matches menu items case insensitively.
  42. .BI \-l " lines"
  43. dmenu lists items vertically, with the given number of lines.
  44. .TP
  45. +.BI \-h " height"
  46. +dmenu uses a menu line of at least 'height' pixels tall, but no less than 8.
  47. +.TP
  48. .BI \-m " monitor"
  49. dmenu is displayed on the monitor number supplied. Monitor numbers are starting
  50. from 0.
  51. diff --git a/dmenu.c b/dmenu.c
  52. index 65f25ce..f2a4047 100644
  53. --- a/dmenu.c
  54. +++ b/dmenu.c
  55. @@ -131,7 +131,7 @@ drawmenu(void)
  56. {
  57. unsigned int curpos;
  58. struct item *item;
  59. - int x = 0, y = 0, w;
  60. + int x = 0, y = 0, fh = drw->fonts->h, w;
  61. drw_setscheme(drw, scheme[SchemeNorm]);
  62. drw_rect(drw, 0, 0, mw, mh, 1, 1);
  63. @@ -148,7 +148,7 @@ drawmenu(void)
  64. curpos = TEXTW(text) - TEXTW(&text[cursor]);
  65. if ((curpos += lrpad / 2 - 1) < w) {
  66. drw_setscheme(drw, scheme[SchemeNorm]);
  67. - drw_rect(drw, x + curpos, 2, 2, bh - 4, 1, 0);
  68. + drw_rect(drw, x + curpos, 2 + (bh - fh) / 2, 2, fh - 4, 1, 0);
  69. }
  70. if (lines > 0) {
  71. @@ -609,6 +609,7 @@ setup(void)
  72. /* calculate menu geometry */
  73. bh = drw->fonts->h + 2;
  74. + bh = MAX(bh,lineheight); /* make a menu line AT LEAST 'lineheight' tall */
  75. lines = MAX(lines, 0);
  76. mh = (lines + 1) * bh;
  77. #ifdef XINERAMA
  78. @@ -689,7 +690,7 @@ setup(void)
  79. static void
  80. usage(void)
  81. {
  82. - fputs("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
  83. + fputs("usage: dmenu [-bfiv] [-l lines] [-h height] [-p prompt] [-fn font] [-m monitor]\n"
  84. " [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]\n", stderr);
  85. exit(1);
  86. }
  87. @@ -717,6 +718,10 @@ main(int argc, char *argv[])
  88. /* these options take one argument */
  89. else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */
  90. lines = atoi(argv[++i]);
  91. + else if (!strcmp(argv[i], "-h")) { /* minimum height of one menu line */
  92. + lineheight = atoi(argv[++i]);
  93. + lineheight = MAX(lineheight, min_lineheight);
  94. + }
  95. else if (!strcmp(argv[i], "-m"))
  96. mon = atoi(argv[++i]);
  97. else if (!strcmp(argv[i], "-p")) /* adds prompt to left of input field */
  98. --
  99. 2.29.2