+// NB: argc and argv may be changed here, pass by reference!
+int wxEntryStart( int& argc, char *argv[] )
+{
+#ifdef __WXDEBUG__
+#if !wxUSE_NANOX
+ // install the X error handler
+ gs_pfnXErrorHandler = XSetErrorHandler( wxXErrorHandler );
+#endif
+#endif // __WXDEBUG__
+
+ wxString displayName;
+ bool syncDisplay = FALSE;
+
+ // Parse the arguments.
+ // We can't use wxCmdLineParser or OnInitCmdLine and friends because
+ // we have to create the Display earlier. If we can find a way to
+ // use the wxAppBase API then I'll be quite happy to change it.
+ g_newArgv = new wxChar*[argc];
+ g_newArgc = 0;
+ int i;
+ for (i = 0; i < argc; i++)
+ {
+ wxString arg(argv[i]);
+ if (arg == wxT("-display"))
+ {
+ if (i < (argc - 1))
+ {
+ i ++;
+ displayName = argv[i];
+ continue;
+ }
+ }
+ else if (arg == wxT("-geometry"))
+ {
+ if (i < (argc - 1))
+ {
+ i ++;
+ wxString windowGeometry = argv[i];
+ int w, h;
+ if (wxSscanf(windowGeometry.c_str(), _T("%dx%d"), &w, &h) != 2)
+ {
+ wxLogError(_("Invalid geometry specification '%s'"), windowGeometry.c_str());
+ }
+ else
+ {
+ g_initialSize = wxSize(w, h);
+ }
+ continue;
+ }
+ }
+ else if (arg == wxT("-sync"))
+ {
+ syncDisplay = TRUE;
+ continue;
+ }
+ else if (arg == wxT("-iconic"))
+ {
+ g_showIconic = TRUE;
+
+ continue;
+ }
+
+ // Not eaten by wxWindows, so pass through
+ g_newArgv[g_newArgc] = argv[i];
+ g_newArgc ++;
+ }
+
+ Display* xdisplay = NULL;
+ if (displayName.IsEmpty())
+ xdisplay = XOpenDisplay(NULL);
+ else
+ xdisplay = XOpenDisplay((char*) displayName.c_str());
+
+ if (!xdisplay)
+ {
+ wxLogError( _("wxWindows could not open display. Exiting.") );
+ return -1;
+ }
+
+ if (syncDisplay)
+ {
+ XSynchronize(xdisplay, True);
+ }
+
+ wxApp::ms_display = (WXDisplay*) xdisplay;
+
+ XSelectInput( xdisplay, XDefaultRootWindow(xdisplay), PropertyChangeMask);
+
+ wxSetDetectableAutoRepeat( TRUE );
+
+ if (!wxApp::Initialize())
+ return -1;
+
+ return 0;
+}
+
+int wxEntryInitGui()
+{
+ int retValue = 0;
+
+ if ( !wxTheApp->OnInitGui() )
+ retValue = -1;
+
+ return retValue;
+}
+
+