The phenomenon of seeing the wrong colors in a window because another X11 colormap is installed in the hardware is called false color.
The best way to avoid false color is to use a TrueColor visual. Since all 32 bits are available for TrueColor visuals, the colors always show up correctly. The SX hardware renders 24-bit visuals with the same speed as it renders 8-bit visuals, so there is no performance penalty when using 24-bit visuals.
In 32-bit mode the StaticGray visual has its own dedicated hardware color lookup table (actually a linear ramp). Hence StaticGray windows in 32-bit mode will never cause other 8-bit windows to appear incorrectly.