X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/cfb0ef701eb4d8043b91822931ca0e6e3af5fddc..13390af486a8b9b72408260f6d89309870a43812:/src/osx/cocoa/evtloop.mm?ds=sidebyside diff --git a/src/osx/cocoa/evtloop.mm b/src/osx/cocoa/evtloop.mm index bcd24e8405..89957cd2bd 100644 --- a/src/osx/cocoa/evtloop.mm +++ b/src/osx/cocoa/evtloop.mm @@ -118,10 +118,16 @@ bool wxGUIEventLoop::Dispatch() inMode:NSDefaultRunLoopMode dequeue: YES]) { + WXEVENTREF formerEvent = wxTheApp == NULL ? NULL : wxTheApp->MacGetCurrentEvent(); + WXEVENTHANDLERCALLREF formerHandler = wxTheApp == NULL ? NULL : wxTheApp->MacGetCurrentEventHandlerCallRef(); + if (wxTheApp) wxTheApp->MacSetCurrentEvent(event, NULL); m_sleepTime = 0.0; [NSApp sendEvent: event]; + + if (wxTheApp) + wxTheApp->MacSetCurrentEvent(formerEvent , formerHandler); } else { @@ -173,8 +179,25 @@ void wxGUIEventLoop::DoRun() void wxGUIEventLoop::DoStop() { [NSApp stop:0]; + // only calling stop: is not enough when called from a runloop-observer, + // therefore add a dummy event, to make sure the runloop gets another round + NSEvent *event = [NSEvent otherEventWithType:NSApplicationDefined + location:NSMakePoint(0.0, 0.0) + modifierFlags:0 + timestamp:0 + windowNumber:0 + context:nil + subtype:0 data1:0 data2:0]; + [NSApp postEvent:event atStart:FALSE]; } +CFRunLoopRef wxGUIEventLoop::CFGetCurrentRunLoop() const +{ + NSRunLoop* nsloop = [NSRunLoop currentRunLoop]; + return [nsloop getCFRunLoop]; +} + + // TODO move into a evtloop_osx.cpp wxModalEventLoop::wxModalEventLoop(wxWindow *modalWindow)