From 588bc3e0b38875f07aa7e636dd3d44572f2ec608 Mon Sep 17 00:00:00 2001
From: 0x1bi <ben@0x1bi.net>
Date: Fri, 7 Feb 2020 22:03:37 -0500
Subject: [PATCH] added border to dmenu

---
 config.def.h | 3 +++
 dmenu.1      | 5 +++++
 dmenu.c      | 8 ++++++--
 3 files changed, 14 insertions(+), 2 deletions(-)

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.1 b/dmenu.1
index 323f93c..0484700 100644
--- a/dmenu.1
+++ b/dmenu.1
@@ -22,6 +22,8 @@ dmenu \- dynamic menu
 .IR color ]
 .RB [ \-w
 .IR windowid ]
+.RB [ \-bw
+.IR width ]
 .P
 .BR dmenu_run " ..."
 .SH DESCRIPTION
@@ -80,6 +82,9 @@ prints version information to stdout, then exits.
 .TP
 .BI \-w " windowid"
 embed into windowid.
+.TP
+.BI \-bw " width"
+defines border width around dmenu window.
 .SH USAGE
 dmenu is completely controlled by the keyboard.  Items are selected using the
 arrow keys, page up, page down, home, and end.
diff --git a/dmenu.c b/dmenu.c
index 65f25ce..3e1c70c 100644
--- a/dmenu.c
+++ b/dmenu.c
@@ -659,9 +659,11 @@ setup(void)
 	swa.override_redirect = True;
 	swa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
 	swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask;
-	win = XCreateWindow(dpy, parentwin, x, y, mw, mh, 0,
+	win = XCreateWindow(dpy, parentwin, 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);
 
 
@@ -690,7 +692,7 @@ static void
 usage(void)
 {
 	fputs("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
-	      "             [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]\n", stderr);
+	      "             [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid] [-bw width]\n", stderr);
 	exit(1);
 }
 
@@ -733,6 +735,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 around dmenu */
+			border_width = atoi(argv[++i]);
 		else
 			usage();
 
-- 
2.24.1

