]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/app.cpp
wxChoice/wxComboBox background colour change (to get back to where we were);
[wxWidgets.git] / src / gtk / app.cpp
index d262df2ecbdf01d5d71026e4e03e3912eef07819..e399efa119ee5ea0e3a61c461a2a9b78b679a9aa 100644 (file)
@@ -8,7 +8,6 @@
 /////////////////////////////////////////////////////////////////////////////
 
 #ifdef __GNUG__
-    #pragma implementation "appbase.h"
     #pragma implementation "app.h"
 #endif
 
 #include "wx/thread.h"
 #endif
 
-#include "unistd.h"
+#include <unistd.h>
 
-#include "glib.h"
-#include "gdk/gdk.h"
-#include "gtk/gtk.h"
+#include <glib.h>
+#include <gdk/gdk.h>
+#include <gtk/gtk.h>
 
 #include "wx/gtk/win_gtk.h"
 
 wxApp *wxTheApp = (wxApp *)  NULL;
 wxAppInitializerFunction wxAppBase::m_appInitFn = (wxAppInitializerFunction) NULL;
 
-#if wxUSE_THREADS
-extern wxList *wxPendingEvents;
-extern wxCriticalSection *wxPendingEventsLocker;
-#endif
 extern wxResourceCache *wxTheResourceCache;
 extern bool g_isIdle;
 
@@ -127,10 +122,18 @@ unsigned char g_palette[64*3] =
 // local functions
 //-----------------------------------------------------------------------------
 
-extern void wxFlushResources(void);
+extern void wxFlushResources();
+
+/* forward declaration */
+gint   wxapp_idle_callback( gpointer WXUNUSED(data) );
+void   wxapp_install_idle_handler();
+
+#if wxUSE_THREADS
+gint   wxapp_wakeup_timerout_callback( gpointer WXUNUSED(data) );
+#endif
 
 //-----------------------------------------------------------------------------
-// global functions
+// wxExit
 //-----------------------------------------------------------------------------
 
 void wxExit()
@@ -138,8 +141,9 @@ void wxExit()
     gtk_main_quit();
 }
 
-/* forward declaration */
-gint wxapp_idle_callback( gpointer WXUNUSED(data) );
+//-----------------------------------------------------------------------------
+// wxYield
+//-----------------------------------------------------------------------------
 
 bool wxYield()
 {
@@ -170,6 +174,20 @@ bool wxYield()
     return TRUE;
 }
 
+//-----------------------------------------------------------------------------
+// wxWakeUpIdle
+//-----------------------------------------------------------------------------
+
+void wxWakeUpIdle()
+{
+    if (g_isIdle) 
+        wxapp_install_idle_handler();
+}
+
+//-----------------------------------------------------------------------------
+// local functions
+//-----------------------------------------------------------------------------
+
 gint wxapp_idle_callback( gpointer WXUNUSED(data) )
 {
     if (!wxTheApp) return TRUE;
@@ -208,19 +226,29 @@ void wxapp_install_idle_handler()
 {
     wxASSERT_MSG( wxTheApp->m_idleTag == 0, wxT("attempt to install idle handler twice") );
 
-    /* this routine gets called by all event handlers
-       indicating that the idle is over. */
+    /* 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). */
+
+#if wxUSE_THREADS
+    if (!wxThread::IsMain())
+        GDK_THREADS_ENTER ();
+#endif
 
     wxTheApp->m_idleTag = gtk_idle_add( wxapp_idle_callback, (gpointer) NULL );
 
     g_isIdle = FALSE;
+    
+#if wxUSE_THREADS
+    if (!wxThread::IsMain())
+        GDK_THREADS_LEAVE ();
+#endif
 }
 
 #if wxUSE_THREADS
 
-/* forward declaration */
-static gint wxapp_wakeup_timerout_callback( gpointer WXUNUSED(data) );
-
 void wxapp_install_thread_wakeup()
 {
     if (wxTheApp->m_wakeUpTimerTag) return;
@@ -236,7 +264,7 @@ void wxapp_uninstall_thread_wakeup()
     wxTheApp->m_wakeUpTimerTag = 0;
 }
 
-static gint wxapp_wakeup_timerout_callback( gpointer WXUNUSED(data) )
+gint wxapp_wakeup_timerout_callback( gpointer WXUNUSED(data) )
 {
     wxapp_uninstall_thread_wakeup();
 
@@ -265,7 +293,8 @@ static gint wxapp_wakeup_timerout_callback( gpointer WXUNUSED(data) )
 
     return TRUE;
 }
-#endif
+
+#endif // wxUSE_THREADS
 
 //-----------------------------------------------------------------------------
 // wxApp
@@ -427,11 +456,9 @@ void wxApp::OnIdle( wxIdleEvent &event )
 
     s_inOnIdle = TRUE;
 
-#if wxUSE_THREADS
     /* Resend in the main thread events which have been prepared in other
        threads */
     ProcessPendingEvents();
-#endif
 
     /* 'Garbage' collection of windows deleted with Close(). */
     DeletePendingObjects();
@@ -520,25 +547,6 @@ void wxApp::Dispatch()
     gtk_main_iteration();
 }
 
-#if wxUSE_THREADS
-void wxApp::ProcessPendingEvents()
-{
-    wxNode *node = wxPendingEvents->First();
-    wxCriticalSectionLocker locker(*wxPendingEventsLocker);
-
-    while (node)
-    {
-        wxEvtHandler *handler = (wxEvtHandler *)node->Data();
-
-        handler->ProcessPendingEvents();
-
-        delete node;
-
-        node = wxPendingEvents->First();
-    }
-}
-#endif // wxUSE_THREADS
-
 void wxApp::DeletePendingObjects()
 {
     wxNode *node = wxPendingDelete.First();
@@ -653,9 +661,8 @@ void wxApp::CleanUp()
     wxLog *oldLog = wxLog::SetActiveTarget( (wxLog*) NULL );
     if (oldLog)
         delete oldLog;
-}
-
 #endif // wxUSE_LOG
+}
 
 //-----------------------------------------------------------------------------
 // wxEntry