X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9482617091b084d4ee006679a450176715d465e0..1978421a6d8b81c1f8a961da4b8ddf544fec7b1b:/src/os2/app.cpp diff --git a/src/os2/app.cpp b/src/os2/app.cpp index bde40f8e18..84687d9924 100644 --- a/src/os2/app.cpp +++ b/src/os2/app.cpp @@ -166,15 +166,13 @@ void wxApp::HandleSockets() int i; struct GsocketCallbackInfo *CallbackInfo = (struct GsocketCallbackInfo *)m_sockCallbackInfo; - int r = 0; timeout.tv_sec = 0; timeout.tv_usec = 0; if ( select(m_maxSocketNr, &readfds, &writefds, 0, &timeout) > 0) { - for (i = m_lastUsedHandle + 1; i != m_lastUsedHandle; i++) + for (i = m_lastUsedHandle + 1; i != m_lastUsedHandle; + (i < m_maxSocketNr - 1) ? i++ : (i = 0)) { - if (i == m_maxSocketNr) - i = 0; if (FD_ISSET(i, &readfds)) { int r; @@ -187,7 +185,6 @@ void wxApp::HandleSockets() { CallbackInfo[r].proc(CallbackInfo[r].gsock); pendingEvent = TRUE; - wxYield(); } } if (FD_ISSET(i, &writefds)) @@ -201,14 +198,13 @@ void wxApp::HandleSockets() { CallbackInfo[r].proc(CallbackInfo[r].gsock); pendingEvent = TRUE; - wxYield(); } } } m_lastUsedHandle = i; } if (pendingEvent) - wxYield(); + ProcessPendingEvents(); } } // --------------------------------------------------------------------------- @@ -226,7 +222,7 @@ void wxApp::HandleSockets() // // Initialize // -bool wxApp::Initialize(int argc, wxChar **argv) +bool wxApp::Initialize(int& argc, wxChar **argv) { if ( !wxAppBase::Initialize(argc, argv) ) return false; @@ -470,104 +466,6 @@ void wxApp::CleanUp() wxAppBase::CleanUp(); } // end of wxApp::CleanUp -//---------------------------------------------------------------------- -// Main wxWindows entry point -//---------------------------------------------------------------------- -int wxEntry( - int argc -, char* argv[] -) -{ - HAB vHab = 0; - - if (!wxApp::Initialize(vHab)) - return 0; - - // - // create the application object or ensure that one already exists - // - if (!wxTheApp) - { - // The app may have declared a global application object, but we recommend - // the IMPLEMENT_APP macro is used instead, which sets an initializer - // function for delayed, dynamic app object construction. - wxCHECK_MSG( wxApp::GetInitializerFunction(), 0, - wxT("No initializer - use IMPLEMENT_APP macro.") ); - wxTheApp = (*wxApp::GetInitializerFunction()) (); - } - wxCHECK_MSG( wxTheApp, 0, wxT("You have to define an instance of wxApp!") ); - wxTheApp->argc = argc; - -#if wxUSE_UNICODE - wxTheApp->argv = new wxChar*[argc+1]; - - int nArgc = 0; - - while (nArgc < argc) - { - wxTheApp->argv[nArgc] = wxStrdup(wxConvLibc.cMB2WX(argv[nArgc])); - nArgc++; - } - wxTheApp->argv[nArgc] = (wxChar *)NULL; -#else - wxTheApp->argv = argv; -#endif - - wxString sName(wxFileNameFromPath(argv[0])); - - wxStripExtension(sName); - wxTheApp->SetAppName(sName); - - int nRetValue = 0; - - if (!wxTheApp->OnInitGui()) - nRetValue = -1; - - if (nRetValue == 0) - { - if (wxTheApp->OnInit()) - { - wxTheApp->OnRun(); - } - // Normal exit - wxWindow* pTopWindow = wxTheApp->GetTopWindow(); - if (pTopWindow) - { - // Forcibly delete the window. - if (pTopWindow->IsKindOf(CLASSINFO(wxFrame)) || - pTopWindow->IsKindOf(CLASSINFO(wxDialog)) ) - { - pTopWindow->Close(TRUE); - wxTheApp->DeletePendingObjects(); - } - else - { - delete pTopWindow; - wxTheApp->SetTopWindow(NULL); - } - } - } - else // app initialization failed - { - wxLogLastError(" Gui initialization failed, exitting"); - } -#if wxUSE_CONSOLEDEBUG - printf("wxTheApp->OnExit "); - fflush(stdout); -#endif - nRetValue = wxTheApp->OnExit(); -#if wxUSE_CONSOLEDEBUG - printf("wxApp::CleanUp "); - fflush(stdout); -#endif - wxApp::CleanUp(); -#if wxUSE_CONSOLEDEBUG - printf("return %i ", nRetValue); - fflush(stdout); -#endif - return(nRetValue); -} // end of wxEntry - bool wxApp::OnInitGui() { ERRORID vError; @@ -596,7 +494,6 @@ wxApp::wxApp() argc = 0; argv = NULL; m_nPrintMode = wxPRINT_WINDOWS; - m_bAuto3D = TRUE; m_hMq = 0; m_maxSocketHandles = 0; m_maxSocketNr = 0; @@ -745,30 +642,18 @@ int wxApp::MainLoop() while (!Pending() && ProcessIdle()) { HandleSockets(); - wxUsleep(10000); + wxUsleep(10); } HandleSockets(); if (Pending()) DoMessage(); else - wxUsleep(10000); + wxUsleep(10); } return (int)svCurrentMsg.mp1; } // end of wxApp::MainLoop -// -// Returns TRUE if more time is needed. -// -bool wxApp::ProcessIdle() -{ - wxIdleEvent vEvent; - - vEvent.SetEventObject(this); - ProcessEvent(vEvent); - return vEvent.MoreRequested(); -} // end of wxApp::ProcessIdle - void wxApp::ExitMainLoop() { ::WinPostMsg(NULL, WM_QUIT, 0, 0); @@ -888,25 +773,8 @@ void wxApp::OnIdle( return; gbInOnIdle = TRUE; - - // - // If there are pending events, we must process them: pending events - // are either events to the threads other than main or events posted - // with wxPostEvent() functions - // - ProcessPendingEvents(); - - // - // 'Garbage' collection of windows deleted with Close(). - // - DeletePendingObjects(); - -#if wxUSE_LOG - // - // Flush the logged messages if any - // - wxLog::FlushActive(); -#endif // wxUSE_LOG + + wxAppBase::OnIdle(event); #if wxUSE_DC_CACHEING // automated DC cache management: clear the cached DCs and bitmap @@ -918,66 +786,9 @@ void wxApp::OnIdle( wxDC::ClearCache(); #endif // wxUSE_DC_CACHEING - // - // Send OnIdle events to all windows - // - if (SendIdleEvents()) - { - // - // SendIdleEvents() returns TRUE if at least one window requested more - // idle events - // - rEvent.RequestMore(TRUE); - } gbInOnIdle = FALSE; } // end of wxApp::OnIdle -// Send idle event to all top-level windows -bool wxApp::SendIdleEvents() -{ - bool bNeedMore = FALSE; - wxWindowList::Node* pNode = wxTopLevelWindows.GetFirst(); - - while (pNode) - { - wxWindow* pWin = pNode->GetData(); - - if (SendIdleEvents(pWin)) - bNeedMore = TRUE; - pNode = pNode->GetNext(); - } - return bNeedMore; -} // end of wxApp::SendIdleEvents - -// -// Send idle event to window and all subwindows -// -bool wxApp::SendIdleEvents( - wxWindow* pWin -) -{ - bool bNeedMore = FALSE; - wxIdleEvent vEvent; - - vEvent.SetEventObject(pWin); - pWin->GetEventHandler()->ProcessEvent(vEvent); - - if (vEvent.MoreRequested()) - bNeedMore = TRUE; - - wxNode* pNode = pWin->GetChildren().First(); - - while (pNode) - { - wxWindow* pWin = (wxWindow*) pNode->Data(); - - if (SendIdleEvents(pWin)) - bNeedMore = TRUE; - pNode = pNode->Next(); - } - return bNeedMore; -} // end of wxApp::SendIdleEvents - void wxApp::OnEndSession( wxCloseEvent& WXUNUSED(rEvent)) { @@ -1054,6 +865,7 @@ bool wxApp::Yield(bool onlyIfNeeded) if (wxTheApp) wxTheApp->ProcessPendingEvents(); + HandleSockets(); // // Let the logs be flashed again //