From 90639b8339a7ae7b98b33033615430412e5c21a0 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 5 Dec 2014 22:17:23 +0000 Subject: [PATCH] Send idle events from inside wxYield() in all ports, including wxMSW. This means it can be now done in wxEventLoopBase itself and calls to ProcessIdle() in the port-specific code are not needed any more, so remove them. This introduces a change in behaviour for wxMSW, where idle event handlers were not invoked from inside wxYield() at all previously, and for wxOSX, where only a single idle event is now generated from wxYield() instead of a stream of them until no idle handler needs any more of them as before. But on the bright side, the new behaviour seems to make most sense and is now the same in all ports. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78222 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 4 ++++ src/common/evtloopcmn.cpp | 18 ++++++++++++++---- src/dfb/evtloop.cpp | 5 ----- src/gtk/evtloop.cpp | 14 -------------- src/gtk1/evtloop.cpp | 8 -------- src/osx/core/evtloop_cf.cpp | 5 ----- src/x11/evtloop.cpp | 1 - 7 files changed, 18 insertions(+), 37 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index be8d0cd8a9..dca685aacb 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -17,6 +17,10 @@ Changes in behaviour not resulting in compilation errors wxINTERPOLATION_DEFAULT and not wxINTERPOLATION_GOOD as in 3.0 for consistency with OS X, call SetInterpolationQuality() explicitly if needed. +- Calling wxYield() in wxMSW now generates wxEVT_IDLE events, just as in the + other ports, but this can be unexpected for the applications not expecting + their idle handlers to be called from inside wxYield(). + Changes in behaviour which may result in build errors ----------------------------------------------------- diff --git a/src/common/evtloopcmn.cpp b/src/common/evtloopcmn.cpp index 626cb51b4d..e8123f3caa 100644 --- a/src/common/evtloopcmn.cpp +++ b/src/common/evtloopcmn.cpp @@ -153,14 +153,24 @@ bool wxEventLoopBase::YieldFor(long eventsToProcess) void wxEventLoopBase::DoYieldFor(long eventsToProcess) { // Normally yielding dispatches not only the pending native events, but - // also the events pending in wxWidgets itself. + // also the events pending in wxWidgets itself and idle events. // // Notice however that we must not do it if we're asked to process only the // events of specific kind, as pending events could be of any kind at all // (ideal would be to have a filtering version of ProcessPendingEvents() - // too but we don't have this right now). - if ( eventsToProcess == wxEVT_CATEGORY_ALL && wxTheApp ) - wxTheApp->ProcessPendingEvents(); + // too but we don't have this right now) and idle events are typically + // unexpected when yielding for the specific event kinds only. + if ( eventsToProcess == wxEVT_CATEGORY_ALL ) + { + if ( wxTheApp ) + wxTheApp->ProcessPendingEvents(); + + // We call it just once, even if it returns true, because we don't want + // to get stuck inside wxYield() forever if the application does some + // constant background processing in its idle handler, we do need to + // get back to the main loop soon. + ProcessIdle(); + } } #if wxUSE_EVENTLOOP_SOURCE diff --git a/src/dfb/evtloop.cpp b/src/dfb/evtloop.cpp index ac18c5b438..b8b004fcaf 100644 --- a/src/dfb/evtloop.cpp +++ b/src/dfb/evtloop.cpp @@ -213,10 +213,5 @@ void wxGUIEventLoop::DoYieldFor(long eventsToProcess) // handle timers, sockets etc. OnNextIteration(); - // 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() ) {} - wxEventLoopBase::DoYieldFor(eventsToProcess); } diff --git a/src/gtk/evtloop.cpp b/src/gtk/evtloop.cpp index 72fd51baa4..9e7a2f44d2 100644 --- a/src/gtk/evtloop.cpp +++ b/src/gtk/evtloop.cpp @@ -385,20 +385,6 @@ void wxGUIEventLoop::DoYieldFor(long eventsToProcess) wxEventLoopBase::DoYieldFor(eventsToProcess); - if (eventsToProcess != wxEVT_CATEGORY_CLIPBOARD) - { - // 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(); - } - //else: if we are inside ~wxClipboardSync() and we call ProcessIdle() and - // the user app contains an UI update handler which calls wxClipboard::IsSupported, - // then we fall into a never-ending loop... - // put all unprocessed GDK events back in the queue GdkDisplay* disp = gdk_window_get_display(wxGetTopLevelGDK()); for (size_t i=0; i