fix BadMatch error when embedding on some windows
commit0fe460dbd469a1d5b6a7140d0e1801935e4a923b
authorLucas de Sena <lucas@seninha.org>
Wed, 5 Apr 2023 20:11:49 +0000 (5 17:11 -0300)
committerHiltjo Posthuma <hiltjo@codemadness.org>
Thu, 6 Apr 2023 18:28:56 +0000 (6 20:28 +0200)
tree20b7ee5c3d537d996b2682125edb10c7e7ea2d5e
parentdfbbf7f6e1b22ccf9e5a45d77ee10995577fb4fc
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
dmenu.c