- // Get info about the current visual. It is enough
- // to do this once here unless we support different
- // visuals, displays and screens. Given that wxX11
- // mostly for embedded things, that is no real
- // limitation.
- Display *xdisplay = (Display*) wxApp::GetDisplay();
- int xscreen = DefaultScreen(xdisplay);
- Visual* xvisual = DefaultVisual(xdisplay,xscreen);
- int xdepth = DefaultDepth(xdisplay, xscreen);
-
- XVisualInfo vinfo_template;
- vinfo_template.visual = xvisual;
- vinfo_template.visualid = XVisualIDFromVisual( xvisual );
- vinfo_template.depth = xdepth;
-
- int nitem = 0;
- XVisualInfo *vi = XGetVisualInfo( xdisplay, VisualIDMask|VisualDepthMask, &vinfo_template, &nitem );
- wxASSERT_MSG( vi, wxT("No visual info") );
-
- m_visualType = vi->visual->c_class;
- m_visualScreen = vi->screen;
-
- m_visualRedMask = vi->red_mask;
- m_visualGreenMask = vi->green_mask;
- m_visualBlueMask = vi->blue_mask;
-
- if (m_visualType != GrayScale && m_visualType != PseudoColor)
- {
- wxCalcPrecAndShift( m_visualRedMask, &m_visualRedShift, &m_visualRedPrec );
- wxCalcPrecAndShift( m_visualGreenMask, &m_visualGreenShift, &m_visualGreenPrec );
- wxCalcPrecAndShift( m_visualBlueMask, &m_visualBlueShift, &m_visualBluePrec );
- }
-
- m_visualDepth = xdepth;
- if (xdepth == 16)
- xdepth = m_visualRedPrec + m_visualGreenPrec + m_visualBluePrec;
-
- m_visualColormapSize = vi->colormap_size;
-
- XFree( vi );
-
- if (m_visualDepth > 8)
- return TRUE;
-
- m_visualColormap = new XColor[m_visualColormapSize];
- XColor* colors = (XColor*) m_visualColormap;