common wxMacWakeUp code across all platforms
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64343 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -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))
|
||||
|
@@ -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
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -87,11 +87,6 @@ void wxApp::DoCleanUp()
|
||||
{
|
||||
}
|
||||
|
||||
void wxMacWakeUp()
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
#endif // wxUSE_BASE
|
||||
|
||||
#if wxUSE_GUI
|
||||
|
@@ -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
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user