summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstkhan <personal@slickd.xyz>2025-07-23 21:35:48 -0500
committerstkhan <personal@slickd.xyz>2025-07-23 21:35:48 -0500
commit7bf6f5dabe3b0530dc1811663a5498acfa1df879 (patch)
tree04f682c70dda155df024725c39f5093fdf051316
parent631750d87c2711d2c29c5522a0d8de7744080ac3 (diff)
Dmenu overhaul
-rw-r--r--Makefile7
-rw-r--r--config.mk5
-rw-r--r--profiles/master/keys.h4
-rwxr-xr-xscripts/cp.sh1
-rwxr-xr-xscripts/pre_build.sh7
-rwxr-xr-xwm/dmenu-5.2/dmenu_run6
-rw-r--r--wm/dmenu-5.3/LICENSE (renamed from wm/dmenu-5.2/LICENSE)0
-rw-r--r--wm/dmenu-5.3/Makefile (renamed from wm/dmenu-5.2/Makefile)12
-rw-r--r--wm/dmenu-5.3/README (renamed from wm/dmenu-5.2/README)0
-rw-r--r--wm/dmenu-5.3/arg.h (renamed from wm/dmenu-5.2/arg.h)0
-rw-r--r--wm/dmenu-5.3/config.def.h (renamed from wm/dmenu-5.2/config.def.h)13
-rw-r--r--wm/dmenu-5.3/config.h (renamed from wm/dmenu-5.2/config.h)19
-rw-r--r--wm/dmenu-5.3/config.mk (renamed from wm/dmenu-5.2/config.mk)6
-rw-r--r--wm/dmenu-5.3/dmenu.1234
-rw-r--r--wm/dmenu-5.3/dmenu.1.orig (renamed from wm/dmenu-5.2/dmenu.1)18
-rw-r--r--wm/dmenu-5.3/dmenu.c (renamed from wm/dmenu-5.2/dmenu.c)211
-rwxr-xr-xwm/dmenu-5.3/dmenu_path (renamed from wm/dmenu-5.2/dmenu_path)0
-rwxr-xr-xwm/dmenu-5.3/dmenu_run6
-rw-r--r--wm/dmenu-5.3/drw.c (renamed from wm/dmenu-5.2/drw.c)49
-rw-r--r--wm/dmenu-5.3/drw.h (renamed from wm/dmenu-5.2/drw.h)9
-rw-r--r--wm/dmenu-5.3/patches/dmenu-alpha-20230110-5.2.diff293
-rw-r--r--wm/dmenu-5.3/patches/dmenu-border-20230512-0fe460d.diff36
-rw-r--r--wm/dmenu-5.3/patches/dmenu-center-20250407-b1e217b.diff135
-rw-r--r--wm/dmenu-5.3/patches/dmenu-grid-4.9.diff107
-rw-r--r--wm/dmenu-5.3/patches/dmenu-lineheight-4.6.diff99
-rw-r--r--wm/dmenu-5.3/patches/dmenu-lineheight-5.2.diff106
-rw-r--r--wm/dmenu-5.3/patches/dmenu-xyw-5.2.diff99
-rw-r--r--wm/dmenu-5.3/stest.1 (renamed from wm/dmenu-5.2/stest.1)0
-rw-r--r--wm/dmenu-5.3/stest.c (renamed from wm/dmenu-5.2/stest.c)0
-rw-r--r--wm/dmenu-5.3/util.c (renamed from wm/dmenu-5.2/util.c)0
-rw-r--r--wm/dmenu-5.3/util.h (renamed from wm/dmenu-5.2/util.h)1
31 files changed, 1371 insertions, 112 deletions
diff --git a/Makefile b/Makefile
index 755cf61..6f4efa8 100644
--- a/Makefile
+++ b/Makefile
@@ -15,8 +15,11 @@ config:
rm -rf .config
@./scripts/set_theme.sh
@echo "Run make to compile sarc"
-sarc: clean
+sarc: clean
./scripts/cp.sh
+ ${COLOR}
+ cp wm/${DMENU}/config.h wm/${DMENU}/real_config.h
+ ./scripts/pre_build.sh
mkdir -p ~/.config/sarc/
@echo "Compiling wm..."
make wm -C wm
@@ -36,7 +39,7 @@ install: feh_fix
clean:
make clean-wm -C wm
make clean-utils -C utils
- rm -rf colors.h
+ rm -rf colors.h wm/${DMENU}/real_config.h
part:
./scripts/cp.sh
cleanp: clean
diff --git a/config.mk b/config.mk
index 7540a88..18dab69 100644
--- a/config.mk
+++ b/config.mk
@@ -1,8 +1,7 @@
-#PREFIX=~/projects/sarc/build
PREFIX=/usr/local
-MANPREFIX=$(PREFIX)/share/man
+MANPREFIX=${PREFIX}/share/man
X11INC=/usr/X11R6/include
X11LIB=/usr/X11R6/lib
DWM=dwm-6.4
ST=st-0.9
-DMENU=dmenu-5.2
+DMENU=dmenu-5.3
diff --git a/profiles/master/keys.h b/profiles/master/keys.h
index b4e5c28..8a9b039 100644
--- a/profiles/master/keys.h
+++ b/profiles/master/keys.h
@@ -1,7 +1,9 @@
+#define WINKEY Mod4Mask
static Key keys[] = {
/* modifier key function argument */
{ MODKEY, XK_d, spawn, {.v = dmenucmd } },
- { MODKEY, XK_Return, spawn, {.v = termcmd } },
+ { 0, XK_Super_L, spawn, SHCMD("dmenu_run") },
+ { MODKEY, XK_Return, spawn, {.v = termcmd } },
{ MODKEY, XK_b, togglebar, {0} },
{ MODKEY, XK_j, focusstack, {.i = +1 } },
{ MODKEY, XK_k, focusstack, {.i = -1 } },
diff --git a/scripts/cp.sh b/scripts/cp.sh
index 2722351..7fb531c 100755
--- a/scripts/cp.sh
+++ b/scripts/cp.sh
@@ -4,3 +4,4 @@ cp ./profiles/$PROFILE/keys.h ./wm/dwm-6.4/
cp ./profiles/$PROFILE/blocks.h ./wm/dwmblocks/
cp ./theme/$THEME/$THEME.png ~/.config/wallpaper.png
cp ./theme/$THEME/colors.h .
+
diff --git a/scripts/pre_build.sh b/scripts/pre_build.sh
new file mode 100755
index 0000000..a29b4cb
--- /dev/null
+++ b/scripts/pre_build.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+source config.mk
+# Set color variable for dmenu
+COLOR=$(grep col_cyan colors.h | sed "s/static const char col_cyan\[\] //g ; s/ //g ; s/=\"//g ; s/\"\;//g")
+GRAY=$(grep col_gray1 colors.h | sed "s/static const char col_gray1\[\] //g ; s/ //g ; s/=\"//g ; s/\"\;//g")
+sed -i "s/COL_CYAN/\"${COLOR}\"/g" wm/${DMENU}/real_config.h
+sed -i "s/COL_GRAY/\"${GRAY}\"/g" wm/${DMENU}/real_config.h
diff --git a/wm/dmenu-5.2/dmenu_run b/wm/dmenu-5.2/dmenu_run
deleted file mode 100755
index e3b2aab..0000000
--- a/wm/dmenu-5.2/dmenu_run
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/sh
-
-DMENU_PATH=$(echo $PATH | sed 's/:/ /g' | sort -u)
-EXE=$(ls $DMENU_PATH | grep -v '^/' | sort -u | dmenu -p "Enter a program name: ")
-
-$EXE
diff --git a/wm/dmenu-5.2/LICENSE b/wm/dmenu-5.3/LICENSE
index 2a64b28..2a64b28 100644
--- a/wm/dmenu-5.2/LICENSE
+++ b/wm/dmenu-5.3/LICENSE
diff --git a/wm/dmenu-5.2/Makefile b/wm/dmenu-5.3/Makefile
index a03a95c..ffa6c1b 100644
--- a/wm/dmenu-5.2/Makefile
+++ b/wm/dmenu-5.3/Makefile
@@ -6,13 +6,7 @@ include config.mk
SRC = drw.c dmenu.c stest.c util.c
OBJ = $(SRC:.c=.o)
-all: options dmenu stest
-
-options:
- @echo dmenu build options:
- @echo "CFLAGS = $(CFLAGS)"
- @echo "LDFLAGS = $(LDFLAGS)"
- @echo "CC = $(CC)"
+all: dmenu stest
.c.o:
$(CC) -c $(CFLAGS) $<
@@ -20,7 +14,7 @@ options:
config.h:
cp config.def.h $@
-$(OBJ): arg.h config.h config.mk drw.h
+$(OBJ): arg.h real_config.h config.mk drw.h
dmenu: dmenu.o drw.o util.o
$(CC) -o $@ dmenu.o drw.o util.o $(LDFLAGS)
@@ -61,4 +55,4 @@ uninstall:
$(DESTDIR)$(MANPREFIX)/man1/dmenu.1\
$(DESTDIR)$(MANPREFIX)/man1/stest.1
-.PHONY: all options clean dist install uninstall
+.PHONY: all clean dist install uninstall
diff --git a/wm/dmenu-5.2/README b/wm/dmenu-5.3/README
index a8fcdfe..a8fcdfe 100644
--- a/wm/dmenu-5.2/README
+++ b/wm/dmenu-5.3/README
diff --git a/wm/dmenu-5.2/arg.h b/wm/dmenu-5.3/arg.h
index e94e02b..e94e02b 100644
--- a/wm/dmenu-5.2/arg.h
+++ b/wm/dmenu-5.3/arg.h
diff --git a/wm/dmenu-5.2/config.def.h b/wm/dmenu-5.3/config.def.h
index 1edb647..d336705 100644
--- a/wm/dmenu-5.2/config.def.h
+++ b/wm/dmenu-5.3/config.def.h
@@ -2,6 +2,7 @@
/* Default settings; can be overriden by command line. */
static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */
+static const unsigned int alpha = 0xff; /* Amount of opacity. 0xff is opaque */
/* -fn option overrides fonts[0]; default X11 font or font set */
static const char *fonts[] = {
"monospace:size=10"
@@ -13,11 +14,21 @@ static const char *colors[SchemeLast][2] = {
[SchemeSel] = { "#eeeeee", "#005577" },
[SchemeOut] = { "#000000", "#00ffff" },
};
-/* -l option; if nonzero, dmenu uses vertical list with given number of lines */
+
+static const unsigned int alphas[SchemeLast][2] = {
+ [SchemeNorm] = { OPAQUE, alpha },
+ [SchemeSel] = { OPAQUE, alpha },
+ [SchemeOut] = { OPAQUE, alpha },
+};
+/* -l and -g options; controls number of lines and columns in grid if > 0 */
static unsigned int lines = 0;
+static unsigned int columns = 0;
/*
* Characters not considered part of a word while deleting words
* for example: " /?\"&[]"
*/
static const char worddelimiters[] = " ";
+
+/* Size of the window border */
+static unsigned int border_width = 0;
diff --git a/wm/dmenu-5.2/config.h b/wm/dmenu-5.3/config.h
index 2085cc2..7d4edc0 100644
--- a/wm/dmenu-5.2/config.h
+++ b/wm/dmenu-5.3/config.h
@@ -1,7 +1,14 @@
/* See LICENSE file for copyright and license details. */
/* Default settings; can be overriden by command line. */
+static unsigned int lineheight = 0;
+static unsigned int min_lineheight = 8;
static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */
+static unsigned int border_width = 0;
+static int centered = 0;
+static int min_width = 500;
+static const float menu_height_ratio = 4.0f;
+static const unsigned int alpha = 0xf0; /* Amount of opacity. 0xff is opaque */
/* -fn option overrides fonts[0]; default X11 font or font set */
static const char *fonts[] = {
"Source Code Pro:size=9"
@@ -9,13 +16,19 @@ static const char *fonts[] = {
static const char *prompt = NULL; /* -p option; prompt to the left of input field */
static const char *colors[SchemeLast][2] = {
/* fg bg */
- [SchemeNorm] = { "#bbbbbb", "#222222" },
- [SchemeSel] = { "#eeeeee", "#005577" },
+ [SchemeNorm] = { "#bbbbbb", COL_GRAY },
+ [SchemeSel] = { "#eeeeee", COL_CYAN},
[SchemeOut] = { "#000000", "#00ffff" },
};
+
+static const unsigned int alphas[SchemeLast][2] = {
+ [SchemeNorm] = { OPAQUE, alpha },
+ [SchemeSel] = { OPAQUE, alpha },
+ [SchemeOut] = { OPAQUE, alpha },
+};
/* -l option; if nonzero, dmenu uses vertical list with given number of lines */
static unsigned int lines = 0;
-
+static unsigned int columns = 0;
/*
* Characters not considered part of a word while deleting words
* for example: " /?\"&[]"
diff --git a/wm/dmenu-5.2/config.mk b/wm/dmenu-5.3/config.mk
index 7570ff1..64c3b06 100644
--- a/wm/dmenu-5.2/config.mk
+++ b/wm/dmenu-5.3/config.mk
@@ -1,5 +1,5 @@
# dmenu version
-VERSION = 5.2
+VERSION = 5.3
# paths
PREFIX = /usr/local
@@ -21,11 +21,11 @@ FREETYPEINC = /usr/include/freetype2
# includes and libs
INCS = -I$(X11INC) -I$(FREETYPEINC)
-LIBS = -L$(X11LIB) -lX11 $(XINERAMALIBS) $(FREETYPELIBS)
+LIBS = -L$(X11LIB) -lX11 $(XINERAMALIBS) $(FREETYPELIBS) -lXrender
# flags
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200809L -DVERSION=\"$(VERSION)\" $(XINERAMAFLAGS)
-CFLAGS = -std=c99 -pedantic -O3 $(INCS) $(CPPFLAGS)
+CFLAGS = -std=c99 -pedantic -Wall -Os $(INCS) $(CPPFLAGS)
LDFLAGS = $(LIBS)
# compiler and linker
diff --git a/wm/dmenu-5.3/dmenu.1 b/wm/dmenu-5.3/dmenu.1
new file mode 100644
index 0000000..89eb7bf
--- /dev/null
+++ b/wm/dmenu-5.3/dmenu.1
@@ -0,0 +1,234 @@
+.TH DMENU 1 dmenu\-VERSION
+.SH NAME
+dmenu \- dynamic menu
+.SH SYNOPSIS
+.B dmenu
+.RB [ \-bfiv ]
+.RB [ \-g
+.IR columns ]
+.RB [ \-l
+.IR lines ]
+.RB [ \-h
+.IR height ]
+.RB [ \-m
+.IR monitor ]
+.RB [ \-x
+.IR xoffset ]
+.RB [ \-y
+.IR yoffset ]
+.RB [ \-z
+.IR width ]
+.RB [ \-p
+.IR prompt ]
+.RB [ \-fn
+.IR font ]
+.RB [ \-nb
+.IR color ]
+.RB [ \-nf
+.IR color ]
+.RB [ \-sb
+.IR color ]
+.RB [ \-sf
+.IR color ]
+.RB [ \-w
+.IR windowid ]
+.P
+.BR dmenu_run " ..."
+.SH DESCRIPTION
+.B dmenu
+is a dynamic menu for X, which reads a list of newline\-separated items from
+stdin. When the user selects an item and presses Return, their choice is printed
+to stdout and dmenu terminates. Entering text will narrow the items to those
+matching the tokens in the input.
+.P
+.B dmenu_run
+is a script used by
+.IR dwm (1)
+which lists programs in the user's $PATH and runs the result in their $SHELL.
+.SH OPTIONS
+.TP
+.B \-b
+dmenu appears at the bottom of the screen.
+.TP
+.B \-c
+dmenu appears centered on the screen.
+.TP
+.B \-f
+dmenu grabs the keyboard before reading stdin if not reading from a tty. This
+is faster, but will lock up X until stdin reaches end\-of\-file.
+.TP
+.B \-i
+dmenu matches menu items case insensitively.
+.TP
+.BI \-g " columns"
+dmenu lists items in a grid with the given number of columns.
+.TP
+.BI \-l " lines"
+dmenu lists items in a grid with the given number of lines.
+.TP
+.BI \-lh " height"
+dmenu uses a menu line of at least 'height' pixels tall, but no less than 8.
+.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.
+.TP
+.BI \-x " xoffset"
+dmenu is placed at this offset measured from the left side of the monitor.
+Can be negative.
+If option
+.B \-m
+is present, the measurement will use the given monitor.
+.TP
+.BI \-y " yoffset"
+dmenu is placed at this offset measured from the top of the monitor. If the
+.B \-b
+option is used, the offset is measured from the bottom. Can be negative.
+If option
+.B \-m
+is present, the measurement will use the given monitor.
+.TP
+.BI \-z " width"
+sets the width of the dmenu window.
+.TP
+.BI \-p " prompt"
+defines the prompt to be displayed to the left of the input field.
+.TP
+.BI \-fn " font"
+defines the font or font set used.
+.TP
+.BI \-nb " color"
+defines the normal background color.
+.IR #RGB ,
+.IR #RRGGBB ,
+and X color names are supported.
+.TP
+.BI \-nf " color"
+defines the normal foreground color.
+.TP
+.BI \-sb " color"
+defines the selected background color.
+.TP
+.BI \-sf " color"
+defines the selected foreground color.
+.TP
+.B \-v
+prints version information to stdout, then exits.
+.TP
+.BI \-w " windowid"
+embed into windowid.
+.SH USAGE
+dmenu is completely controlled by the keyboard. Items are selected using the
+arrow keys, page up, page down, home, and end.
+.TP
+.B Tab
+Copy the selected item to the input field.
+.TP
+.B Return
+Confirm selection. Prints the selected item to stdout and exits, returning
+success.
+.TP
+.B Ctrl-Return
+Confirm selection. Prints the selected item to stdout and continues.
+.TP
+.B Shift\-Return
+Confirm input. Prints the input text to stdout and exits, returning success.
+.TP
+.B Escape
+Exit without selecting an item, returning failure.
+.TP
+.B Ctrl-Left
+Move cursor to the start of the current word
+.TP
+.B Ctrl-Right
+Move cursor to the end of the current word
+.TP
+.B C\-a
+Home
+.TP
+.B C\-b
+Left
+.TP
+.B C\-c
+Escape
+.TP
+.B C\-d
+Delete
+.TP
+.B C\-e
+End
+.TP
+.B C\-f
+Right
+.TP
+.B C\-g
+Escape
+.TP
+.B C\-h
+Backspace
+.TP
+.B C\-i
+Tab
+.TP
+.B C\-j
+Return
+.TP
+.B C\-J
+Shift-Return
+.TP
+.B C\-k
+Delete line right
+.TP
+.B C\-m
+Return
+.TP
+.B C\-M
+Shift-Return
+.TP
+.B C\-n
+Down
+.TP
+.B C\-p
+Up
+.TP
+.B C\-u
+Delete line left
+.TP
+.B C\-w
+Delete word left
+.TP
+.B C\-y
+Paste from primary X selection
+.TP
+.B C\-Y
+Paste from X clipboard
+.TP
+.B M\-b
+Move cursor to the start of the current word
+.TP
+.B M\-f
+Move cursor to the end of the current word
+.TP
+.B M\-g
+Home
+.TP
+.B M\-G
+End
+.TP
+.B M\-h
+Up
+.TP
+.B M\-j
+Page down
+.TP
+.B M\-k
+Page up
+.TP
+.B M\-l
+Down
+.SH SEE ALSO
+.IR dwm (1),
+.IR stest (1)
diff --git a/wm/dmenu-5.2/dmenu.1 b/wm/dmenu-5.3/dmenu.1.orig
index 323f93c..be710c7 100644
--- a/wm/dmenu-5.2/dmenu.1
+++ b/wm/dmenu-5.3/dmenu.1.orig
@@ -4,8 +4,12 @@ dmenu \- dynamic menu
.SH SYNOPSIS
.B dmenu
.RB [ \-bfiv ]
+.RB [ \-g
+.IR columns ]
.RB [ \-l
.IR lines ]
+.RB [ \-h
+.IR height ]
.RB [ \-m
.IR monitor ]
.RB [ \-p
@@ -40,6 +44,9 @@ which lists programs in the user's $PATH and runs the result in their $SHELL.
.B \-b
dmenu appears at the bottom of the screen.
.TP
+.B \-c
+dmenu appears centered on the screen.
+.TP
.B \-f
dmenu grabs the keyboard before reading stdin if not reading from a tty. This
is faster, but will lock up X until stdin reaches end\-of\-file.
@@ -47,8 +54,17 @@ is faster, but will lock up X until stdin reaches end\-of\-file.
.B \-i
dmenu matches menu items case insensitively.
.TP
+.BI \-g " columns"
+dmenu lists items in a grid with the given number of columns.
+.TP
.BI \-l " lines"
-dmenu lists items vertically, with the given number of lines.
+dmenu lists items in a grid with the given number of lines.
+.TP
+.BI \-lh " height"
+dmenu uses a menu line of at least 'height' pixels tall, but no less than 8.
+.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
diff --git a/wm/dmenu-5.2/dmenu.c b/wm/dmenu-5.3/dmenu.c
index 0526abb..504487c 100644
--- a/wm/dmenu-5.2/dmenu.c
+++ b/wm/dmenu-5.3/dmenu.c
@@ -10,10 +10,12 @@
#include <X11/Xlib.h>
#include <X11/Xatom.h>
+#include <X11/Xproto.h>
#include <X11/Xutil.h>
#ifdef XINERAMA
#include <X11/extensions/Xinerama.h>
#endif
+#include <X11/extensions/Xrender.h>
#include <X11/Xft/Xft.h>
#include "drw.h"
@@ -22,24 +24,26 @@
/* macros */
#define INTERSECT(x,y,w,h,r) (MAX(0, MIN((x)+(w),(r).x_org+(r).width) - MAX((x),(r).x_org)) \
* MAX(0, MIN((y)+(h),(r).y_org+(r).height) - MAX((y),(r).y_org)))
-#define LENGTH(X) (sizeof X / sizeof X[0])
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
-#define NUMBERSMAXDIGITS 100
-#define NUMBERSBUFSIZE (NUMBERSMAXDIGITS * 2) + 1
+
+#define OPAQUE 0xffu
/* enums */
enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */
struct item {
char *text;
+ unsigned int width;
struct item *left, *right;
int out;
};
-static char numbers[NUMBERSBUFSIZE] = "";
static char text[BUFSIZ] = "";
static char *embed;
static int bh, mw, mh;
+static int dmx = 0; /* put dmenu at this x offset */
+static int dmy = 0; /* put dmenu at this y offset (measured from the bottom if topbar is 0) */
+static unsigned int dmw = 0; /* make dmenu this wide */
static int inputw = 0, promptw;
static int lrpad; /* sum of left and right padding */
static size_t cursor;
@@ -56,10 +60,16 @@ static XIC xic;
static Drw *drw;
static Clr *scheme[SchemeLast];
-#include "config.h"
+static int useargb = 0;
+static Visual *visual;
+static int depth;
+static Colormap cmap;
+
+#include "real_config.h"
static int (*fstrncmp)(const char *, const char *, size_t) = strncmp;
static char *(*fstrstr)(const char *, const char *) = strstr;
+static void xinitvisual();
static unsigned int
textw_clamp(const char *str, unsigned int n)
@@ -87,9 +97,9 @@ calcoffsets(void)
int i, n;
if (lines > 0)
- n = lines * bh;
+ n = lines * columns * bh;
else
- n = mw - (promptw + inputw + TEXTW("<") + TEXTW(">") + TEXTW(numbers));
+ n = mw - (promptw + inputw + TEXTW("<") + TEXTW(">"));
/* calculate which items will begin the next page and previous page */
for (i = 0, next = curr; next; next = next->right)
if ((i += (lines > 0) ? bh : textw_clamp(next->text, n)) > n)
@@ -99,6 +109,15 @@ calcoffsets(void)
break;
}
+static int
+max_textw(void)
+{
+ int len = 0;
+ for (struct item *item = items; item && item->text; item++)
+ len = MAX(item->width, len);
+ return len;
+}
+
static void
cleanup(void)
{
@@ -147,26 +166,11 @@ drawitem(struct item *item, int x, int y, int w)
}
static void
-recalculatenumbers()
-{
- unsigned int numer = 0, denom = 0;
- struct item *item;
- if (matchend) {
- numer++;
- for (item = matchend; item && item->left; item = item->left)
- numer++;
- }
- for (item = items; item && item->text; item++)
- denom++;
- snprintf(numbers, NUMBERSBUFSIZE, "%d/%d", numer, denom);
-}
-
-static void
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);
@@ -183,14 +187,19 @@ 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);
}
- recalculatenumbers();
if (lines > 0) {
- /* draw vertical list */
- for (item = curr; item != next; item = item->right)
- drawitem(item, x, y += bh, mw - x);
+ /* draw grid */
+ int i = 0;
+ for (item = curr; item != next; item = item->right, i++)
+ drawitem(
+ item,
+ x + ((i / lines) * ((mw - x) / columns)),
+ y + (((i % lines) + 1) * bh),
+ (mw - x) / columns
+ );
} else if (matches) {
/* draw horizontal list */
x += inputw;
@@ -201,15 +210,13 @@ drawmenu(void)
}
x += w;
for (item = curr; item != next; item = item->right)
- x = drawitem(item, x, 0, textw_clamp(item->text, mw - x - TEXTW(">") - TEXTW(numbers)));
+ x = drawitem(item, x, 0, textw_clamp(item->text, mw - x - TEXTW(">")));
if (next) {
w = TEXTW(">");
drw_setscheme(drw, scheme[SchemeNorm]);
- drw_text(drw, mw - w - TEXTW(numbers), 0, w, bh, lrpad / 2, ">", 0);
+ drw_text(drw, mw - w, 0, w, bh, lrpad / 2, ">", 0);
}
}
- drw_setscheme(drw, scheme[SchemeNorm]);
- drw_text(drw, mw - TEXTW(numbers), 0, TEXTW(numbers), bh, lrpad / 2, numbers, 0);
drw_map(drw, win, 0, 0, mw, mh);
}
@@ -345,19 +352,19 @@ movewordedge(int dir)
static void
keypress(XKeyEvent *ev)
{
- char buf[32];
+ char buf[64];
int len;
- KeySym ksym;
+ KeySym ksym = NoSymbol;
Status status;
len = XmbLookupString(xic, ev, buf, sizeof buf, &ksym, &status);
switch (status) {
default: /* XLookupNone, XBufferOverflow */
return;
- case XLookupChars:
+ case XLookupChars: /* composed string from input method */
goto insert;
case XLookupKeySym:
- case XLookupBoth:
+ case XLookupBoth: /* a KeySym and a string are returned: use keysym */
break;
}
@@ -571,19 +578,25 @@ static void
readstdin(void)
{
char *line = NULL;
- size_t i, junk, size = 0;
+ size_t i, itemsiz = 0, linesiz = 0;
ssize_t len;
/* read each line from stdin and add it to the item list */
- for (i = 0; (len = getline(&line, &junk, stdin)) != -1; i++, line = NULL) {
- if (i + 1 >= size / sizeof *items)
- if (!(items = realloc(items, (size += BUFSIZ))))
- die("cannot realloc %zu bytes:", size);
+ for (i = 0; (len = getline(&line, &linesiz, stdin)) != -1; i++) {
+ if (i + 1 >= itemsiz) {
+ itemsiz += 256;
+ if (!(items = realloc(items, itemsiz * sizeof(*items))))
+ die("cannot realloc %zu bytes:", itemsiz * sizeof(*items));
+ }
if (line[len - 1] == '\n')
line[len - 1] = '\0';
- items[i].text = line;
+ if (!(items[i].text = strdup(line)))
+ die("strdup:");
+ items[i].width = TEXTW(line);
+
items[i].out = 0;
}
+ free(line);
if (items)
items[i].text = NULL;
lines = MIN(lines, i);
@@ -644,15 +657,17 @@ setup(void)
#endif
/* init appearance */
for (j = 0; j < SchemeLast; j++)
- scheme[j] = drw_scm_create(drw, colors[j], 2);
+ scheme[j] = drw_scm_create(drw, colors[j], alphas[i], 2);
clip = XInternAtom(dpy, "CLIPBOARD", False);
utf8 = XInternAtom(dpy, "UTF8_STRING", False);
/* 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;
+ promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
#ifdef XINERAMA
i = 0;
if (parentwin == root && (info = XineramaQueryScreens(dpy, &n))) {
@@ -679,9 +694,16 @@ setup(void)
if (INTERSECT(x, y, 1, 1, info[i]) != 0)
break;
- x = info[i].x_org;
- y = info[i].y_org + (topbar ? 0 : info[i].height - mh);
- mw = info[i].width;
+ if (centered) {
+ mw = MIN(MAX(max_textw() + promptw, min_width), info[i].width);
+ x = info[i].x_org + ((info[i].width - mw) / 2) + dmx;
+ y = info[i].y_org + ((info[i].height - mh) / menu_height_ratio - dmy);
+ } else {
+ x = info[i].x_org + dmx;
+ y = info[i].y_org + (topbar ? 0 : info[i].height - mh - dmy);
+ mw = (dmw>0 ? dmw : info[i].width);;
+ }
+
XFree(info);
} else
#endif
@@ -689,9 +711,16 @@ setup(void)
if (!XGetWindowAttributes(dpy, parentwin, &wa))
die("could not get embedding window attributes: 0x%lx",
parentwin);
- x = 0;
- y = topbar ? 0 : wa.height - mh;
- mw = wa.width;
+
+ if (centered) {
+ mw = MIN(MAX(max_textw() + promptw, min_width), wa.width) + dmw;
+ x = (wa.width - mw) / 2 + dmx;
+ y = (wa.height - mh) / 2 - dmy;
+ } else {
+ x = dmx;
+ y = topbar ? dmy : wa.height - mh - dmy;
+ mw = (dmw>0 ? dmw : wa.width);
+ }
}
promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
inputw = mw / 3; /* input width: ~33% of monitor width */
@@ -699,11 +728,15 @@ setup(void)
/* create menu window */
swa.override_redirect = True;
- swa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
+ swa.background_pixel = 0;
+ swa.border_pixel = 0;
+ swa.colormap = cmap;
swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask;
- win = XCreateWindow(dpy, parentwin, x, y, mw, mh, 0,
- CopyFromParent, CopyFromParent, CopyFromParent,
- CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
+ win = XCreateWindow(dpy, root, x, y, mw, mh, border_width,
+ depth, CopyFromParent, visual,
+ CWOverrideRedirect | CWBackPixel | CWBorderPixel | CWColormap | CWEventMask, &swa);
+ if (border_width)
+ XSetWindowBorder(dpy, win, scheme[SchemeSel][ColBg].pixel);
XSetClassHint(dpy, win, &ch);
@@ -716,6 +749,7 @@ setup(void)
XMapRaised(dpy, win);
if (embed) {
+ XReparentWindow(dpy, win, parentwin, x, y);
XSelectInput(dpy, parentwin, FocusChangeMask | SubstructureNotifyMask);
if (XQueryTree(dpy, parentwin, &dw, &w, &dws, &du) && dws) {
for (i = 0; i < du && dws[i] != win; ++i)
@@ -731,7 +765,7 @@ setup(void)
static void
usage(void)
{
- die("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
+ die("usage: dmenu [-bfiv] [-l lines] [-h height] [-p prompt] [-fn font] [-m monitor]\n"
" [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]");
}
@@ -750,20 +784,43 @@ main(int argc, char *argv[])
topbar = 0;
else if (!strcmp(argv[i], "-f")) /* grabs keyboard before reading stdin */
fast = 1;
+ else if (!strcmp(argv[i], "-c")) /* centers dmenu on screen */
+ centered = 1;
else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */
fstrncmp = strncasecmp;
fstrstr = cistrstr;
} else if (i + 1 == argc)
usage();
/* these options take one argument */
- else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */
+ else if (!strcmp(argv[i], "-g")) { /* number of columns in grid */
+ columns = atoi(argv[++i]);
+ if (lines == 0) lines = 1;
+ } else if (!strcmp(argv[i], "-l")) { /* number of lines in grid */
lines = atoi(argv[++i]);
- else if (!strcmp(argv[i], "-m"))
+ if (columns == 0) columns = 1;
+ }
+
+ else if (!strcmp(argv[i], "-x")) /* window x offset */
+ dmx = atoi(argv[++i]);
+ else if (!strcmp(argv[i], "-y")) /* window y offset (from bottom up if -b) */
+ dmy = atoi(argv[++i]);
+ else if (!strcmp(argv[i], "-z")) /* make dmenu this wide */
+ dmw = 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 */
prompt = argv[++i];
else if (!strcmp(argv[i], "-fn")) /* font or font set */
fonts[0] = argv[++i];
+ else if(!strcmp(argv[i], "-lh")) { /* 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 */
@@ -774,6 +831,8 @@ main(int argc, char *argv[])
colors[SchemeSel][ColFg] = argv[++i];
else if (!strcmp(argv[i], "-w")) /* embedding window id */
embed = argv[++i];
+ else if (!strcmp(argv[i], "-bw"))
+ border_width = atoi(argv[++i]); /* border width */
else
usage();
@@ -788,7 +847,8 @@ main(int argc, char *argv[])
if (!XGetWindowAttributes(dpy, parentwin, &wa))
die("could not get embedding window attributes: 0x%lx",
parentwin);
- drw = drw_create(dpy, screen, root, wa.width, wa.height);
+ xinitvisual();
+ drw = drw_create(dpy, screen, root, wa.width, wa.height, visual, depth, cmap);
if (!drw_fontset_create(drw, fonts, LENGTH(fonts)))
die("no fonts could be loaded.");
lrpad = drw->fonts->h;
@@ -810,3 +870,40 @@ main(int argc, char *argv[])
return 1; /* unreachable */
}
+
+void
+xinitvisual()
+{
+ XVisualInfo *infos;
+ XRenderPictFormat *fmt;
+ int nitems;
+ int i;
+
+ XVisualInfo tpl = {
+ .screen = screen,
+ .depth = 32,
+ .class = TrueColor
+ };
+ long masks = VisualScreenMask | VisualDepthMask | VisualClassMask;
+
+ infos = XGetVisualInfo(dpy, masks, &tpl, &nitems);
+ visual = NULL;
+ for(i = 0; i < nitems; i ++) {
+ fmt = XRenderFindVisualFormat(dpy, infos[i].visual);
+ if (fmt->type == PictTypeDirect && fmt->direct.alphaMask) {
+ visual = infos[i].visual;
+ depth = infos[i].depth;
+ cmap = XCreateColormap(dpy, root, visual, AllocNone);
+ useargb = 1;
+ break;
+ }
+ }
+
+ XFree(infos);
+
+ if (! visual) {
+ visual = DefaultVisual(dpy, screen);
+ depth = DefaultDepth(dpy, screen);
+ cmap = DefaultColormap(dpy, screen);
+ }
+}
diff --git a/wm/dmenu-5.2/dmenu_path b/wm/dmenu-5.3/dmenu_path
index 3a7cda7..3a7cda7 100755
--- a/wm/dmenu-5.2/dmenu_path
+++ b/wm/dmenu-5.3/dmenu_path
diff --git a/wm/dmenu-5.3/dmenu_run b/wm/dmenu-5.3/dmenu_run
new file mode 100755
index 0000000..590995a
--- /dev/null
+++ b/wm/dmenu-5.3/dmenu_run
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+DMENU_PATH=$(echo $PATH | sed 's/:/ /g' | sort -u)
+EXE=$(ls $DMENU_PATH | grep -v '^/' | sort -u | dmenu -bw 3 -c -g 3 -l 20 -p "Run: ")
+
+$EXE
diff --git a/wm/dmenu-5.2/drw.c b/wm/dmenu-5.3/drw.c
index a58a2b4..4c1790e 100644
--- a/wm/dmenu-5.2/drw.c
+++ b/wm/dmenu-5.3/drw.c
@@ -61,7 +61,7 @@ utf8decode(const char *c, long *u, size_t clen)
}
Drw *
-drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h)
+drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h, Visual *visual, unsigned int depth, Colormap cmap)
{
Drw *drw = ecalloc(1, sizeof(Drw));
@@ -70,8 +70,11 @@ drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h
drw->root = root;
drw->w = w;
drw->h = h;
- drw->drawable = XCreatePixmap(dpy, root, w, h, DefaultDepth(dpy, screen));
- drw->gc = XCreateGC(dpy, root, 0, NULL);
+ drw->visual = visual;
+ drw->depth = depth;
+ drw->cmap = cmap;
+ drw->drawable = XCreatePixmap(dpy, root, w, h, depth);
+ drw->gc = XCreateGC(dpy, drw->drawable, 0, NULL);
XSetLineAttributes(dpy, drw->gc, 1, LineSolid, CapButt, JoinMiter);
return drw;
@@ -87,7 +90,7 @@ drw_resize(Drw *drw, unsigned int w, unsigned int h)
drw->h = h;
if (drw->drawable)
XFreePixmap(drw->dpy, drw->drawable);
- drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, DefaultDepth(drw->dpy, drw->screen));
+ drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, drw->depth);
}
void
@@ -181,21 +184,22 @@ drw_fontset_free(Fnt *font)
}
void
-drw_clr_create(Drw *drw, Clr *dest, const char *clrname)
+drw_clr_create(Drw *drw, Clr *dest, const char *clrname, unsigned int alpha)
{
if (!drw || !dest || !clrname)
return;
- if (!XftColorAllocName(drw->dpy, DefaultVisual(drw->dpy, drw->screen),
- DefaultColormap(drw->dpy, drw->screen),
+ if (!XftColorAllocName(drw->dpy, drw->visual, drw->cmap,
clrname, dest))
die("error, cannot allocate color '%s'", clrname);
+
+ dest->pixel = (dest->pixel & 0x00ffffffU) | (alpha << 24);
}
/* Wrapper to create color schemes. The caller has to call free(3) on the
* returned color scheme when done using it. */
Clr *
-drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
+drw_scm_create(Drw *drw, const char *clrnames[], const unsigned int alphas[], size_t clrcount)
{
size_t i;
Clr *ret;
@@ -205,7 +209,7 @@ drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
return NULL;
for (i = 0; i < clrcount; i++)
- drw_clr_create(drw, &ret[i], clrnames[i]);
+ drw_clr_create(drw, &ret[i], clrnames[i], alphas[i]);
return ret;
}
@@ -238,8 +242,8 @@ drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int
int
drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert)
{
- int i, ty, ellipsis_x = 0;
- unsigned int tmpw, ew, ellipsis_w = 0, ellipsis_len;
+ int ty, ellipsis_x = 0;
+ unsigned int tmpw, ew, ellipsis_w = 0, ellipsis_len, hash, h0, h1;
XftDraw *d = NULL;
Fnt *usedfont, *curfont, *nextfont;
int utf8strlen, utf8charlen, render = x || y || w || h;
@@ -251,9 +255,7 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
XftResult result;
int charexists = 0, overflow = 0;
/* keep track of a couple codepoints for which we have no match. */
- enum { nomatches_len = 64 };
- static struct { long codepoint[nomatches_len]; unsigned int idx; } nomatches;
- static unsigned int ellipsis_width = 0;
+ static unsigned int nomatches[128], ellipsis_width;
if (!drw || (render && (!drw->scheme || !w)) || !text || !drw->fonts)
return 0;
@@ -263,9 +265,7 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
} else {
XSetForeground(drw->dpy, drw->gc, drw->scheme[invert ? ColFg : ColBg].pixel);
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
- d = XftDrawCreate(drw->dpy, drw->drawable,
- DefaultVisual(drw->dpy, drw->screen),
- DefaultColormap(drw->dpy, drw->screen));
+ d = XftDrawCreate(drw->dpy, drw->drawable, drw->visual, drw->cmap);
x += lpad;
w -= lpad;
}
@@ -338,11 +338,14 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
* character must be drawn. */
charexists = 1;
- for (i = 0; i < nomatches_len; ++i) {
- /* avoid calling XftFontMatch if we know we won't find a match */
- if (utf8codepoint == nomatches.codepoint[i])
- goto no_match;
- }
+ hash = (unsigned int)utf8codepoint;
+ hash = ((hash >> 16) ^ hash) * 0x21F0AAAD;
+ hash = ((hash >> 15) ^ hash) * 0xD35A2D97;
+ h0 = ((hash >> 15) ^ hash) % LENGTH(nomatches);
+ h1 = (hash >> 17) % LENGTH(nomatches);
+ /* avoid expensive XftFontMatch call when we know we won't find a match */
+ if (nomatches[h0] == utf8codepoint || nomatches[h1] == utf8codepoint)
+ goto no_match;
fccharset = FcCharSetCreate();
FcCharSetAddChar(fccharset, utf8codepoint);
@@ -371,7 +374,7 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
curfont->next = usedfont;
} else {
xfont_free(usedfont);
- nomatches.codepoint[++nomatches.idx % nomatches_len] = utf8codepoint;
+ nomatches[nomatches[h0] ? h1 : h0] = utf8codepoint;
no_match:
usedfont = drw->fonts;
}
diff --git a/wm/dmenu-5.2/drw.h b/wm/dmenu-5.3/drw.h
index fd7631b..48f2f93 100644
--- a/wm/dmenu-5.2/drw.h
+++ b/wm/dmenu-5.3/drw.h
@@ -20,6 +20,9 @@ typedef struct {
Display *dpy;
int screen;
Window root;
+ Visual *visual;
+ unsigned int depth;
+ Colormap cmap;
Drawable drawable;
GC gc;
Clr *scheme;
@@ -27,7 +30,7 @@ typedef struct {
} Drw;
/* Drawable abstraction */
-Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h);
+Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h, Visual*, unsigned int, Colormap);
void drw_resize(Drw *drw, unsigned int w, unsigned int h);
void drw_free(Drw *drw);
@@ -39,8 +42,8 @@ unsigned int drw_fontset_getwidth_clamp(Drw *drw, const char *text, unsigned int
void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h);
/* Colorscheme abstraction */
-void drw_clr_create(Drw *drw, Clr *dest, const char *clrname);
-Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount);
+void drw_clr_create(Drw *drw, Clr *dest, const char *clrname, unsigned int alpha);
+Clr *drw_scm_create(Drw *drw, const char *clrnames[], const unsigned int alphas[], size_t clrcount);
/* Cursor abstraction */
Cur *drw_cur_create(Drw *drw, int shape);
diff --git a/wm/dmenu-5.3/patches/dmenu-alpha-20230110-5.2.diff b/wm/dmenu-5.3/patches/dmenu-alpha-20230110-5.2.diff
new file mode 100644
index 0000000..e3b1493
--- /dev/null
+++ b/wm/dmenu-5.3/patches/dmenu-alpha-20230110-5.2.diff
@@ -0,0 +1,293 @@
+From 4709ed81c8b8df043420ca9de016054088beb934 Mon Sep 17 00:00:00 2001
+From: Andrew Slice <edward.andrew.slice@gmail.com>
+Date: Tue, 10 Jan 2023 17:22:44 -0500
+Subject: [PATCH] Adds alpha transparency. This also fixes a crash that happens
+ when using '-w' to embed dmenu in a window that has alpha transparency.
+
+Based on the original patch by Marcin Lukow <marcin@nerdy.cat>
+---
+ config.def.h | 7 ++++++
+ config.mk | 2 +-
+ dmenu.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++-----
+ drw.c | 26 ++++++++++++-----------
+ drw.h | 9 +++++---
+ 5 files changed, 83 insertions(+), 21 deletions(-)
+
+diff --git a/config.def.h b/config.def.h
+index 1edb647..809c96e 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -2,6 +2,7 @@
+ /* Default settings; can be overriden by command line. */
+
+ static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */
++static const unsigned int alpha = 0xff; /* Amount of opacity. 0xff is opaque */
+ /* -fn option overrides fonts[0]; default X11 font or font set */
+ static const char *fonts[] = {
+ "monospace:size=10"
+@@ -13,6 +14,12 @@ static const char *colors[SchemeLast][2] = {
+ [SchemeSel] = { "#eeeeee", "#005577" },
+ [SchemeOut] = { "#000000", "#00ffff" },
+ };
++
++static const unsigned int alphas[SchemeLast][2] = {
++ [SchemeNorm] = { OPAQUE, alpha },
++ [SchemeSel] = { OPAQUE, alpha },
++ [SchemeOut] = { OPAQUE, alpha },
++};
+ /* -l option; if nonzero, dmenu uses vertical list with given number of lines */
+ static unsigned int lines = 0;
+
+diff --git a/config.mk b/config.mk
+index 566348b..fa2b4fc 100644
+--- a/config.mk
++++ b/config.mk
+@@ -21,7 +21,7 @@ FREETYPEINC = /usr/include/freetype2
+
+ # includes and libs
+ INCS = -I$(X11INC) -I$(FREETYPEINC)
+-LIBS = -L$(X11LIB) -lX11 $(XINERAMALIBS) $(FREETYPELIBS)
++LIBS = -L$(X11LIB) -lX11 $(XINERAMALIBS) $(FREETYPELIBS) -lXrender
+
+ # flags
+ CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200809L -DVERSION=\"$(VERSION)\" $(XINERAMAFLAGS)
+diff --git a/dmenu.c b/dmenu.c
+index 27b7a30..a20302f 100644
+--- a/dmenu.c
++++ b/dmenu.c
+@@ -10,10 +10,12 @@
+
+ #include <X11/Xlib.h>
+ #include <X11/Xatom.h>
++#include <X11/Xproto.h>
+ #include <X11/Xutil.h>
+ #ifdef XINERAMA
+ #include <X11/extensions/Xinerama.h>
+ #endif
++#include <X11/extensions/Xrender.h>
+ #include <X11/Xft/Xft.h>
+
+ #include "drw.h"
+@@ -25,6 +27,8 @@
+ #define LENGTH(X) (sizeof X / sizeof X[0])
+ #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
+
++#define OPAQUE 0xffu
++
+ /* enums */
+ enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */
+
+@@ -53,10 +57,16 @@ static XIC xic;
+ static Drw *drw;
+ static Clr *scheme[SchemeLast];
+
++static int useargb = 0;
++static Visual *visual;
++static int depth;
++static Colormap cmap;
++
+ #include "config.h"
+
+ static int (*fstrncmp)(const char *, const char *, size_t) = strncmp;
+ static char *(*fstrstr)(const char *, const char *) = strstr;
++static void xinitvisual();
+
+ static unsigned int
+ textw_clamp(const char *str, unsigned int n)
+@@ -627,7 +637,7 @@ setup(void)
+ #endif
+ /* init appearance */
+ for (j = 0; j < SchemeLast; j++)
+- scheme[j] = drw_scm_create(drw, colors[j], 2);
++ scheme[j] = drw_scm_create(drw, colors[j], alphas[i], 2);
+
+ clip = XInternAtom(dpy, "CLIPBOARD", False);
+ utf8 = XInternAtom(dpy, "UTF8_STRING", False);
+@@ -682,11 +692,13 @@ setup(void)
+
+ /* create menu window */
+ swa.override_redirect = True;
+- swa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
++ swa.background_pixel = 0;
++ swa.border_pixel = 0;
++ swa.colormap = cmap;
+ swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask;
+ win = XCreateWindow(dpy, parentwin, x, y, mw, mh, 0,
+- CopyFromParent, CopyFromParent, CopyFromParent,
+- CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
++ depth, CopyFromParent, visual,
++ CWOverrideRedirect | CWBackPixel | CWBorderPixel | CWColormap | CWEventMask, &swa);
+ XSetClassHint(dpy, win, &ch);
+
+
+@@ -771,7 +783,8 @@ main(int argc, char *argv[])
+ if (!XGetWindowAttributes(dpy, parentwin, &wa))
+ die("could not get embedding window attributes: 0x%lx",
+ parentwin);
+- drw = drw_create(dpy, screen, root, wa.width, wa.height);
++ xinitvisual();
++ drw = drw_create(dpy, screen, root, wa.width, wa.height, visual, depth, cmap);
+ if (!drw_fontset_create(drw, fonts, LENGTH(fonts)))
+ die("no fonts could be loaded.");
+ lrpad = drw->fonts->h;
+@@ -793,3 +806,40 @@ main(int argc, char *argv[])
+
+ return 1; /* unreachable */
+ }
++
++void
++xinitvisual()
++{
++ XVisualInfo *infos;
++ XRenderPictFormat *fmt;
++ int nitems;
++ int i;
++
++ XVisualInfo tpl = {
++ .screen = screen,
++ .depth = 32,
++ .class = TrueColor
++ };
++ long masks = VisualScreenMask | VisualDepthMask | VisualClassMask;
++
++ infos = XGetVisualInfo(dpy, masks, &tpl, &nitems);
++ visual = NULL;
++ for(i = 0; i < nitems; i ++) {
++ fmt = XRenderFindVisualFormat(dpy, infos[i].visual);
++ if (fmt->type == PictTypeDirect && fmt->direct.alphaMask) {
++ visual = infos[i].visual;
++ depth = infos[i].depth;
++ cmap = XCreateColormap(dpy, root, visual, AllocNone);
++ useargb = 1;
++ break;
++ }
++ }
++
++ XFree(infos);
++
++ if (! visual) {
++ visual = DefaultVisual(dpy, screen);
++ depth = DefaultDepth(dpy, screen);
++ cmap = DefaultColormap(dpy, screen);
++ }
++}
+diff --git a/drw.c b/drw.c
+index a58a2b4..42700e5 100644
+--- a/drw.c
++++ b/drw.c
+@@ -61,7 +61,7 @@ utf8decode(const char *c, long *u, size_t clen)
+ }
+
+ Drw *
+-drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h)
++drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h, Visual *visual, unsigned int depth, Colormap cmap)
+ {
+ Drw *drw = ecalloc(1, sizeof(Drw));
+
+@@ -70,8 +70,11 @@ drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h
+ drw->root = root;
+ drw->w = w;
+ drw->h = h;
+- drw->drawable = XCreatePixmap(dpy, root, w, h, DefaultDepth(dpy, screen));
+- drw->gc = XCreateGC(dpy, root, 0, NULL);
++ drw->visual = visual;
++ drw->depth = depth;
++ drw->cmap = cmap;
++ drw->drawable = XCreatePixmap(dpy, root, w, h, depth);
++ drw->gc = XCreateGC(dpy, drw->drawable, 0, NULL);
+ XSetLineAttributes(dpy, drw->gc, 1, LineSolid, CapButt, JoinMiter);
+
+ return drw;
+@@ -87,7 +90,7 @@ drw_resize(Drw *drw, unsigned int w, unsigned int h)
+ drw->h = h;
+ if (drw->drawable)
+ XFreePixmap(drw->dpy, drw->drawable);
+- drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, DefaultDepth(drw->dpy, drw->screen));
++ drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, drw->depth);
+ }
+
+ void
+@@ -181,21 +184,22 @@ drw_fontset_free(Fnt *font)
+ }
+
+ void
+-drw_clr_create(Drw *drw, Clr *dest, const char *clrname)
++drw_clr_create(Drw *drw, Clr *dest, const char *clrname, unsigned int alpha)
+ {
+ if (!drw || !dest || !clrname)
+ return;
+
+- if (!XftColorAllocName(drw->dpy, DefaultVisual(drw->dpy, drw->screen),
+- DefaultColormap(drw->dpy, drw->screen),
++ if (!XftColorAllocName(drw->dpy, drw->visual, drw->cmap,
+ clrname, dest))
+ die("error, cannot allocate color '%s'", clrname);
++
++ dest->pixel = (dest->pixel & 0x00ffffffU) | (alpha << 24);
+ }
+
+ /* Wrapper to create color schemes. The caller has to call free(3) on the
+ * returned color scheme when done using it. */
+ Clr *
+-drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
++drw_scm_create(Drw *drw, const char *clrnames[], const unsigned int alphas[], size_t clrcount)
+ {
+ size_t i;
+ Clr *ret;
+@@ -205,7 +209,7 @@ drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
+ return NULL;
+
+ for (i = 0; i < clrcount; i++)
+- drw_clr_create(drw, &ret[i], clrnames[i]);
++ drw_clr_create(drw, &ret[i], clrnames[i], alphas[i]);
+ return ret;
+ }
+
+@@ -263,9 +267,7 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
+ } else {
+ XSetForeground(drw->dpy, drw->gc, drw->scheme[invert ? ColFg : ColBg].pixel);
+ XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
+- d = XftDrawCreate(drw->dpy, drw->drawable,
+- DefaultVisual(drw->dpy, drw->screen),
+- DefaultColormap(drw->dpy, drw->screen));
++ d = XftDrawCreate(drw->dpy, drw->drawable, drw->visual, drw->cmap);
+ x += lpad;
+ w -= lpad;
+ }
+diff --git a/drw.h b/drw.h
+index fd7631b..48f2f93 100644
+--- a/drw.h
++++ b/drw.h
+@@ -20,6 +20,9 @@ typedef struct {
+ Display *dpy;
+ int screen;
+ Window root;
++ Visual *visual;
++ unsigned int depth;
++ Colormap cmap;
+ Drawable drawable;
+ GC gc;
+ Clr *scheme;
+@@ -27,7 +30,7 @@ typedef struct {
+ } Drw;
+
+ /* Drawable abstraction */
+-Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h);
++Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h, Visual*, unsigned int, Colormap);
+ void drw_resize(Drw *drw, unsigned int w, unsigned int h);
+ void drw_free(Drw *drw);
+
+@@ -39,8 +42,8 @@ unsigned int drw_fontset_getwidth_clamp(Drw *drw, const char *text, unsigned int
+ void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h);
+
+ /* Colorscheme abstraction */
+-void drw_clr_create(Drw *drw, Clr *dest, const char *clrname);
+-Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount);
++void drw_clr_create(Drw *drw, Clr *dest, const char *clrname, unsigned int alpha);
++Clr *drw_scm_create(Drw *drw, const char *clrnames[], const unsigned int alphas[], size_t clrcount);
+
+ /* Cursor abstraction */
+ Cur *drw_cur_create(Drw *drw, int shape);
+--
+2.37.4
+
diff --git a/wm/dmenu-5.3/patches/dmenu-border-20230512-0fe460d.diff b/wm/dmenu-5.3/patches/dmenu-border-20230512-0fe460d.diff
new file mode 100644
index 0000000..f7a5971
--- /dev/null
+++ b/wm/dmenu-5.3/patches/dmenu-border-20230512-0fe460d.diff
@@ -0,0 +1,36 @@
+diff --git a/config.def.h b/config.def.h
+index 1edb647..dd3eb31 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -21,3 +21,6 @@ static unsigned int lines = 0;
+ * for example: " /?\"&[]"
+ */
+ static const char worddelimiters[] = " ";
++
++/* Size of the window border */
++static unsigned int border_width = 0;
+diff --git a/dmenu.c b/dmenu.c
+index 27b7a30..7c130fc 100644
+--- a/dmenu.c
++++ b/dmenu.c
+@@ -684,9 +684,11 @@ setup(void)
+ swa.override_redirect = True;
+ swa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
+ swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask;
+- win = XCreateWindow(dpy, root, x, y, mw, mh, 0,
++ win = XCreateWindow(dpy, root, x, y, mw, mh, border_width,
+ CopyFromParent, CopyFromParent, CopyFromParent,
+ CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
++ if (border_width)
++ XSetWindowBorder(dpy, win, scheme[SchemeSel][ColBg].pixel);
+ XSetClassHint(dpy, win, &ch);
+
+
+@@ -757,6 +759,8 @@ main(int argc, char *argv[])
+ colors[SchemeSel][ColFg] = argv[++i];
+ else if (!strcmp(argv[i], "-w")) /* embedding window id */
+ embed = argv[++i];
++ else if (!strcmp(argv[i], "-bw"))
++ border_width = atoi(argv[++i]); /* border width */
+ else
+ usage();
diff --git a/wm/dmenu-5.3/patches/dmenu-center-20250407-b1e217b.diff b/wm/dmenu-5.3/patches/dmenu-center-20250407-b1e217b.diff
new file mode 100644
index 0000000..a28efdb
--- /dev/null
+++ b/wm/dmenu-5.3/patches/dmenu-center-20250407-b1e217b.diff
@@ -0,0 +1,135 @@
+From 95a444534c230de79000348b0e12f8644aac8b15 Mon Sep 17 00:00:00 2001
+From: leliel <mail.leliel@proton.me>
+Date: Mon, 7 Apr 2025 01:00:01 +0000
+Subject: [PATCH] Increased speed for long files with emojis.
+
+---
+ config.def.h | 3 +++
+ dmenu.1 | 3 +++
+ dmenu.c | 40 ++++++++++++++++++++++++++++++++++------
+ 3 files changed, 40 insertions(+), 6 deletions(-)
+
+diff --git a/config.def.h b/config.def.h
+index 1edb647..832896f 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -2,6 +2,9 @@
+ /* Default settings; can be overriden by command line. */
+
+ static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */
++static int centered = 1; /* -c option; centers dmenu on screen */
++static int min_width = 500; /* minimum width when centered */
++static const float menu_height_ratio = 4.0f; /* This is the ratio used in the original calculation */
+ /* -fn option overrides fonts[0]; default X11 font or font set */
+ static const char *fonts[] = {
+ "monospace:size=10"
+diff --git a/dmenu.1 b/dmenu.1
+index 323f93c..c036baa 100644
+--- a/dmenu.1
++++ b/dmenu.1
+@@ -40,6 +40,9 @@ which lists programs in the user's $PATH and runs the result in their $SHELL.
+ .B \-b
+ dmenu appears at the bottom of the screen.
+ .TP
++.B \-c
++dmenu appears centered on the screen.
++.TP
+ .B \-f
+ dmenu grabs the keyboard before reading stdin if not reading from a tty. This
+ is faster, but will lock up X until stdin reaches end\-of\-file.
+diff --git a/dmenu.c b/dmenu.c
+index fd49549..ceb52c7 100644
+--- a/dmenu.c
++++ b/dmenu.c
+@@ -29,6 +29,7 @@ enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */
+
+ struct item {
+ char *text;
++ unsigned int width;
+ struct item *left, *right;
+ int out;
+ };
+@@ -95,6 +96,15 @@ calcoffsets(void)
+ break;
+ }
+
++static int
++max_textw(void)
++{
++ int len = 0;
++ for (struct item *item = items; item && item->text; item++)
++ len = MAX(item->width, len);
++ return len;
++}
++
+ static void
+ cleanup(void)
+ {
+@@ -563,6 +573,7 @@ readstdin(void)
+ line[len - 1] = '\0';
+ if (!(items[i].text = strdup(line)))
+ die("strdup:");
++ items[i].width = TEXTW(line);
+
+ items[i].out = 0;
+ }
+@@ -636,6 +647,7 @@ setup(void)
+ bh = drw->fonts->h + 2;
+ lines = MAX(lines, 0);
+ mh = (lines + 1) * bh;
++ promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
+ #ifdef XINERAMA
+ i = 0;
+ if (parentwin == root && (info = XineramaQueryScreens(dpy, &n))) {
+@@ -662,9 +674,16 @@ setup(void)
+ if (INTERSECT(x, y, 1, 1, info[i]) != 0)
+ break;
+
+- x = info[i].x_org;
+- y = info[i].y_org + (topbar ? 0 : info[i].height - mh);
+- mw = info[i].width;
++ if (centered) {
++ mw = MIN(MAX(max_textw() + promptw, min_width), info[i].width);
++ x = info[i].x_org + ((info[i].width - mw) / 2);
++ y = info[i].y_org + ((info[i].height - mh) / menu_height_ratio);
++ } else {
++ x = info[i].x_org;
++ y = info[i].y_org + (topbar ? 0 : info[i].height - mh);
++ mw = info[i].width;
++ }
++
+ XFree(info);
+ } else
+ #endif
+@@ -672,9 +691,16 @@ setup(void)
+ if (!XGetWindowAttributes(dpy, parentwin, &wa))
+ die("could not get embedding window attributes: 0x%lx",
+ parentwin);
+- x = 0;
+- y = topbar ? 0 : wa.height - mh;
+- mw = wa.width;
++
++ if (centered) {
++ mw = MIN(MAX(max_textw() + promptw, min_width), wa.width);
++ x = (wa.width - mw) / 2;
++ y = (wa.height - mh) / 2;
++ } else {
++ x = 0;
++ y = topbar ? 0 : wa.height - mh;
++ mw = wa.width;
++ }
+ }
+ promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
+ inputw = mw / 3; /* input width: ~33% of monitor width */
+@@ -733,6 +759,8 @@ main(int argc, char *argv[])
+ topbar = 0;
+ else if (!strcmp(argv[i], "-f")) /* grabs keyboard before reading stdin */
+ fast = 1;
++ else if (!strcmp(argv[i], "-c")) /* centers dmenu on screen */
++ centered = 1;
+ else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */
+ fstrncmp = strncasecmp;
+ fstrstr = cistrstr;
+--
+2.49.0
+
diff --git a/wm/dmenu-5.3/patches/dmenu-grid-4.9.diff b/wm/dmenu-5.3/patches/dmenu-grid-4.9.diff
new file mode 100644
index 0000000..c27689b
--- /dev/null
+++ b/wm/dmenu-5.3/patches/dmenu-grid-4.9.diff
@@ -0,0 +1,107 @@
+From 39ab9676914bd0d8105d0f96bbd7611a53077438 Mon Sep 17 00:00:00 2001
+From: Miles Alan <m@milesalan.com>
+Date: Sat, 4 Jul 2020 11:19:04 -0500
+Subject: [PATCH] Add -g option to display entries in the given number of grid
+ columns
+
+This option can be used in conjunction with -l to format dmenu's options in
+arbitrary size grids. For example, to create a 4 column by 6 line grid, you
+could use: dmenu -g 4 -l 6
+---
+ config.def.h | 3 ++-
+ dmenu.1 | 7 ++++++-
+ dmenu.c | 22 ++++++++++++++++------
+ 3 files changed, 24 insertions(+), 8 deletions(-)
+
+diff --git a/config.def.h b/config.def.h
+index 1edb647..96cf3c9 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -13,8 +13,9 @@ static const char *colors[SchemeLast][2] = {
+ [SchemeSel] = { "#eeeeee", "#005577" },
+ [SchemeOut] = { "#000000", "#00ffff" },
+ };
+-/* -l option; if nonzero, dmenu uses vertical list with given number of lines */
++/* -l and -g options; controls number of lines and columns in grid if > 0 */
+ static unsigned int lines = 0;
++static unsigned int columns = 0;
+
+ /*
+ * Characters not considered part of a word while deleting words
+diff --git a/dmenu.1 b/dmenu.1
+index 323f93c..d0a734a 100644
+--- a/dmenu.1
++++ b/dmenu.1
+@@ -4,6 +4,8 @@ dmenu \- dynamic menu
+ .SH SYNOPSIS
+ .B dmenu
+ .RB [ \-bfiv ]
++.RB [ \-g
++.IR columns ]
+ .RB [ \-l
+ .IR lines ]
+ .RB [ \-m
+@@ -47,8 +49,11 @@ is faster, but will lock up X until stdin reaches end\-of\-file.
+ .B \-i
+ dmenu matches menu items case insensitively.
+ .TP
++.BI \-g " columns"
++dmenu lists items in a grid with the given number of columns.
++.TP
+ .BI \-l " lines"
+-dmenu lists items vertically, with the given number of lines.
++dmenu lists items in a grid with the given number of lines.
+ .TP
+ .BI \-m " monitor"
+ dmenu is displayed on the monitor number supplied. Monitor numbers are starting
+diff --git a/dmenu.c b/dmenu.c
+index 6b8f51b..d79b6bb 100644
+--- a/dmenu.c
++++ b/dmenu.c
+@@ -77,7 +77,7 @@ calcoffsets(void)
+ int i, n;
+
+ if (lines > 0)
+- n = lines * bh;
++ n = lines * columns * bh;
+ else
+ n = mw - (promptw + inputw + TEXTW("<") + TEXTW(">"));
+ /* calculate which items will begin the next page and previous page */
+@@ -152,9 +152,15 @@ drawmenu(void)
+ }
+
+ if (lines > 0) {
+- /* draw vertical list */
+- for (item = curr; item != next; item = item->right)
+- drawitem(item, x, y += bh, mw - x);
++ /* draw grid */
++ int i = 0;
++ for (item = curr; item != next; item = item->right, i++)
++ drawitem(
++ item,
++ x + ((i / lines) * ((mw - x) / columns)),
++ y + (((i % lines) + 1) * bh),
++ (mw - x) / columns
++ );
+ } else if (matches) {
+ /* draw horizontal list */
+ x += inputw;
+@@ -708,9 +714,13 @@ main(int argc, char *argv[])
+ } else if (i + 1 == argc)
+ usage();
+ /* these options take one argument */
+- else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */
++ else if (!strcmp(argv[i], "-g")) { /* number of columns in grid */
++ columns = atoi(argv[++i]);
++ if (lines == 0) lines = 1;
++ } else if (!strcmp(argv[i], "-l")) { /* number of lines in grid */
+ lines = atoi(argv[++i]);
+- else if (!strcmp(argv[i], "-m"))
++ if (columns == 0) columns = 1;
++ } else if (!strcmp(argv[i], "-m"))
+ mon = atoi(argv[++i]);
+ else if (!strcmp(argv[i], "-p")) /* adds prompt to left of input field */
+ prompt = argv[++i];
+--
+2.23.1
+
diff --git a/wm/dmenu-5.3/patches/dmenu-lineheight-4.6.diff b/wm/dmenu-5.3/patches/dmenu-lineheight-4.6.diff
new file mode 100644
index 0000000..bb2a6bb
--- /dev/null
+++ b/wm/dmenu-5.3/patches/dmenu-lineheight-4.6.diff
@@ -0,0 +1,99 @@
+diff --git a/config.def.h b/config.def.h
+index a9122f7..6d936b7 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -15,3 +15,6 @@ static const char *outbgcolor = "#00ffff";
+ static const char *outfgcolor = "#000000";
+ /* -l option; if nonzero, dmenu uses vertical list with given number of lines */
+ static unsigned int lines = 0;
++
++static unsigned int lineheight = 0; /* -lh option; minimum height of a menu line */
++
+diff --git a/dmenu.1 b/dmenu.1
+index d3ab805..9fe4434 100644
+--- a/dmenu.1
++++ b/dmenu.1
+@@ -51,6 +51,9 @@ dmenu matches menu items case insensitively.
+ .BI \-l " lines"
+ dmenu lists items vertically, with the given number of lines.
+ .TP
++.BI \-lh " 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 a07f8e3..25832a7 100644
+--- a/dmenu.c
++++ b/dmenu.c
+@@ -119,7 +119,7 @@ drawmenu(void)
+ {
+ int curpos;
+ struct item *item;
+- int x = 0, y = 0, h = bh, w;
++ int x = 0, y = 0, fh = drw->fonts[0]->h, w;
+
+ drw_setscheme(drw, &scheme[SchemeNorm]);
+ drw_rect(drw, 0, 0, mw, mh, 1, 1, 1);
+@@ -134,16 +134,16 @@ drawmenu(void)
+ drw_setscheme(drw, &scheme[SchemeNorm]);
+ drw_text(drw, x, 0, w, bh, text, 0);
+
+- if ((curpos = TEXTNW(text, cursor) + bh / 2 - 2) < w) {
++ if ((curpos = TEXTNW(text, cursor) + fh / 2 - 2) < w) {
+ drw_setscheme(drw, &scheme[SchemeNorm]);
+- drw_rect(drw, x + curpos + 2, 2, 1, bh - 4, 1, 1, 0);
++ drw_rect(drw, x + curpos + 2, 2 + (bh-fh)/2, 1, fh - 4, 1, 1, 0);
+ }
+
+ if (lines > 0) {
+ /* draw vertical list */
+ w = mw - x;
+ for (item = curr; item != next; item = item->right) {
+- y += h;
++ y += bh;
+ if (item == sel)
+ drw_setscheme(drw, &scheme[SchemeSel]);
+ else if (item->out)
+@@ -544,6 +544,7 @@ setup(void)
+
+ /* calculate menu geometry */
+ bh = drw->fonts[0]->h + 2;
++ bh = MAX(bh,lineheight); /* make a menu line AT LEAST 'lineheight' tall */
+ lines = MAX(lines, 0);
+ mh = (lines + 1) * bh;
+ #ifdef XINERAMA
+@@ -608,7 +609,7 @@ setup(void)
+ static void
+ usage(void)
+ {
+- fputs("usage: dmenu [-b] [-f] [-i] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
++ fputs("usage: dmenu [-b] [-f] [-i] [-l lines] [-p prompt] [-fn font] [-lh height] [-m monitor]\n"
+ " [-nb color] [-nf color] [-sb color] [-sf color] [-v]\n", stderr);
+ exit(1);
+ }
+@@ -641,6 +642,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], "-lh")) { /* 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 */
+ normbgcolor = argv[++i];
+ else if (!strcmp(argv[i], "-nf")) /* normal foreground color */
+diff --git a/drw.c b/drw.c
+index 80e3c39..f4a741f 100644
+--- a/drw.c
++++ b/drw.c
+@@ -291,7 +291,7 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *tex
+ if (render) {
+ th = curfont->ascent + curfont->descent;
+ ty = y + (h / 2) - (th / 2) + curfont->ascent;
+- tx = x + (h / 2);
++ tx = x + (drw->fonts[0]->h / 2);
+ XftDrawStringUtf8(d, invert ? &drw->scheme->bg->rgb : &drw->scheme->fg->rgb, curfont->xfont, tx, ty, (XftChar8 *)buf, len);
+ }
+ x += tex.w;
diff --git a/wm/dmenu-5.3/patches/dmenu-lineheight-5.2.diff b/wm/dmenu-5.3/patches/dmenu-lineheight-5.2.diff
new file mode 100644
index 0000000..a5e8468
--- /dev/null
+++ b/wm/dmenu-5.3/patches/dmenu-lineheight-5.2.diff
@@ -0,0 +1,106 @@
+From ba103e38ea4ab07f9a3ee90627714b9bea17c329 Mon Sep 17 00:00:00 2001
+From: pskry <peter@skrypalle.dk>
+Date: Sun, 8 Nov 2020 22:04:22 +0100
+Subject: [PATCH] Add an option which defines the lineheight
+
+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.
+---
+ 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 1edb647..4394dec 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -15,6 +15,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 323f93c..f2a82b4 100644
+--- a/dmenu.1
++++ b/dmenu.1
+@@ -6,6 +6,8 @@ dmenu \- dynamic menu
+ .RB [ \-bfiv ]
+ .RB [ \-l
+ .IR lines ]
++.RB [ \-h
++.IR height ]
+ .RB [ \-m
+ .IR monitor ]
+ .RB [ \-p
+@@ -50,6 +52,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 e7be8af..82b204b 100644
+--- a/dmenu.c
++++ b/dmenu.c
+@@ -148,7 +148,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);
+@@ -165,7 +165,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) {
+@@ -630,6 +630,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
+@@ -710,7 +711,7 @@ setup(void)
+ static void
+ usage(void)
+ {
+- die("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
++ die("usage: dmenu [-bfiv] [-l lines] [-h height] [-p prompt] [-fn font] [-m monitor]\n"
+ " [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]");
+ }
+
+@@ -737,6 +738,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 */
+--
+2.38.1
+
diff --git a/wm/dmenu-5.3/patches/dmenu-xyw-5.2.diff b/wm/dmenu-5.3/patches/dmenu-xyw-5.2.diff
new file mode 100644
index 0000000..312fb26
--- /dev/null
+++ b/wm/dmenu-5.3/patches/dmenu-xyw-5.2.diff
@@ -0,0 +1,99 @@
+--- a/dmenu.1 2022-10-04 10:36:58.000000000 -0700
++++ b/dmenu.1 2024-03-23 19:40:27.116453289 -0700
+@@ -8,6 +8,12 @@
+ .IR lines ]
+ .RB [ \-m
+ .IR monitor ]
++.RB [ \-x
++.IR xoffset ]
++.RB [ \-y
++.IR yoffset ]
++.RB [ \-z
++.IR width ]
+ .RB [ \-p
+ .IR prompt ]
+ .RB [ \-fn
+@@ -54,6 +60,24 @@
+ dmenu is displayed on the monitor number supplied. Monitor numbers are starting
+ from 0.
+ .TP
++.BI \-x " xoffset"
++dmenu is placed at this offset measured from the left side of the monitor.
++Can be negative.
++If option
++.B \-m
++is present, the measurement will use the given monitor.
++.TP
++.BI \-y " yoffset"
++dmenu is placed at this offset measured from the top of the monitor. If the
++.B \-b
++option is used, the offset is measured from the bottom. Can be negative.
++If option
++.B \-m
++is present, the measurement will use the given monitor.
++.TP
++.BI \-z " width"
++sets the width of the dmenu window.
++.TP
+ .BI \-p " prompt"
+ defines the prompt to be displayed to the left of the input field.
+ .TP
+--- a/dmenu.c 2022-10-04 10:36:58.000000000 -0700
++++ b/dmenu.c 2024-03-23 19:39:53.173081139 -0700
+@@ -37,6 +37,9 @@
+ static char text[BUFSIZ] = "";
+ static char *embed;
+ static int bh, mw, mh;
++static int dmx = 0; /* put dmenu at this x offset */
++static int dmy = 0; /* put dmenu at this y offset (measured from the bottom if topbar is 0) */
++static unsigned int dmw = 0; /* make dmenu this wide */
+ static int inputw = 0, promptw;
+ static int lrpad; /* sum of left and right padding */
+ static size_t cursor;
+@@ -658,9 +661,9 @@
+ if (INTERSECT(x, y, 1, 1, info[i]) != 0)
+ break;
+
+- x = info[i].x_org;
+- y = info[i].y_org + (topbar ? 0 : info[i].height - mh);
+- mw = info[i].width;
++ x = info[i].x_org + dmx;
++ y = info[i].y_org + (topbar ? dmy : info[i].height - mh - dmy);
++ mw = (dmw>0 ? dmw : info[i].width);;
+ XFree(info);
+ } else
+ #endif
+@@ -668,9 +671,9 @@
+ if (!XGetWindowAttributes(dpy, parentwin, &wa))
+ die("could not get embedding window attributes: 0x%lx",
+ parentwin);
+- x = 0;
+- y = topbar ? 0 : wa.height - mh;
+- mw = wa.width;
++ x = dmx;
++ y = topbar ? dmy : wa.height - mh - dmy;
++ mw = (dmw>0 ? dmw : wa.width);
+ }
+ promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
+ inputw = mw / 3; /* input width: ~33% of monitor width */
+@@ -711,6 +714,7 @@
+ usage(void)
+ {
+ die("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
++ " [-x xoffset] [-y yoffset] [-z width]\n"
+ " [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]");
+ }
+
+@@ -737,6 +741,12 @@
+ /* 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], "-x")) /* window x offset */
++ dmx = atoi(argv[++i]);
++ else if (!strcmp(argv[i], "-y")) /* window y offset (from bottom up if -b) */
++ dmy = atoi(argv[++i]);
++ else if (!strcmp(argv[i], "-z")) /* make dmenu this wide */
++ dmw = atoi(argv[++i]);
+ else if (!strcmp(argv[i], "-m"))
+ mon = atoi(argv[++i]);
+ else if (!strcmp(argv[i], "-p")) /* adds prompt to left of input field */
diff --git a/wm/dmenu-5.2/stest.1 b/wm/dmenu-5.3/stest.1
index 2667d8a..2667d8a 100644
--- a/wm/dmenu-5.2/stest.1
+++ b/wm/dmenu-5.3/stest.1
diff --git a/wm/dmenu-5.2/stest.c b/wm/dmenu-5.3/stest.c
index e27d3a5..e27d3a5 100644
--- a/wm/dmenu-5.2/stest.c
+++ b/wm/dmenu-5.3/stest.c
diff --git a/wm/dmenu-5.2/util.c b/wm/dmenu-5.3/util.c
index 96b82c9..96b82c9 100644
--- a/wm/dmenu-5.2/util.c
+++ b/wm/dmenu-5.3/util.c
diff --git a/wm/dmenu-5.2/util.h b/wm/dmenu-5.3/util.h
index f633b51..c0a50d4 100644
--- a/wm/dmenu-5.2/util.h
+++ b/wm/dmenu-5.3/util.h
@@ -3,6 +3,7 @@
#define MAX(A, B) ((A) > (B) ? (A) : (B))
#define MIN(A, B) ((A) < (B) ? (A) : (B))
#define BETWEEN(X, A, B) ((A) <= (X) && (X) <= (B))
+#define LENGTH(X) (sizeof (X) / sizeof (X)[0])
void die(const char *fmt, ...);
void *ecalloc(size_t nmemb, size_t size);