- // TODO: parse argv and get display to pass to XOpenDisplay
- Display* dpy = XOpenDisplay(NULL);
- m_initialDisplay = (WXDisplay*) dpy;
-
- if (!dpy) {
- wxString className(wxTheApp->GetClassName());
- wxLogError(_("wxWindows could not open display for '%s': exiting."),
- (const char*) className);
- exit(-1);
+ // Eventually this line will be removed, but for
+ // now we don't want to try popping up a dialog
+ // for error messages.
+ delete wxLog::SetActiveTarget(new wxLogStderr);
+
+ if (!wxAppBase::OnInitGui())
+ return FALSE;
+
+ GetMainColormap( wxApp::GetDisplay() );
+
+ m_maxRequestSize = XMaxRequestSize( (Display*) wxApp::GetDisplay() );
+
+#if !wxUSE_NANOX
+ // 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 );