aboutsummaryrefslogtreecommitdiff
path: root/patches
diff options
context:
space:
mode:
Diffstat (limited to 'patches')
-rw-r--r--patches/dmenu-border-20230512-0fe460d.diff36
-rw-r--r--patches/dmenu-center-20200111-8cd37e1.diff120
-rw-r--r--patches/dmenu-fix-vertical-nav.diff25
-rw-r--r--patches/dmenu-xresources-4.9.diff126
4 files changed, 307 insertions, 0 deletions
diff --git a/patches/dmenu-border-20230512-0fe460d.diff b/patches/dmenu-border-20230512-0fe460d.diff
new file mode 100644
index 0000000..f7a5971
--- /dev/null
+++ b/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/patches/dmenu-center-20200111-8cd37e1.diff b/patches/dmenu-center-20200111-8cd37e1.diff
new file mode 100644
index 0000000..af249a6
--- /dev/null
+++ b/patches/dmenu-center-20200111-8cd37e1.diff
@@ -0,0 +1,120 @@
+From 8cd37e1ab9e7cb025224aeb3543f1a5be8bceb93 Mon Sep 17 00:00:00 2001
+From: Nihal Jere <nihal@nihaljere.xyz>
+Date: Sat, 11 Jan 2020 21:16:08 -0600
+Subject: [PATCH] center patch now has adjustable minimum width
+
+---
+ config.def.h | 2 ++
+ dmenu.1 | 3 +++
+ dmenu.c | 39 ++++++++++++++++++++++++++++++++-------
+ 3 files changed, 37 insertions(+), 7 deletions(-)
+
+diff --git a/config.def.h b/config.def.h
+index 1edb647..88ef264 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -2,6 +2,8 @@
+ /* Default settings; can be overriden by command line. */
+
+ static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */
++static int centered = 0; /* -c option; centers dmenu on screen */
++static int min_width = 500; /* minimum width when centered */
+ /* -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 65f25ce..041c7f8 100644
+--- a/dmenu.c
++++ b/dmenu.c
+@@ -89,6 +89,15 @@ calcoffsets(void)
+ break;
+ }
+
++static int
++max_textw(void)
++{
++ int len = 0;
++ for (struct item *item = items; item && item->text; item++)
++ len = MAX(TEXTW(item->text), len);
++ return len;
++}
++
+ static void
+ cleanup(void)
+ {
+@@ -611,6 +620,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))) {
+@@ -637,9 +647,16 @@ setup(void)
+ if (INTERSECT(x, y, 1, 1, info[i]))
+ 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) / 2);
++ } 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
+@@ -647,11 +664,17 @@ 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 = MIN(inputw, mw/3);
+ match();
+
+@@ -709,6 +732,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.24.1
+
diff --git a/patches/dmenu-fix-vertical-nav.diff b/patches/dmenu-fix-vertical-nav.diff
new file mode 100644
index 0000000..323870a
--- /dev/null
+++ b/patches/dmenu-fix-vertical-nav.diff
@@ -0,0 +1,25 @@
+*** dmenu.c 2023-11-25 22:27:02.258247350 -0500
+--- dmenu2.c 2023-11-25 22:28:50.393973846 -0500
+*************** keypress(XKeyEvent *ev)
+*** 416,425 ****
+ goto draw;
+ case XK_g: ksym = XK_Home; break;
+ case XK_G: ksym = XK_End; break;
+! case XK_h: ksym = XK_Up; break;
+! case XK_j: ksym = XK_Next; break;
+! case XK_k: ksym = XK_Prior; break;
+! case XK_l: ksym = XK_Down; break;
+ default:
+ return;
+ }
+--- 416,425 ----
+ goto draw;
+ case XK_g: ksym = XK_Home; break;
+ case XK_G: ksym = XK_End; break;
+! case XK_h: ksym = XK_Prior; break;
+! case XK_j: ksym = XK_Down; break;
+! case XK_k: ksym = XK_Up; break;
+! case XK_l: ksym = XK_Next; break;
+ default:
+ return;
+ }
diff --git a/patches/dmenu-xresources-4.9.diff b/patches/dmenu-xresources-4.9.diff
new file mode 100644
index 0000000..267fb0a
--- /dev/null
+++ b/patches/dmenu-xresources-4.9.diff
@@ -0,0 +1,126 @@
+diff '--color=auto' -up ../dmenu-4.9/dmenu.c ./dmenu.c
+--- ../dmenu-4.9/dmenu.c 2019-02-02 13:55:02.000000000 +0100
++++ ./dmenu.c 2020-05-24 00:27:58.038586112 +0200
+@@ -15,6 +15,7 @@
+ #include <X11/extensions/Xinerama.h>
+ #endif
+ #include <X11/Xft/Xft.h>
++#include <X11/Xresource.h>
+
+ #include "drw.h"
+ #include "util.h"
+@@ -53,6 +54,10 @@ static XIC xic;
+ static Drw *drw;
+ static Clr *scheme[SchemeLast];
+
++/* Temporary arrays to allow overriding xresources values */
++static char *colortemp[4];
++static char *tempfonts;
++
+ #include "config.h"
+
+ static int (*fstrncmp)(const char *, const char *, size_t) = strncmp;
+@@ -596,8 +601,13 @@ setup(void)
+ int a, di, n, area = 0;
+ #endif
+ /* init appearance */
+- for (j = 0; j < SchemeLast; j++)
+- scheme[j] = drw_scm_create(drw, colors[j], 2);
++ for (j = 0; j < SchemeLast; j++) {
++ scheme[j] = drw_scm_create(drw, (const char**)colors[j], 2);
++ }
++ for (j = 0; j < SchemeOut; ++j) {
++ for (i = 0; i < 2; ++i)
++ free(colors[j][i]);
++ }
+
+ clip = XInternAtom(dpy, "CLIPBOARD", False);
+ utf8 = XInternAtom(dpy, "UTF8_STRING", False);
+@@ -687,6 +697,41 @@ usage(void)
+ exit(1);
+ }
+
++void
++readxresources(void) {
++ XrmInitialize();
++
++ char* xrm;
++ if ((xrm = XResourceManagerString(drw->dpy))) {
++ char *type;
++ XrmDatabase xdb = XrmGetStringDatabase(xrm);
++ XrmValue xval;
++
++ if (XrmGetResource(xdb, "dmenu.font", "*", &type, &xval))
++ fonts[0] = strdup(xval.addr);
++ else
++ fonts[0] = strdup(fonts[0]);
++ if (XrmGetResource(xdb, "dmenu.background", "*", &type, &xval))
++ colors[SchemeNorm][ColBg] = strdup(xval.addr);
++ else
++ colors[SchemeNorm][ColBg] = strdup(colors[SchemeNorm][ColBg]);
++ if (XrmGetResource(xdb, "dmenu.foreground", "*", &type, &xval))
++ colors[SchemeNorm][ColFg] = strdup(xval.addr);
++ else
++ colors[SchemeNorm][ColFg] = strdup(colors[SchemeNorm][ColFg]);
++ if (XrmGetResource(xdb, "dmenu.selbackground", "*", &type, &xval))
++ colors[SchemeSel][ColBg] = strdup(xval.addr);
++ else
++ colors[SchemeSel][ColBg] = strdup(colors[SchemeSel][ColBg]);
++ if (XrmGetResource(xdb, "dmenu.selforeground", "*", &type, &xval))
++ colors[SchemeSel][ColFg] = strdup(xval.addr);
++ else
++ colors[SchemeSel][ColFg] = strdup(colors[SchemeSel][ColFg]);
++
++ XrmDestroyDatabase(xdb);
++ }
++}
++
+ int
+ main(int argc, char *argv[])
+ {
+@@ -715,15 +760,15 @@ main(int argc, char *argv[])
+ 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];
++ tempfonts = argv[++i];
+ else if (!strcmp(argv[i], "-nb")) /* normal background color */
+- colors[SchemeNorm][ColBg] = argv[++i];
++ colortemp[0] = argv[++i];
+ else if (!strcmp(argv[i], "-nf")) /* normal foreground color */
+- colors[SchemeNorm][ColFg] = argv[++i];
++ colortemp[1] = argv[++i];
+ else if (!strcmp(argv[i], "-sb")) /* selected background color */
+- colors[SchemeSel][ColBg] = argv[++i];
++ colortemp[2] = argv[++i];
+ else if (!strcmp(argv[i], "-sf")) /* selected foreground color */
+- colors[SchemeSel][ColFg] = argv[++i];
++ colortemp[3] = argv[++i];
+ else if (!strcmp(argv[i], "-w")) /* embedding window id */
+ embed = argv[++i];
+ else
+@@ -743,8 +788,23 @@ main(int argc, char *argv[])
+ die("could not get embedding window attributes: 0x%lx",
+ parentwin);
+ drw = drw_create(dpy, screen, root, wa.width, wa.height);
+- if (!drw_fontset_create(drw, fonts, LENGTH(fonts)))
++ readxresources();
++ /* Now we check whether to override xresources with commandline parameters */
++ if ( tempfonts )
++ fonts[0] = strdup(tempfonts);
++ if ( colortemp[0])
++ colors[SchemeNorm][ColBg] = strdup(colortemp[0]);
++ if ( colortemp[1])
++ colors[SchemeNorm][ColFg] = strdup(colortemp[1]);
++ if ( colortemp[2])
++ colors[SchemeSel][ColBg] = strdup(colortemp[2]);
++ if ( colortemp[3])
++ colors[SchemeSel][ColFg] = strdup(colortemp[3]);
++
++ if (!drw_fontset_create(drw, (const char**)fonts, LENGTH(fonts)))
+ die("no fonts could be loaded.");
++
++ free(fonts[0]);
+ lrpad = drw->fonts->h;
+
+ #ifdef __OpenBSD__