]> git.saurik.com Git - wxWidgets.git/commitdiff
common wxMacWakeUp code across all platforms
authorStefan Csomor <csomor@advancedconcepts.ch>
Wed, 19 May 2010 08:26:59 +0000 (08:26 +0000)
committerStefan Csomor <csomor@advancedconcepts.ch>
Wed, 19 May 2010 08:26:59 +0000 (08:26 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64343 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/osx/carbon/app.cpp
src/osx/carbon/utils.cpp
src/osx/cocoa/utils.mm
src/osx/iphone/utils.mm
src/osx/utils_osx.cpp

index 273c280db6d086c70ac755393672dc1e9f6b6917..7e03354c972efe3817f18259801ff0ebb7202226 100644 (file)
@@ -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))
index c16c5ddb292d01aa4ffc731d981f3d89fdf760de..c6275209fc687b85921639e0220b33f8fd25a69a 100644 (file)
@@ -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
 
 // ----------------------------------------------------------------------------
index 81f1d186f846820cf3e7bd297266bb2adaf88d54..59420be784a28528135c493c98b9ae4f4c491b22 100644 (file)
@@ -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;
 }
index 884a2d16e0e1cb42d3b0ed44dafd8639b0f361d2..55d5527c6a3c705c4fa9104229031eb92da765a6 100644 (file)
@@ -87,11 +87,6 @@ void wxApp::DoCleanUp()
 {
 }
 
-void wxMacWakeUp()
-{
-    // TODO
-}
-
 #endif // wxUSE_BASE
 
 #if wxUSE_GUI
index c7adb418110dc1f4527250b5afe869fa10bf4b57..9b6eeaa80e8e40f29adc03174c0de3d94e98ecd4 100644 (file)
@@ -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
 
 // ----------------------------------------------------------------------------