XtCreatePopupShell silently ignores the XtNcolormap arg and inherits it
from the parent instead. Because dtwm creates the top-level popup shells
as children of wmGD.topLevelW and wmGD.topLevelW1, which are on the
default screen (normally 0) causes the X server to reject the
CreateWindow with BadMatch because the inherited colourmap does not
match the visual.

To fix this, we need to set the correct colourmap using XtSetValues
after creation.

This patch fixes Bug #164.
>From 9955343081c36facbd085bb17638912a365476dd Mon Sep 17 00:00:00 2001
From: Dark Ayron <[email protected]>
Date: Tue, 26 May 2026 23:32:36 +0000
Subject: [PATCH] dtwm: fix menus on screens other than 0

XtCreatePopupShell silently ignores the XtNcolormap arg and inherits it
from the parent instead. Because dtwm creates the top-level popup shells
as children of wmGD.topLevelW and wmGD.topLevelW1, which are on the
default screen (normally 0) causes the X server to reject the
CreateWindow with BadMatch because the inherited colourmap does not
match the visual.

To fix this, we need to set the correct colourmap using XtSetValues
after creation.
---
 cde/programs/dtwm/WmInitWs.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/cde/programs/dtwm/WmInitWs.c b/cde/programs/dtwm/WmInitWs.c
index bd27e3f42..ca1b43ecd 100644
--- a/cde/programs/dtwm/WmInitWs.c
+++ b/cde/programs/dtwm/WmInitWs.c
@@ -1330,6 +1330,18 @@ InitWmScreen (WmScreenData *pSD, int sNum)
 					       args,
 					       argnum);
 
+    /*
+     * Force the screen-specific colormap on the popup shell. When this
+     * shell's X parent (wmGD.topLevelW) lives on a different screen, Xt's
+     * VendorShell silently inherits the parent's colormap and ignores the
+     * XtNcolormap arg, which then causes BadMatch on every CreateWindow
+     * targeting a non-default screen.
+     */
+    argnum = 0;
+    XtSetArg (args[argnum], XtNcolormap,
+	    DefaultColormap(DISPLAY, sNum));	argnum++;
+    XtSetValues (pSD->screenTopLevelW, args, argnum);
+
     argnum = 0;
     XtSetArg (args[argnum], XtNgeometry, NULL);			argnum++;
     XtSetArg (args[argnum], XtNx, 10000);			argnum++;
@@ -1351,6 +1363,12 @@ InitWmScreen (WmScreenData *pSD, int sNum)
 					       wmGD.topLevelW1,
 					       args,
 					       argnum);
+
+    argnum = 0;
+    XtSetArg (args[argnum], XtNcolormap,
+	    DefaultColormap(DISPLAY1, sNum));	argnum++;
+    XtSetValues (pSD->screenTopLevelW1, args, argnum);
+
     XtRealizeWidget (pSD->screenTopLevelW1);
 
     /*
@@ -1517,6 +1535,12 @@ void InitWmWorkspace (WmWorkspaceData *pWS, WmScreenData *pSD)
 					   	args,
 						argnum);
 
+    /* Same colormap-inheritance workaround as for screenTopLevelW. */
+    argnum = 0;
+    XtSetArg (args[argnum], XtNcolormap,
+	    DefaultColormap(DISPLAY, pSD->screen));	argnum++;
+    XtSetValues (pWS->workspaceTopLevelW, args, argnum);
+
     /* internalize the workspace name */
     pWS->id = XInternAtom (DISPLAY, pWS->name, False);
 
-- 
2.53.0

_______________________________________________
cdesktopenv-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cdesktopenv-devel

Reply via email to