+ needMore = ProcessIdle();
+ } while (needMore && gtk_events_pending() == 0);
+ gdk_threads_leave();
+
+#if wxUSE_THREADS
+ wxMutexLocker lock(m_idleMutex);
+#endif
+
+ bool keepSource = false;
+ // if a new idle source has not been added, either as a result of idle
+ // processing above or by another thread calling WakeUpIdle()
+ if (m_idleSourceId == 0)
+ {
+ // if more idle processing was requested or pending events have appeared
+ if (needMore || HasPendingEvents())
+ {
+ // keep this source installed
+ m_idleSourceId = id_save;
+ keepSource = true;
+ }
+ else // add hooks and remove this source
+ wx_add_idle_hooks();
+ }
+ // else remove this source, leave new one installed
+ // we must keep an idle source, otherwise a wakeup could be lost
+
+ return keepSource;