diff --git a/include/wx/mac/carbon/app.h b/include/wx/mac/carbon/app.h index ca6ecad5cb..16d2af3078 100644 --- a/include/wx/mac/carbon/app.h +++ b/include/wx/mac/carbon/app.h @@ -21,6 +21,8 @@ #include "wx/gdicmn.h" #include "wx/event.h" +#include + class WXDLLEXPORT wxFrame; class WXDLLEXPORT wxWindowMac; class WXDLLEXPORT wxApp ; @@ -105,6 +107,7 @@ private: WXEVENTHANDLERREF m_macEventHandler ; WXEVENTHANDLERCALLREF m_macCurrentEventHandlerCallRef ; WXEVENTREF m_macCurrentEvent ; + CFRunLoopSourceRef m_macEventPosted ; public: static bool s_macSupportPCMenuShortcuts ; diff --git a/src/mac/carbon/app.cpp b/src/mac/carbon/app.cpp index 43c7cf1b29..908557b7da 100644 --- a/src/mac/carbon/app.cpp +++ b/src/mac/carbon/app.cpp @@ -607,6 +607,11 @@ pascal static void wxMacAssertOutputHandler(OSType componentSignature, UInt32 op #endif //__WXDEBUG__ +extern "C" { + /* m_macEventPosted run loop source callback: */ + void macPostedEventCallback(void *unused) { wxTheApp->ProcessPendingEvents(); } +} + bool wxApp::Initialize(int& argc, wxChar **argv) { // Mac-specific @@ -674,6 +679,13 @@ bool wxApp::Initialize(int& argc, wxChar **argv) wxMacCreateNotifierTable() ; + /* connect posted events to common-mode run loop so that wxPostEvent events + are handled even while we're in the menu or on a scrollbar */ + CFRunLoopSourceContext event_posted_context = {0}; + event_posted_context.perform = macPostedEventCallback; + m_macEventPosted = CFRunLoopSourceCreate(NULL,0,&event_posted_context); + CFRunLoopAddSource(CFRunLoopGetCurrent(), m_macEventPosted, kCFRunLoopCommonModes); + UMAShowArrowCursor() ; return true; @@ -721,6 +733,12 @@ void wxApp::CleanUp() wxToolTip::RemoveToolTips() ; #endif + if (m_macEventPosted) + { + CFRelease(m_macEventPosted); + } + m_macEventPosted = NULL; + // One last chance for pending objects to be cleaned up wxTheApp->DeletePendingObjects(); @@ -857,6 +875,7 @@ wxApp::wxApp() m_macCurrentEvent = NULL ; m_macCurrentEventHandlerCallRef = NULL ; + m_macEventPosted = NULL ; } int wxApp::MainLoop() @@ -913,6 +932,10 @@ void wxApp::OnIdle(wxIdleEvent& event) void wxApp::WakeUpIdle() { + if (m_macEventPosted) + { + CFRunLoopSourceSignal(m_macEventPosted); + } wxMacWakeUp() ; }