+ if (g_pendingTag == 0)
+ g_pendingTag = gtk_idle_add_priority( 900, wxapp_pending_callback, (gpointer) NULL );
+
+ /* This routine gets called by all event handlers
+ indicating that the idle is over. It may also
+ get called from other thread for sending events
+ to the main thread (and processing these in
+ idle time). Very low priority. */
+
+ wxTheApp->m_idleTag = gtk_idle_add_priority( 1000, wxapp_idle_callback, (gpointer) NULL );
+}
+
+#if wxUSE_THREADS
+
+static int g_threadUninstallLevel = 0;
+
+void wxapp_install_thread_wakeup()
+{
+ g_threadUninstallLevel++;
+
+ if (g_threadUninstallLevel != 1) return;
+
+ if (wxTheApp->m_wakeUpTimerTag) return;
+
+ wxTheApp->m_wakeUpTimerTag = gtk_timeout_add( 50, wxapp_wakeup_timerout_callback, (gpointer) NULL );
+}
+
+void wxapp_uninstall_thread_wakeup()
+{
+ g_threadUninstallLevel--;
+
+ if (g_threadUninstallLevel != 0) return;
+
+ if (!wxTheApp->m_wakeUpTimerTag) return;
+
+ gtk_timeout_remove( wxTheApp->m_wakeUpTimerTag );
+ wxTheApp->m_wakeUpTimerTag = 0;
+}
+
+gint wxapp_wakeup_timerout_callback( gpointer WXUNUSED(data) )
+{
+ // when getting called from GDK's time-out handler
+ // we are no longer within GDK's grab on the GUI
+ // thread so we must lock it here ourselves
+ gdk_threads_enter();
+
+ wxapp_uninstall_thread_wakeup();
+
+ // unblock other threads wishing to do some GUI things