X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/bf06fbce415a5b923de735aae3fe306619268594..8ba4faba4de4af7613911d83263b9470e5bb1207:/src/osx/carbon/evtloop.cpp?ds=inline diff --git a/src/osx/carbon/evtloop.cpp b/src/osx/carbon/evtloop.cpp index f208d9801c..d263effec7 100644 --- a/src/osx/carbon/evtloop.cpp +++ b/src/osx/carbon/evtloop.cpp @@ -29,9 +29,12 @@ #ifndef WX_PRECOMP #include "wx/app.h" #include "wx/log.h" - #include "wx/nonownedwnd.h" #endif // WX_PRECOMP +#if wxUSE_GUI +#include "wx/nonownedwnd.h" +#endif + #include "wx/osx/private.h" // ============================================================================ @@ -57,7 +60,7 @@ static void DispatchAndReleaseEvent(EventRef theEvent) int wxGUIEventLoop::DoDispatchTimeout(unsigned long timeout) { wxMacAutoreleasePool autoreleasepool; - + EventRef event; OSStatus status = ReceiveNextEvent(0, NULL, timeout/1000, true, &event); switch ( status ) @@ -80,6 +83,16 @@ int wxGUIEventLoop::DoDispatchTimeout(unsigned long timeout) } } +void wxGUIEventLoop::WakeUp() +{ + OSStatus err = noErr; + wxMacCarbonEvent wakeupEvent; + wakeupEvent.Create( 'WXMC', 'WXMC', GetCurrentEventTime(), + kEventAttributeNone ); + err = PostEventToQueue(GetMainEventQueue(), wakeupEvent, + kEventPriorityHigh ); +} + void wxGUIEventLoop::DoRun() { wxMacAutoreleasePool autoreleasepool; @@ -91,31 +104,57 @@ void wxGUIEventLoop::DoStop() QuitApplicationEventLoop(); } +CFRunLoopRef wxGUIEventLoop::CFGetCurrentRunLoop() const +{ + return wxCFEventLoop::CFGetCurrentRunLoop(); +} + +// TODO move into a evtloop_osx.cpp + +wxModalEventLoop::wxModalEventLoop(wxWindow *modalWindow) +{ + m_modalWindow = wxDynamicCast(modalWindow, wxNonOwnedWindow); + wxASSERT_MSG( m_modalWindow != NULL, "must pass in a toplevel window for modal event loop" ); + m_modalNativeWindow = m_modalWindow->GetWXWindow(); +} + +wxModalEventLoop::wxModalEventLoop(WXWindow modalNativeWindow) +{ + m_modalWindow = NULL; + wxASSERT_MSG( modalNativeWindow != NULL, "must pass in a toplevel window for modal event loop" ); + m_modalNativeWindow = modalNativeWindow; +} + +// END move into a evtloop_osx.cpp + void wxModalEventLoop::DoRun() { + wxWindowDisabler disabler(m_modalWindow); wxMacAutoreleasePool autoreleasepool; - WindowRef windowRef = m_modalWindow->GetWXWindow(); + + bool resetGroupParent = false; WindowGroupRef windowGroup = NULL; WindowGroupRef formerParentGroup = NULL; - bool resetGroupParent = false; - + // make sure modal dialogs are in the right layer so that they are not covered - - if ( m_modalWindow->GetParent() == NULL ) + if ( m_modalWindow != NULL ) { - windowGroup = GetWindowGroup(windowRef) ; - if ( windowGroup != GetWindowGroupOfClass( kMovableModalWindowClass ) ) + if ( m_modalWindow->GetParent() == NULL ) { - formerParentGroup = GetWindowGroupParent( windowGroup ); - SetWindowGroupParent( windowGroup, GetWindowGroupOfClass( kMovableModalWindowClass ) ); - resetGroupParent = true; + windowGroup = GetWindowGroup(m_modalNativeWindow) ; + if ( windowGroup != GetWindowGroupOfClass( kMovableModalWindowClass ) ) + { + formerParentGroup = GetWindowGroupParent( windowGroup ); + SetWindowGroupParent( windowGroup, GetWindowGroupOfClass( kMovableModalWindowClass ) ); + resetGroupParent = true; + } } } m_modalWindow->SetFocus(); - - RunAppModalLoopForWindow(windowRef); + + RunAppModalLoopForWindow(m_modalNativeWindow); if ( resetGroupParent ) { @@ -127,8 +166,7 @@ void wxModalEventLoop::DoRun() void wxModalEventLoop::DoStop() { wxMacAutoreleasePool autoreleasepool; - WindowRef theWindow = m_modalWindow->GetWXWindow(); - QuitAppModalLoopForWindow(theWindow); + QuitAppModalLoopForWindow(m_modalNativeWindow); }