Create RunLoop that can be used to process pending events so that events will still be processed while the user is using a menu or scrollbar [ Patch 1160346 ] - this really needs to be in 2.5.5 so it can be widely tested before 2.6.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33127 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Kevin Hock
2005-03-28 18:47:46 +00:00
parent 264f00e7d9
commit 95e568ee3e
2 changed files with 26 additions and 0 deletions

View File

@@ -21,6 +21,8 @@
#include "wx/gdicmn.h" #include "wx/gdicmn.h"
#include "wx/event.h" #include "wx/event.h"
#include <CoreFoundation/CoreFoundation.h>
class WXDLLEXPORT wxFrame; class WXDLLEXPORT wxFrame;
class WXDLLEXPORT wxWindowMac; class WXDLLEXPORT wxWindowMac;
class WXDLLEXPORT wxApp ; class WXDLLEXPORT wxApp ;
@@ -105,6 +107,7 @@ private:
WXEVENTHANDLERREF m_macEventHandler ; WXEVENTHANDLERREF m_macEventHandler ;
WXEVENTHANDLERCALLREF m_macCurrentEventHandlerCallRef ; WXEVENTHANDLERCALLREF m_macCurrentEventHandlerCallRef ;
WXEVENTREF m_macCurrentEvent ; WXEVENTREF m_macCurrentEvent ;
CFRunLoopSourceRef m_macEventPosted ;
public: public:
static bool s_macSupportPCMenuShortcuts ; static bool s_macSupportPCMenuShortcuts ;

View File

@@ -607,6 +607,11 @@ pascal static void wxMacAssertOutputHandler(OSType componentSignature, UInt32 op
#endif //__WXDEBUG__ #endif //__WXDEBUG__
extern "C" {
/* m_macEventPosted run loop source callback: */
void macPostedEventCallback(void *unused) { wxTheApp->ProcessPendingEvents(); }
}
bool wxApp::Initialize(int& argc, wxChar **argv) bool wxApp::Initialize(int& argc, wxChar **argv)
{ {
// Mac-specific // Mac-specific
@@ -674,6 +679,13 @@ bool wxApp::Initialize(int& argc, wxChar **argv)
wxMacCreateNotifierTable() ; 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() ; UMAShowArrowCursor() ;
return true; return true;
@@ -721,6 +733,12 @@ void wxApp::CleanUp()
wxToolTip::RemoveToolTips() ; wxToolTip::RemoveToolTips() ;
#endif #endif
if (m_macEventPosted)
{
CFRelease(m_macEventPosted);
}
m_macEventPosted = NULL;
// One last chance for pending objects to be cleaned up // One last chance for pending objects to be cleaned up
wxTheApp->DeletePendingObjects(); wxTheApp->DeletePendingObjects();
@@ -857,6 +875,7 @@ wxApp::wxApp()
m_macCurrentEvent = NULL ; m_macCurrentEvent = NULL ;
m_macCurrentEventHandlerCallRef = NULL ; m_macCurrentEventHandlerCallRef = NULL ;
m_macEventPosted = NULL ;
} }
int wxApp::MainLoop() int wxApp::MainLoop()
@@ -913,6 +932,10 @@ void wxApp::OnIdle(wxIdleEvent& event)
void wxApp::WakeUpIdle() void wxApp::WakeUpIdle()
{ {
if (m_macEventPosted)
{
CFRunLoopSourceSignal(m_macEventPosted);
}
wxMacWakeUp() ; wxMacWakeUp() ;
} }