From 5375a1f5e859deebee2b30e4a50bd40fc324f586 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Mon, 28 Jan 2002 16:17:39 +0000 Subject: [PATCH] Change idle behvaiour with regard to wxIdleEvent::RequestMore(). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13881 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/app.cpp | 49 ++++++++++++++++++++++++------------------------ src/gtk1/app.cpp | 49 ++++++++++++++++++++++++------------------------ 2 files changed, 48 insertions(+), 50 deletions(-) diff --git a/src/gtk/app.cpp b/src/gtk/app.cpp index 86a0258e1b..7b88bc6f5e 100644 --- a/src/gtk/app.cpp +++ b/src/gtk/app.cpp @@ -125,12 +125,13 @@ bool wxApp::Yield(bool onlyIfNeeded) while (gtk_events_pending()) 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) */ - while ( ProcessIdle() ) - { - } + // 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). But we + // call ProcessIdle() only once since this is not meant for longish + // background jobs (controlled by wxIdleEvent::RequestMore() and the + // return value of Processidle(). + ProcessIdle(); // let the logs be flashed again wxLog::Resume(); @@ -190,17 +191,17 @@ gint wxapp_pending_callback( gpointer WXUNUSED(data) ) { if (!wxTheApp) return TRUE; - // when getting called from GDK's time-out handler + // When getting called from GDK's time-out handler // we are no longer within GDK's grab on the GUI - // thread so we must lock it here ourselves + // thread so we must lock it here ourselves. gdk_threads_enter(); - // Sent idle event to all who request them + // Sent idle event to all who request them. wxTheApp->ProcessPendingEvents(); g_pendingTag = 0; - /* flush the logged messages if any */ + // Flush the logged messages if any. #if wxUSE_LOG wxLog::FlushActive(); #endif // wxUSE_LOG @@ -228,28 +229,26 @@ gint wxapp_idle_callback( gpointer WXUNUSED(data) ) } #endif // __WXDEBUG__ - // when getting called from GDK's time-out handler + // When getting called from GDK's time-out handler // we are no longer within GDK's grab on the GUI - // thread so we must lock it here ourselves + // thread so we must lock it here ourselves. gdk_threads_enter(); - /* Indicate that we are now in idle mode - even so deeply - in idle mode that we don't get any idle events anymore. - this is like wxMSW where an idle event is sent only - once each time after the event queue has been completely - emptied */ + // Indicate that we are now in idle mode and event handlers + // will have to reinstall the idle handler again. g_isIdle = TRUE; wxTheApp->m_idleTag = 0; - // Sent idle event to all who request them as long as they do - while (wxTheApp->ProcessIdle()) + // Sent idle event to all who request them as long as + // no events have popped up in the event queue. + while (wxTheApp->ProcessIdle() && (gtk_events_pending() == 0)) ; // Release lock again gdk_threads_leave(); // Return FALSE to indicate that no more idle events are - // to be sent (single shot instead of continuous stream) + // to be sent (single shot instead of continuous stream). return FALSE; } @@ -501,20 +500,20 @@ void wxApp::OnIdle( wxIdleEvent &event ) { static bool s_inOnIdle = FALSE; - /* Avoid recursion (via ProcessEvent default case) */ + // 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 */ + // Resend in the main thread events which have been prepared in other + // threads ProcessPendingEvents(); - /* 'Garbage' collection of windows deleted with Close(). */ + // 'Garbage' collection of windows deleted with Close() DeletePendingObjects(); - /* Send OnIdle events to all windows */ + // Send OnIdle events to all windows bool needMore = SendIdleEvents(); if (needMore) diff --git a/src/gtk1/app.cpp b/src/gtk1/app.cpp index 86a0258e1b..7b88bc6f5e 100644 --- a/src/gtk1/app.cpp +++ b/src/gtk1/app.cpp @@ -125,12 +125,13 @@ bool wxApp::Yield(bool onlyIfNeeded) while (gtk_events_pending()) 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) */ - while ( ProcessIdle() ) - { - } + // 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). But we + // call ProcessIdle() only once since this is not meant for longish + // background jobs (controlled by wxIdleEvent::RequestMore() and the + // return value of Processidle(). + ProcessIdle(); // let the logs be flashed again wxLog::Resume(); @@ -190,17 +191,17 @@ gint wxapp_pending_callback( gpointer WXUNUSED(data) ) { if (!wxTheApp) return TRUE; - // when getting called from GDK's time-out handler + // When getting called from GDK's time-out handler // we are no longer within GDK's grab on the GUI - // thread so we must lock it here ourselves + // thread so we must lock it here ourselves. gdk_threads_enter(); - // Sent idle event to all who request them + // Sent idle event to all who request them. wxTheApp->ProcessPendingEvents(); g_pendingTag = 0; - /* flush the logged messages if any */ + // Flush the logged messages if any. #if wxUSE_LOG wxLog::FlushActive(); #endif // wxUSE_LOG @@ -228,28 +229,26 @@ gint wxapp_idle_callback( gpointer WXUNUSED(data) ) } #endif // __WXDEBUG__ - // when getting called from GDK's time-out handler + // When getting called from GDK's time-out handler // we are no longer within GDK's grab on the GUI - // thread so we must lock it here ourselves + // thread so we must lock it here ourselves. gdk_threads_enter(); - /* Indicate that we are now in idle mode - even so deeply - in idle mode that we don't get any idle events anymore. - this is like wxMSW where an idle event is sent only - once each time after the event queue has been completely - emptied */ + // Indicate that we are now in idle mode and event handlers + // will have to reinstall the idle handler again. g_isIdle = TRUE; wxTheApp->m_idleTag = 0; - // Sent idle event to all who request them as long as they do - while (wxTheApp->ProcessIdle()) + // Sent idle event to all who request them as long as + // no events have popped up in the event queue. + while (wxTheApp->ProcessIdle() && (gtk_events_pending() == 0)) ; // Release lock again gdk_threads_leave(); // Return FALSE to indicate that no more idle events are - // to be sent (single shot instead of continuous stream) + // to be sent (single shot instead of continuous stream). return FALSE; } @@ -501,20 +500,20 @@ void wxApp::OnIdle( wxIdleEvent &event ) { static bool s_inOnIdle = FALSE; - /* Avoid recursion (via ProcessEvent default case) */ + // 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 */ + // Resend in the main thread events which have been prepared in other + // threads ProcessPendingEvents(); - /* 'Garbage' collection of windows deleted with Close(). */ + // 'Garbage' collection of windows deleted with Close() DeletePendingObjects(); - /* Send OnIdle events to all windows */ + // Send OnIdle events to all windows bool needMore = SendIdleEvents(); if (needMore) -- 2.45.2