]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/app.cpp
::GetWindowText() -> wxGetWindowText
[wxWidgets.git] / src / gtk / app.cpp
index afe49ce3c1552d12142a6abbfc9c7efffb2f421a..e37f422742a07d78efc95078dbbe0e75b3853f02 100644 (file)
@@ -46,6 +46,10 @@ wxApp *wxTheApp = (wxApp *)  NULL;
 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] =
@@ -136,11 +140,11 @@ bool wxYield()
     // 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();
+    for ( wxWindowList::Node *node = wxTopLevelWindows.GetFirst();
           node;
           node = node->GetNext() )
     {
-        wxWindow *win = ((wxWindow*)node->GetData());
+        wxWindow *win = node->GetData();
         win->OnInternalIdle();
     }
 
@@ -283,6 +287,12 @@ void wxApp::OnIdle( wxIdleEvent &event )
 
     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();
 
@@ -304,14 +314,15 @@ bool wxApp::SendIdleEvents()
 {
     bool needMore = FALSE;
 
-    wxNode* node = wxTopLevelWindows.First();
+    wxWindowList::Node* node = wxTopLevelWindows.GetFirst();
     while (node)
     {
-        wxWindow* win = (wxWindow*) node->Data();
+        wxWindow* win = node->GetData();
         if (SendIdleEvents(win))
             needMore = TRUE;
-        node = node->Next();
+        node = node->GetNext();
     }
+
     return needMore;
 }
 
@@ -366,6 +377,25 @@ void wxApp::Dispatch()
 {
 }
 
+#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();
@@ -384,10 +414,12 @@ void wxApp::DeletePendingObjects()
 
 wxWindow *wxApp::GetTopWindow()
 {
-    if (m_topWindow) return m_topWindow;
-    wxNode *node = wxTopLevelWindows.First();
-    if (!node) return (wxWindow *) NULL;
-    return (wxWindow*)node->Data();
+    if (m_topWindow)
+        return m_topWindow;
+    else if (wxTopLevelWindows.GetCount() > 0)
+        return wxTopLevelWindows.GetFirst()->GetData();
+    else
+        return NULL;
 }
 
 void wxApp::SetTopWindow( wxWindow *win )
@@ -403,6 +435,13 @@ bool wxApp::Initialize()
 
     wxSystemSettings::Init();
 
+    // GL: I'm annoyed ... I don't know where to put this and I don't want to
+    // create a module for that as it's part of the core.
+#if wxUSE_THREADS
+    wxPendingEvents = new wxList();
+    wxPendingEventsLocker = new wxCriticalSection();
+#endif
+
 /*
     wxTheFontNameDirectory =  new wxFontNameDirectory;
     wxTheFontNameDirectory->Initialize();
@@ -463,6 +502,13 @@ void wxApp::CleanUp()
     delete wxTheApp;
     wxTheApp = (wxApp*) NULL;
 
+    // GL: I'm annoyed ... I don't know where to put this and I don't want to
+    // create a module for that as it's part of the core.
+#if wxUSE_THREADS
+    delete wxPendingEvents;
+    delete wxPendingEventsLocker;
+#endif
+
     wxSystemSettings::Done();
 
     delete[] wxBuffer;
@@ -538,7 +584,7 @@ int wxEntry( int argc, char *argv[] )
     if (!wxTheApp->OnInit())
         return 0;
 
-    wxTheApp->m_initialized = (wxTopLevelWindows.Number() > 0);
+    wxTheApp->m_initialized = wxTopLevelWindows.GetCount() != 0;
 
     int retValue = 0;