Return to repo list

suckless-gf-dmenu

Gentoo-friendly patches for Suckless's dmenu.
Return to HMagellan.com

commit 853a2908d94977dc3199a4202f6c148be25dbd41
parent 1719ef85f72dcc8c1fe8b830c54f19030cb9a827
Author: Erik Letson <hmagellan@hmagellan.com>
Date:   Fri, 21 Aug 2020 14:07:11 -0500

Added managed

Diffstat:
MREADME | 2+-
Apatches/managed/USAGE | 28++++++++++++++++++++++++++++
Apatches/managed/managed-nodoc.patch | 62++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apatches/managed/managed.patch | 95+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 186 insertions(+), 1 deletion(-)

diff --git a/README b/README @@ -42,7 +42,7 @@ patches! (1). https://tools.suckless.org/dmenu/patches/ - CURRENT PROGRESS: 10/32 patches supported + CURRENT PROGRESS: 11/32 patches supported 3/32 patches unsupported USUPPORTED PATCHES: diff --git a/patches/managed/USAGE b/patches/managed/USAGE @@ -0,0 +1,28 @@ +managed - Let dmenu be managed by the window manager with the -wm option +Source: https://tools.suckless.org/dmenu/patches/managed/dmenu-managed-4.9.diff +Original Author: Miles Alan m@milesalan.com + +Description from source: + """ + Adds a -wm flag which sets override_redirect to false; thus letting your window manager manage the + dmenu window. + + This may be helpful in contexts where you don't want to exclusively bind dmenu or want to treat dmenu + more as a 'window' rather than as an overlay. + """ + +== YOU MUST == +(1). Place the patch file in /etc/portage/patches/x11-misc/dmenu/ and run 'emerge dmenu' + +== YOU PROBABLY SHOULD == +(1). Run dmenu with the '-wm' option to let it be managed just like a regular window + +== PATCH MODIFICATIONS == +(1). Removed all changes made to 'config.def.h' +(2). Modified Chunk #4 of the 'dwm.c' changes to reflect the 4.8 codebase +(2). Added a 'nodoc' patch version which strips out added documentation + +== INCOMPATIBILITIES == +THIS PATCH MAKES CHANGES TO DMENU'S BUILT-IN DOCUMENTATION, WHICH CAN CAUSE CONFLICTS WITH OTHER PATCHES! +If you encounter such conflicts, try emerging with the 'managed-nodoc.patch' file instead. It is the +same as the 'managed.patch' file except it makes no changes to the documentation. diff --git a/patches/managed/managed-nodoc.patch b/patches/managed/managed-nodoc.patch @@ -0,0 +1,62 @@ +diff --git a/dmenu.c b/dmenu.c +index 6b8f51b..4632eb4 100644 +--- a/dmenu.c ++++ b/dmenu.c +@@ -44,6 +44,7 @@ static struct item *items = NULL; + static struct item *matches, *matchend; + static struct item *prev, *curr, *next, *sel; + static int mon = -1, screen; ++static int managed = 0; + + static Atom clip, utf8; + static Display *dpy; +@@ -198,7 +199,7 @@ grabkeyboard(void) + struct timespec ts = { .tv_sec = 0, .tv_nsec = 1000000 }; + int i; + +- if (embed) ++ if (embed || managed) + return; + /* try to grab keyboard, we may have to wait for another process to ungrab */ + for (i = 0; i < 1000; i++) { +@@ -651,7 +652,7 @@ setup(void) + match(); + + /* create menu window */ +- swa.override_redirect = True; ++ swa.override_redirect = managed ? False : True; + swa.background_pixel = scheme[SchemeNorm][ColBg].pixel; + swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask; + win = XCreateWindow(dpy, parentwin, x, y, mw, mh, 0, +@@ -665,7 +666,19 @@ setup(void) + XNClientWindow, win, XNFocusWindow, win, NULL); + + XMapRaised(dpy, win); ++ ++ if (managed) { ++ XTextProperty prop; ++ char *windowtitle = prompt != NULL ? prompt : "dmenu"; ++ Xutf8TextListToTextProperty(dpy, &windowtitle, 1, XUTF8StringStyle, &prop); ++ XSetWMName(dpy, win, &prop); ++ XSetTextProperty(dpy, win, &prop, XInternAtom(dpy, "_NET_WM_NAME", False)); ++ XFree(prop.value); ++ } else { ++ XSetInputFocus(dpy, win, RevertToParent, CurrentTime); ++ } ++ + if (embed) { + XSelectInput(dpy, parentwin, FocusChangeMask); + if (XQueryTree(dpy, parentwin, &dw, &w, &dws, &du) && dws) { + for (i = 0; i < du && dws[i] != win; ++i) +@@ -705,6 +717,8 @@ main(int argc, char *argv[]) + else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */ + fstrncmp = strncasecmp; + fstrstr = cistrstr; ++ } else if (!strcmp(argv[i], "-wm")) { /* display as managed wm window */ ++ managed = 1; + } else if (i + 1 == argc) + usage(); + /* these options take one argument */ +-- +2.27.0 + diff --git a/patches/managed/managed.patch b/patches/managed/managed.patch @@ -0,0 +1,95 @@ +From 5aee7d1488354322462e243416e27e026d73e0eb Mon Sep 17 00:00:00 2001 +From: Miles Alan <m@milesalan.com> +Date: Tue, 16 Jun 2020 21:40:30 -0500 +Subject: [PATCH] Add -wm flag to run dmenu as managed WM window (e.g. no + override_redirect) + +--- + dmenu.1 | 4 ++++ + dmenu.c | 20 +++++++++++++++++--- + 2 files changed, 21 insertions(+), 3 deletions(-) + +diff --git a/dmenu.1 b/dmenu.1 +index 323f93c..89a9493 100644 +--- a/dmenu.1 ++++ b/dmenu.1 +@@ -22,6 +22,7 @@ dmenu \- dynamic menu + .IR color ] + .RB [ \-w + .IR windowid ] ++.RB [ \-wm ] + .P + .BR dmenu_run " ..." + .SH DESCRIPTION +@@ -80,6 +81,9 @@ prints version information to stdout, then exits. + .TP + .BI \-w " windowid" + embed into windowid. ++.TP ++.BI \-wm ++Display as a managed WM window (e.g. don't set overide_redirect flag) + .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 6b8f51b..4632eb4 100644 +--- a/dmenu.c ++++ b/dmenu.c +@@ -44,6 +44,7 @@ static struct item *items = NULL; + static struct item *matches, *matchend; + static struct item *prev, *curr, *next, *sel; + static int mon = -1, screen; ++static int managed = 0; + + static Atom clip, utf8; + static Display *dpy; +@@ -198,7 +199,7 @@ grabkeyboard(void) + struct timespec ts = { .tv_sec = 0, .tv_nsec = 1000000 }; + int i; + +- if (embed) ++ if (embed || managed) + return; + /* try to grab keyboard, we may have to wait for another process to ungrab */ + for (i = 0; i < 1000; i++) { +@@ -651,7 +652,7 @@ setup(void) + match(); + + /* create menu window */ +- swa.override_redirect = True; ++ swa.override_redirect = managed ? False : True; + swa.background_pixel = scheme[SchemeNorm][ColBg].pixel; + swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask; + win = XCreateWindow(dpy, parentwin, x, y, mw, mh, 0, +@@ -665,7 +666,19 @@ setup(void) + XNClientWindow, win, XNFocusWindow, win, NULL); + + XMapRaised(dpy, win); ++ ++ if (managed) { ++ XTextProperty prop; ++ char *windowtitle = prompt != NULL ? prompt : "dmenu"; ++ Xutf8TextListToTextProperty(dpy, &windowtitle, 1, XUTF8StringStyle, &prop); ++ XSetWMName(dpy, win, &prop); ++ XSetTextProperty(dpy, win, &prop, XInternAtom(dpy, "_NET_WM_NAME", False)); ++ XFree(prop.value); ++ } else { ++ XSetInputFocus(dpy, win, RevertToParent, CurrentTime); ++ } ++ + if (embed) { + XSelectInput(dpy, parentwin, FocusChangeMask); + if (XQueryTree(dpy, parentwin, &dw, &w, &dws, &du) && dws) { + for (i = 0; i < du && dws[i] != win; ++i) +@@ -705,6 +717,8 @@ main(int argc, char *argv[]) + else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */ + fstrncmp = strncasecmp; + fstrstr = cistrstr; ++ } else if (!strcmp(argv[i], "-wm")) { /* display as managed wm window */ ++ managed = 1; + } else if (i + 1 == argc) + usage(); + /* these options take one argument */ +-- +2.27.0 +