+IMPLEMENT_DYNAMIC_CLASS(wxApp,wxEvtHandler)
+
+BEGIN_EVENT_TABLE(wxApp, wxEvtHandler)
+ EVT_IDLE(wxAppBase::OnIdle)
+END_EVENT_TABLE()
+
+wxApp::wxApp()
+{
+#ifdef __WXDEBUG__
+ m_isInAssert = false;
+#endif // __WXDEBUG__
+
+ m_idleTag = 0;
+ g_isIdle = true;
+ wxapp_install_idle_handler();
+
+#if wxUSE_THREADS
+ g_main_context_set_poll_func( NULL, wxapp_poll_func );
+#endif
+
+ // this is NULL for a "regular" wxApp, but is set (and freed) by a wxGLApp
+ m_glVisualInfo = (void *) NULL;
+ m_glFBCInfo = (void *) NULL;
+}
+
+wxApp::~wxApp()
+{
+ if (m_idleTag)
+ g_source_remove( m_idleTag );
+}
+
+bool wxApp::OnInitGui()
+{
+ if ( !wxAppBase::OnInitGui() )
+ return false;
+
+ // if this is a wxGLApp (derived from wxApp), and we've already
+ // chosen a specific visual, then derive the GdkVisual from that
+ if (m_glVisualInfo != NULL)
+ {
+ // seems gtk_widget_set_default_visual no longer exists?
+ GdkVisual* vis = gtk_widget_get_default_visual();
+
+ GdkColormap *colormap = gdk_colormap_new( vis, FALSE );
+ gtk_widget_set_default_colormap( colormap );
+ }
+
+ // On some machines, the default visual is just 256 colours, so
+ // we make sure we get the best. This can sometimes be wasteful.
+
+ else
+ if ((gdk_visual_get_best() != gdk_visual_get_system()) && (m_useBestVisual))
+ {
+ /* seems gtk_widget_set_default_visual no longer exists? */
+ GdkVisual* vis = gtk_widget_get_default_visual();
+
+ GdkColormap *colormap = gdk_colormap_new( vis, FALSE );
+ gtk_widget_set_default_colormap( colormap );
+ }
+
+ return true;
+}
+
+GdkVisual *wxApp::GetGdkVisual()
+{
+ GdkVisual *visual = NULL;
+
+ if (m_glVisualInfo)
+ visual = gdkx_visual_get( ((XVisualInfo *) m_glVisualInfo)->visualid );
+ else
+ visual = gdk_drawable_get_visual( wxGetRootWindow()->window );