Rationalised OnIdle

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21948 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2003-07-14 08:41:08 +00:00
parent 9977626de4
commit 955a919785
18 changed files with 37 additions and 349 deletions

View File

@@ -381,16 +381,13 @@ public:
// it should return TRUE if more idle events are needed, FALSE if not // it should return TRUE if more idle events are needed, FALSE if not
virtual bool ProcessIdle() ; virtual bool ProcessIdle() ;
#if 0
// Send idle event to all top-level windows.
// Returns TRUE if more idle time is requested.
virtual bool SendIdleEvents();
#endif
// Send idle event to window and all subwindows // Send idle event to window and all subwindows
// Returns TRUE if more idle time is requested. // Returns TRUE if more idle time is requested.
virtual bool SendIdleEvents(wxWindow* win, wxIdleEvent& event); virtual bool SendIdleEvents(wxWindow* win, wxIdleEvent& event);
// Perform standard OnIdle behaviour: call from port's OnIdle
void OnIdle(wxIdleEvent& event);
// top level window functions // top level window functions
// -------------------------- // --------------------------

View File

@@ -53,9 +53,6 @@ public:
virtual bool Yield(bool onlyIfNeeded = FALSE); virtual bool Yield(bool onlyIfNeeded = FALSE);
virtual void WakeUpIdle() { CocoaRequestIdle(); } virtual void WakeUpIdle() { CocoaRequestIdle(); }
/* Idle Processing */
void OnIdle(wxIdleEvent& event);
virtual bool Initialize(int& argc, wxChar **argv); virtual bool Initialize(int& argc, wxChar **argv);
virtual void CleanUp(); virtual void CleanUp();
virtual bool CallOnInit(); virtual bool CallOnInit();

View File

@@ -52,9 +52,6 @@ public:
virtual bool Yield(bool onlyIfNeeded = FALSE); virtual bool Yield(bool onlyIfNeeded = FALSE);
virtual void WakeUpIdle(); virtual void WakeUpIdle();
// implementation only from now on
void OnIdle( wxIdleEvent &event );
virtual bool Initialize(int& argc, wxChar **argv); virtual bool Initialize(int& argc, wxChar **argv);
virtual void CleanUp(); virtual void CleanUp();

View File

@@ -52,9 +52,6 @@ public:
virtual bool Yield(bool onlyIfNeeded = FALSE); virtual bool Yield(bool onlyIfNeeded = FALSE);
virtual void WakeUpIdle(); virtual void WakeUpIdle();
// implementation only from now on
void OnIdle( wxIdleEvent &event );
virtual bool Initialize(int& argc, wxChar **argv); virtual bool Initialize(int& argc, wxChar **argv);
virtual void CleanUp(); virtual void CleanUp();

View File

@@ -48,9 +48,6 @@ public:
virtual bool Pending(); virtual bool Pending();
virtual void Dispatch(); virtual void Dispatch();
// implementation only from now on
void OnIdle(wxIdleEvent &event);
virtual bool Initialize(int& argc, wxChar **argv); virtual bool Initialize(int& argc, wxChar **argv);
virtual void CleanUp(); virtual void CleanUp();

View File

@@ -66,8 +66,6 @@ public:
// implementation from now on // implementation from now on
// -------------------------- // --------------------------
void OnIdle(wxIdleEvent& event);
protected: protected:
bool m_showOnInit; bool m_showOnInit;

View File

@@ -66,8 +66,6 @@ public:
// implementation from now on // implementation from now on
// -------------------------- // --------------------------
void OnIdle(wxIdleEvent& event);
// Processes an X event. // Processes an X event.
virtual bool ProcessXEvent(WXEvent* event); virtual bool ProcessXEvent(WXEvent* event);

View File

@@ -134,7 +134,7 @@ void wxApp::Exit()
#if !USE_SHARED_LIBRARY #if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler) IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler)
BEGIN_EVENT_TABLE(wxApp, wxEvtHandler) BEGIN_EVENT_TABLE(wxApp, wxEvtHandler)
EVT_IDLE(wxApp::OnIdle) EVT_IDLE(wxAppBase::OnIdle)
// EVT_END_SESSION(wxApp::OnEndSession) // EVT_END_SESSION(wxApp::OnEndSession)
// EVT_QUERY_END_SESSION(wxApp::OnQueryEndSession) // EVT_QUERY_END_SESSION(wxApp::OnQueryEndSession)
END_EVENT_TABLE() END_EVENT_TABLE()
@@ -278,37 +278,6 @@ void wxApp::Dispatch()
{ {
} }
void wxApp::OnIdle(wxIdleEvent& event)
{
wxLogDebug("wxApp::OnIdle");
#if 0
static bool s_inOnIdle = FALSE;
// Avoid recursion (via ProcessEvent default case)
if ( s_inOnIdle )
return;
s_inOnIdle = TRUE;
#endif
DeletePendingObjects();
// flush the logged messages if any
wxLog *pLog = wxLog::GetActiveTarget();
if ( pLog != NULL && pLog->HasPendingMessages() )
pLog->Flush();
#if 0
// Send OnIdle events to all windows
bool needMore = SendIdleEvents();
if (needMore)
event.RequestMore(TRUE);
s_inOnIdle = FALSE;
#endif
}
// Yield to other processes // Yield to other processes
bool wxApp::Yield(bool onlyIfNeeded) bool wxApp::Yield(bool onlyIfNeeded)

View File

@@ -232,25 +232,6 @@ bool wxAppBase::ProcessIdle()
return needMore; return needMore;
} }
#if 0
// Send idle event to all top-level windows
bool wxAppBase::SendIdleEvents()
{
bool needMore = FALSE;
wxWindowList::compatibility_iterator node = wxTopLevelWindows.GetFirst();
while (node)
{
wxWindow* win = node->GetData();
if (SendIdleEvents(win))
needMore = TRUE;
node = node->GetNext();
}
return needMore;
}
#endif
// Send idle event to window and all subwindows // Send idle event to window and all subwindows
bool wxAppBase::SendIdleEvents(wxWindow* win, wxIdleEvent& event) bool wxAppBase::SendIdleEvents(wxWindow* win, wxIdleEvent& event)
{ {
@@ -279,6 +260,26 @@ bool wxAppBase::SendIdleEvents(wxWindow* win, wxIdleEvent& event)
return needMore; return needMore;
} }
void wxAppBase::OnIdle(wxIdleEvent& event)
{
// 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
// GRG: I have moved this here so that all pending events are processed
// before starting to delete any objects. This behaves better (in
// particular, wrt wxPostEvent) and is coherent with wxGTK's current
// behaviour. Changed Feb/2000 before 2.1.14
ProcessPendingEvents();
// 'Garbage' collection of windows deleted with Close().
DeletePendingObjects();
#if wxUSE_LOG
// flush the logged messages if any
wxLog::FlushActive();
#endif // wxUSE_LOG
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxGUIAppTraitsBase // wxGUIAppTraitsBase

View File

@@ -390,7 +390,7 @@ GtkWidget* wxGetRootWindow()
IMPLEMENT_DYNAMIC_CLASS(wxApp,wxEvtHandler) IMPLEMENT_DYNAMIC_CLASS(wxApp,wxEvtHandler)
BEGIN_EVENT_TABLE(wxApp, wxEvtHandler) BEGIN_EVENT_TABLE(wxApp, wxEvtHandler)
EVT_IDLE(wxApp::OnIdle) EVT_IDLE(wxAppBase::OnIdle)
END_EVENT_TABLE() END_EVENT_TABLE()
wxApp::wxApp() wxApp::wxApp()
@@ -534,35 +534,6 @@ GdkVisual *wxApp::GetGdkVisual()
return visual; return visual;
} }
void wxApp::OnIdle( wxIdleEvent &event )
{
static bool s_inOnIdle = FALSE;
// Avoid recursion (via ProcessEvent default case)
if (s_inOnIdle)
return;
s_inOnIdle = TRUE;
// Resend in the main thread events which have been prepared in other
// threads
ProcessPendingEvents();
// 'Garbage' collection of windows deleted with Close()
DeletePendingObjects();
// Now done in ProcessIdle()
#if 0
// Send OnIdle events to all windows
bool needMore = SendIdleEvents();
if (needMore)
event.RequestMore(TRUE);
#endif
s_inOnIdle = FALSE;
}
int wxApp::MainLoop() int wxApp::MainLoop()
{ {
gtk_main(); gtk_main();

View File

@@ -390,7 +390,7 @@ GtkWidget* wxGetRootWindow()
IMPLEMENT_DYNAMIC_CLASS(wxApp,wxEvtHandler) IMPLEMENT_DYNAMIC_CLASS(wxApp,wxEvtHandler)
BEGIN_EVENT_TABLE(wxApp, wxEvtHandler) BEGIN_EVENT_TABLE(wxApp, wxEvtHandler)
EVT_IDLE(wxApp::OnIdle) EVT_IDLE(wxAppBase::OnIdle)
END_EVENT_TABLE() END_EVENT_TABLE()
wxApp::wxApp() wxApp::wxApp()
@@ -534,35 +534,6 @@ GdkVisual *wxApp::GetGdkVisual()
return visual; return visual;
} }
void wxApp::OnIdle( wxIdleEvent &event )
{
static bool s_inOnIdle = FALSE;
// Avoid recursion (via ProcessEvent default case)
if (s_inOnIdle)
return;
s_inOnIdle = TRUE;
// Resend in the main thread events which have been prepared in other
// threads
ProcessPendingEvents();
// 'Garbage' collection of windows deleted with Close()
DeletePendingObjects();
// Now done in ProcessIdle()
#if 0
// Send OnIdle events to all windows
bool needMore = SendIdleEvents();
if (needMore)
event.RequestMore(TRUE);
#endif
s_inOnIdle = FALSE;
}
int wxApp::MainLoop() int wxApp::MainLoop()
{ {
gtk_main(); gtk_main();

View File

@@ -1025,35 +1025,13 @@ void wxApp::Dispatch()
void wxApp::OnIdle(wxIdleEvent& event) void wxApp::OnIdle(wxIdleEvent& event)
{ {
// Avoid recursion (via ProcessEvent default case) wxAppBase::OnIdle(event);
if ( s_inOnIdle )
return;
s_inOnIdle = TRUE;
// 'Garbage' collection of windows deleted with Close().
DeletePendingObjects();
// flush the logged messages if any
wxLog *pLog = wxLog::GetActiveTarget();
if ( pLog != NULL && pLog->HasPendingMessages() )
pLog->Flush();
// Now done in ProcessIdle()
#if 0
// Send OnIdle events to all windows
bool needMore = SendIdleEvents();
if (needMore)
event.RequestMore(TRUE);
#endif
// If they are pending events, we must process them: pending events are // If they are pending events, we must process them: pending events are
// either events to the threads other than main or events posted with // either events to the threads other than main or events posted with
// wxPostEvent() functions // wxPostEvent() functions
wxMacProcessNotifierAndPendingEvents(); wxMacProcessNotifierAndPendingEvents();
s_inOnIdle = FALSE;
if(!wxMenuBar::MacGetInstalledMenuBar() && wxMenuBar::MacGetCommonMenuBar()) if(!wxMenuBar::MacGetInstalledMenuBar() && wxMenuBar::MacGetCommonMenuBar())
wxMenuBar::MacGetCommonMenuBar()->MacInstallMenuBar(); wxMenuBar::MacGetCommonMenuBar()->MacInstallMenuBar();
} }

View File

@@ -1025,35 +1025,13 @@ void wxApp::Dispatch()
void wxApp::OnIdle(wxIdleEvent& event) void wxApp::OnIdle(wxIdleEvent& event)
{ {
// Avoid recursion (via ProcessEvent default case) wxAppBase::OnIdle(event);
if ( s_inOnIdle )
return;
s_inOnIdle = TRUE;
// 'Garbage' collection of windows deleted with Close().
DeletePendingObjects();
// flush the logged messages if any
wxLog *pLog = wxLog::GetActiveTarget();
if ( pLog != NULL && pLog->HasPendingMessages() )
pLog->Flush();
// Now done in ProcessIdle()
#if 0
// Send OnIdle events to all windows
bool needMore = SendIdleEvents();
if (needMore)
event.RequestMore(TRUE);
#endif
// If they are pending events, we must process them: pending events are // If they are pending events, we must process them: pending events are
// either events to the threads other than main or events posted with // either events to the threads other than main or events posted with
// wxPostEvent() functions // wxPostEvent() functions
wxMacProcessNotifierAndPendingEvents(); wxMacProcessNotifierAndPendingEvents();
s_inOnIdle = FALSE;
if(!wxMenuBar::MacGetInstalledMenuBar() && wxMenuBar::MacGetCommonMenuBar()) if(!wxMenuBar::MacGetInstalledMenuBar() && wxMenuBar::MacGetCommonMenuBar())
wxMenuBar::MacGetCommonMenuBar()->MacInstallMenuBar(); wxMenuBar::MacGetCommonMenuBar()->MacInstallMenuBar();
} }

View File

@@ -204,7 +204,7 @@ static void wxDestroyMGL_WM()
IMPLEMENT_DYNAMIC_CLASS(wxApp,wxEvtHandler) IMPLEMENT_DYNAMIC_CLASS(wxApp,wxEvtHandler)
BEGIN_EVENT_TABLE(wxApp, wxEvtHandler) BEGIN_EVENT_TABLE(wxApp, wxEvtHandler)
EVT_IDLE(wxApp::OnIdle) EVT_IDLE(wxAppBase::OnIdle)
END_EVENT_TABLE() END_EVENT_TABLE()
@@ -272,38 +272,6 @@ bool wxApp::OnInitGui()
return TRUE; return TRUE;
} }
void wxApp::OnIdle(wxIdleEvent &event)
{
static bool s_inOnIdle = FALSE;
/* Avoid recursion (via ProcessEvent default case) */
if (s_inOnIdle)
return;
s_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_LOG
// flush the logged messages if any
wxLog::FlushActive();
#endif // wxUSE_LOG
// Now done in ProcessIdle()
#if 0
// Send OnIdle events to all windows
if ( SendIdleEvents() )
event.RequestMore(TRUE);
#endif
s_inOnIdle = FALSE;
}
int wxApp::MainLoop() int wxApp::MainLoop()
{ {
int rt; int rt;

View File

@@ -71,7 +71,7 @@ wxHashTable *wxWidgetHashTable = NULL;
IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler) IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler)
BEGIN_EVENT_TABLE(wxApp, wxEvtHandler) BEGIN_EVENT_TABLE(wxApp, wxEvtHandler)
EVT_IDLE(wxApp::OnIdle) EVT_IDLE(wxAppBase::OnIdle)
END_EVENT_TABLE() END_EVENT_TABLE()
#ifdef __WXDEBUG__ #ifdef __WXDEBUG__
@@ -203,48 +203,6 @@ void wxApp::HandlePropertyChange(WXEvent *event)
XtDispatchEvent((XEvent*) event); /* let Motif do the work */ XtDispatchEvent((XEvent*) event); /* let Motif do the work */
} }
void wxApp::OnIdle(wxIdleEvent& event)
{
static bool inOnIdle = FALSE;
// Avoid recursion (via ProcessEvent default case)
if (inOnIdle)
return;
inOnIdle = 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
// GRG: I have moved this here so that all pending events are processed
// before starting to delete any objects. This behaves better (in
// particular, wrt wxPostEvent) and is coherent with wxGTK's current
// behaviour. Also removed the '#if wxUSE_THREADS' around it.
// Changed Mar/2000 before 2.1.14
// Flush pending events.
ProcessPendingEvents();
// 'Garbage' collection of windows deleted with Close().
DeletePendingObjects();
// flush the logged messages if any
wxLog *pLog = wxLog::GetActiveTarget();
if ( pLog != NULL && pLog->HasPendingMessages() )
pLog->Flush();
// Now done in ProcessIdle()
#if 0
// Send OnIdle events to all windows
bool needMore = SendIdleEvents();
if (needMore)
event.RequestMore(TRUE);
#endif
inOnIdle = FALSE;
}
static char *fallbackResources[] = { static char *fallbackResources[] = {
"*menuBar.marginHeight: 0", "*menuBar.marginHeight: 0",
"*menuBar.shadowThickness: 1", "*menuBar.shadowThickness: 1",

View File

@@ -802,23 +802,8 @@ void wxApp::OnIdle(wxIdleEvent& event)
return; return;
wxIsInOnIdleFlag = TRUE; wxIsInOnIdleFlag = TRUE;
// If there are pending events, we must process them: pending events wxAppBase::OnIdle(event);
// are either events to the threads other than main or events posted
// with wxPostEvent() functions
// GRG: I have moved this here so that all pending events are processed
// before starting to delete any objects. This behaves better (in
// particular, wrt wxPostEvent) and is coherent with wxGTK's current
// behaviour. Changed Feb/2000 before 2.1.14
ProcessPendingEvents();
// 'Garbage' collection of windows deleted with Close().
DeletePendingObjects();
#if wxUSE_LOG
// flush the logged messages if any
wxLog::FlushActive();
#endif // wxUSE_LOG
#if wxUSE_DC_CACHEING #if wxUSE_DC_CACHEING
// automated DC cache management: clear the cached DCs and bitmap // automated DC cache management: clear the cached DCs and bitmap
@@ -828,17 +813,6 @@ void wxApp::OnIdle(wxIdleEvent& event)
wxDC::ClearCache(); wxDC::ClearCache();
#endif // wxUSE_DC_CACHEING #endif // wxUSE_DC_CACHEING
// Now done in ProcessIdle()
#if 0
// Send OnIdle events to all windows
if ( SendIdleEvents() )
{
// SendIdleEvents() returns TRUE if at least one window requested more
// idle events
event.RequestMore(TRUE);
}
#endif
wxIsInOnIdleFlag = FALSE; wxIsInOnIdleFlag = FALSE;
} }

View File

@@ -777,25 +777,8 @@ void wxApp::OnIdle(
return; return;
gbInOnIdle = TRUE; gbInOnIdle = TRUE;
// wxAppBase::OnIdle(event);
// 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
#if wxUSE_DC_CACHEING #if wxUSE_DC_CACHEING
// automated DC cache management: clear the cached DCs and bitmap // automated DC cache management: clear the cached DCs and bitmap
@@ -807,21 +790,6 @@ void wxApp::OnIdle(
wxDC::ClearCache(); wxDC::ClearCache();
#endif // wxUSE_DC_CACHEING #endif // wxUSE_DC_CACHEING
// Now done in ProcessIdle()
#if 0
//
// Send OnIdle events to all windows
//
if (SendIdleEvents())
{
//
// SendIdleEvents() returns TRUE if at least one window requested more
// idle events
//
rEvent.RequestMore(TRUE);
}
#endif
gbInOnIdle = FALSE; gbInOnIdle = FALSE;
} // end of wxApp::OnIdle } // end of wxApp::OnIdle

View File

@@ -88,7 +88,7 @@ WXDisplay *wxApp::ms_display = NULL;
IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler) IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler)
BEGIN_EVENT_TABLE(wxApp, wxEvtHandler) BEGIN_EVENT_TABLE(wxApp, wxEvtHandler)
EVT_IDLE(wxApp::OnIdle) EVT_IDLE(wxAppBase::OnIdle)
END_EVENT_TABLE() END_EVENT_TABLE()
bool wxApp::Initialize(int& argc, wxChar **argv) bool wxApp::Initialize(int& argc, wxChar **argv)
@@ -700,35 +700,6 @@ bool wxApp::HandlePropertyChange(WXEvent *event)
return FALSE; return FALSE;
} }
void wxApp::OnIdle(wxIdleEvent& event)
{
static bool s_inOnIdle = FALSE;
// Avoid recursion (via ProcessEvent default case)
if (s_inOnIdle)
return;
s_inOnIdle = TRUE;
// Resend in the main thread events which have been prepared in other
// threads
ProcessPendingEvents();
// 'Garbage' collection of windows deleted with Close()
DeletePendingObjects();
// Now done in ProcessIdle()
#if 0
// Send OnIdle events to all windows
bool needMore = SendIdleEvents();
if (needMore)
event.RequestMore(TRUE);
#endif
s_inOnIdle = FALSE;
}
void wxApp::WakeUpIdle() void wxApp::WakeUpIdle()
{ {
// TODO: use wxMotif implementation? // TODO: use wxMotif implementation?