From cc96f525259a67031d16254d4fed87087ccfb6a8 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Wed, 19 May 2010 08:26:59 +0000 Subject: [PATCH] common wxMacWakeUp code across all platforms git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64343 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/osx/carbon/app.cpp | 30 +++--------------------------- src/osx/carbon/utils.cpp | 39 --------------------------------------- src/osx/cocoa/utils.mm | 33 +++------------------------------ src/osx/iphone/utils.mm | 5 ----- src/osx/utils_osx.cpp | 12 ++++++++++++ 5 files changed, 18 insertions(+), 101 deletions(-) diff --git a/src/osx/carbon/app.cpp b/src/osx/carbon/app.cpp index 273c280db6..7e03354c97 100644 --- a/src/osx/carbon/app.cpp +++ b/src/osx/carbon/app.cpp @@ -775,11 +775,6 @@ wxMacAssertOutputHandler(OSType WXUNUSED(componentSignature), #endif // wxDEBUG_LEVEL -extern "C" void macPostedEventCallback(void *WXUNUSED(unused)) -{ - wxTheApp->ProcessPendingEvents(); -} - bool wxApp::Initialize(int& argc, wxChar **argv) { // Mac-specific @@ -823,16 +818,6 @@ bool wxApp::Initialize(int& argc, wxChar **argv) wxSetWorkingDirectory( cwd ) ; } - /* 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); - // run loop takes ownership - CFRelease(m_macEventPosted); - */ return true; } @@ -945,12 +930,6 @@ void wxApp::CleanUp() wxToolTip::RemoveToolTips() ; #endif - if (m_macEventPosted) - { - CFRunLoopRemoveSource(CFRunLoopGetCurrent(), m_macEventPosted, kCFRunLoopCommonModes); - m_macEventPosted = NULL; - } - DoCleanUp(); wxAppBase::CleanUp(); @@ -1058,7 +1037,6 @@ wxApp::wxApp() m_macCurrentEvent = NULL ; m_macCurrentEventHandlerCallRef = NULL ; - m_macEventPosted = NULL ; m_macPool = new wxMacAutoreleasePool(); } @@ -1104,12 +1082,10 @@ void wxApp::OnIdle(wxIdleEvent& WXUNUSED(event)) void wxApp::WakeUpIdle() { - if (m_macEventPosted) - { - CFRunLoopSourceSignal(m_macEventPosted); - } + wxEventLoopBase * const loop = wxEventLoopBase::GetActive(); - wxMacWakeUp() ; + if ( loop ) + loop->WakeUp(); } void wxApp::OnEndSession(wxCloseEvent& WXUNUSED(event)) diff --git a/src/osx/carbon/utils.cpp b/src/osx/carbon/utils.cpp index c16c5ddb29..c6275209fc 100644 --- a/src/osx/carbon/utils.cpp +++ b/src/osx/carbon/utils.cpp @@ -195,45 +195,6 @@ void wxClientDisplayRect(int *x, int *y, int *width, int *height) #endif // wxUSE_GUI -#if wxUSE_BASE -// ---------------------------------------------------------------------------- -// Common Event Support -// ---------------------------------------------------------------------------- - -void wxMacWakeUp() -{ - OSStatus err = noErr; - -#if wxOSX_USE_CARBON -#if 0 - // lead sometimes to race conditions, although all calls used should be thread safe ... - static wxMacCarbonEvent s_wakeupEvent; - if ( !s_wakeupEvent.IsValid() ) - { - err = s_wakeupEvent.Create( 'WXMC', 'WXMC', GetCurrentEventTime(), - kEventAttributeNone ); - } - if ( err == noErr ) - { - - if ( IsEventInQueue( GetMainEventQueue() , s_wakeupEvent ) ) - return; - s_wakeupEvent.SetCurrentTime(); - err = PostEventToQueue(GetMainEventQueue(), s_wakeupEvent, - kEventPriorityHigh ); - } -#else - wxMacCarbonEvent wakeupEvent; - wakeupEvent.Create( 'WXMC', 'WXMC', GetCurrentEventTime(), - kEventAttributeNone ); - err = PostEventToQueue(GetMainEventQueue(), wakeupEvent, - kEventPriorityHigh ); -#endif -#endif -} - -#endif // wxUSE_BASE - #if wxUSE_GUI // ---------------------------------------------------------------------------- diff --git a/src/osx/cocoa/utils.mm b/src/osx/cocoa/utils.mm index 81f1d186f8..59420be784 100644 --- a/src/osx/cocoa/utils.mm +++ b/src/osx/cocoa/utils.mm @@ -45,35 +45,6 @@ void wxBell() NSBeep(); } -// ---------------------------------------------------------------------------- -// Common Event Support -// ---------------------------------------------------------------------------- - -void wxMacWakeUp() -{ - // ensure that we have an auto release pool in place because the event will - // be autoreleased from NSEvent:otherEventWithType and we might not have a - // global pool during startup or shutdown and we actually never have it if - // we're called from another thread - // - // FIXME: we can't use wxMacAutoreleasePool here because it's in core and - // we're in base - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - - NSEvent* wakeupEvent = [NSEvent otherEventWithType:NSApplicationDefined - location:NSZeroPoint - modifierFlags:NSAnyEventMask - timestamp:0 - windowNumber:0 - context:nil - subtype:0 - data1:0 - data2:0]; - [NSApp postEvent:wakeupEvent atStart:NO]; - - [pool release]; -} - #endif // wxUSE_BASE #if wxUSE_GUI @@ -234,11 +205,13 @@ bool wxApp::DoInitGui() if (!sm_isEmbedded) { wxNSAppController* controller = [[wxNSAppController alloc] init]; - [[NSApplication sharedApplication] setDelegate:controller]; + [NSApp setDelegate:controller]; NSAppleEventManager *appleEventManager = [NSAppleEventManager sharedAppleEventManager]; [appleEventManager setEventHandler:controller andSelector:@selector(handleGetURLEvent:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL]; + + [NSApp finishLaunching]; } return true; } diff --git a/src/osx/iphone/utils.mm b/src/osx/iphone/utils.mm index 884a2d16e0..55d5527c6a 100644 --- a/src/osx/iphone/utils.mm +++ b/src/osx/iphone/utils.mm @@ -87,11 +87,6 @@ void wxApp::DoCleanUp() { } -void wxMacWakeUp() -{ - // TODO -} - #endif // wxUSE_BASE #if wxUSE_GUI diff --git a/src/osx/utils_osx.cpp b/src/osx/utils_osx.cpp index c7adb41811..9b6eeaa80e 100644 --- a/src/osx/utils_osx.cpp +++ b/src/osx/utils_osx.cpp @@ -83,6 +83,18 @@ void wxDisplaySize(int *width, int *height) *height = (int)bounds.size.height; } +#if wxUSE_BASE + +void wxMacWakeUp() +{ + wxEventLoopBase * const loop = wxEventLoopBase::GetActive(); + + if ( loop ) + loop->WakeUp(); +} + +#endif + #if wxUSE_GUI // ---------------------------------------------------------------------------- -- 2.45.2