dmenu

My custom build of dmenu.
git clone https://git.mtkn.jp/dmenu
Log | Files | Refs | README | LICENSE

commit 0fe460dbd469a1d5b6a7140d0e1801935e4a923b
parent dfbbf7f6e1b22ccf9e5a45d77ee10995577fb4fc
Author: Lucas de Sena <lucas@seninha.org>
Date:   Wed,  5 Apr 2023 17:11:49 -0300

fix BadMatch error when embedding on some windows

When embedded into another window, dmenu will fail with the BadMatch
error if that window have not the same colormap/depth/visual as the
root window.

That happens because dmenu inherits the colormap/depth/visual from
its parent, but draws on a pixmap created based on the root window
using a GC created for the root window (see drw.c).  A BadMatch will
occur when copying the content of the pixmap into dmenu's window.

A solution is to create dmenu's window inside root and then reparent
it if embeded.

See this mail[1] on ports@openbsd.org mailing list for context.

[1]: https://marc.info/?l=openbsd-ports&m=168072150814664&w=2

Diffstat:
Mdmenu.c | 3++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/dmenu.c b/dmenu.c @@ -685,7 +685,7 @@ 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, root, x, y, mw, mh, 0, CopyFromParent, CopyFromParent, CopyFromParent, CWOverrideRedirect | CWBackPixel | CWEventMask, &swa); XSetClassHint(dpy, win, &ch); @@ -700,6 +700,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)