Skip to content

Commit 0fe460d

Browse files
phillbushhiltjo
authored andcommitted
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
1 parent dfbbf7f commit 0fe460d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

dmenu.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ setup(void)
685685
swa.override_redirect = True;
686686
swa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
687687
swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask;
688-
win = XCreateWindow(dpy, parentwin, x, y, mw, mh, 0,
688+
win = XCreateWindow(dpy, root, x, y, mw, mh, 0,
689689
CopyFromParent, CopyFromParent, CopyFromParent,
690690
CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
691691
XSetClassHint(dpy, win, &ch);
@@ -700,6 +700,7 @@ setup(void)
700700

701701
XMapRaised(dpy, win);
702702
if (embed) {
703+
XReparentWindow(dpy, win, parentwin, x, y);
703704
XSelectInput(dpy, parentwin, FocusChangeMask | SubstructureNotifyMask);
704705
if (XQueryTree(dpy, parentwin, &dw, &w, &dws, &du) && dws) {
705706
for (i = 0; i < du && dws[i] != win; ++i)

0 commit comments

Comments
 (0)