/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
-#pragma implementation "app.h"
+ #pragma implementation "app.h"
#endif
#include "wx/app.h"
#include "wx/font.h"
#include "wx/settings.h"
#include "wx/dialog.h"
+
#if wxUSE_WX_RESOURCES
-#include "wx/resource.h"
+ #include "wx/resource.h"
#endif
+
#include "wx/module.h"
#include "wx/image.h"
-#if wxUSE_THREADS
+
#include "wx/thread.h"
-#endif
+
#include "unistd.h"
-// many versions of Unices have this function, but it is not defined in system
-// headers - please add your system here if it is the case for your OS.
-// SunOS < 5.6 (i.e. Solaris < 2.6) and DG-UX are like this.
-#if (defined(__SUN__) && !defined(__SunOs_5_6) && \
- !defined(__SunOs_5_7) && !defined(__SUNPRO_CC)) || \
- defined(__osf__)
- extern "C"
- {
- void usleep(unsigned long usec);
- };
-#endif // Unices without usleep()
+#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"
-#include <unistd.h> // usleep() on solaris
-
//-----------------------------------------------------------------------------
// global data
//-----------------------------------------------------------------------------
wxAppInitializerFunction wxApp::m_appInitFn = (wxAppInitializerFunction) NULL;
extern wxList wxPendingDelete;
+#if wxUSE_THREADS
+extern wxList wxPendingEvents;
+extern wxCriticalSection wxPendingEventsLocker;
+#endif
extern wxResourceCache *wxTheResourceCache;
unsigned char g_palette[64*3] =
bool wxYield()
{
- while (gtk_events_pending() > 0) gtk_main_iteration();
+ // it's necessary to call ProcessIdle() to update the frames sizes which
+ // might have been changed (it also will update other things set from
+ // OnUpdateUI() which is a nice (and desired) side effect)
+ for ( wxNode *node = wxTopLevelWindows.GetFirst();
+ node;
+ node = node->GetNext() )
+ {
+ wxWindow *win = ((wxWindow*)node->GetData());
+ win->OnInternalIdle();
+ }
+
+ while (gtk_events_pending() > 0)
+ gtk_main_iteration();
+
return TRUE;
}
gint wxapp_idle_callback( gpointer WXUNUSED(data) )
{
- if (wxTheApp) while (wxTheApp->ProcessIdle()) {}
-#if wxUSE_THREADS
+ if (wxTheApp)
+ {
+ while (wxTheApp->ProcessIdle())
+ {
+ }
+ }
+
wxMutexGuiLeave();
-#endif
- usleep(10000);
-#if wxUSE_THREADS
+ wxUsleep(10);
wxMutexGuiEnter();
-#endif
+
return TRUE;
}
inOnIdle = TRUE;
+ /* Resend in the main thread events which have been prepared in other
+ threads */
+ ProcessPendingEvents();
+
/* 'Garbage' collection of windows deleted with Close(). */
DeletePendingObjects();
{
}
+#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
+
void wxApp::DeletePendingObjects()
{
wxNode *node = wxPendingDelete.First();