From a5218939d66dc93bf41741e1118a49e519845bc7 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Sat, 16 Nov 2013 07:19:15 +0000 Subject: [PATCH] porting fix for non-bundled apps to 3.0.1 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_3_0_BRANCH@75201 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/osx/cocoa/utils.mm | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/osx/cocoa/utils.mm b/src/osx/cocoa/utils.mm index 55e08c7965..456523f5f9 100644 --- a/src/osx/cocoa/utils.mm +++ b/src/osx/cocoa/utils.mm @@ -276,6 +276,24 @@ void wxBell() return self; } +- (void) transformToForegroundApplication { + ProcessSerialNumber psn = { 0, kCurrentProcess }; + TransformProcessType(&psn, kProcessTransformToForegroundApplication); + + if ( UMAGetSystemVersion() < 0x1090 ) + { + [self deactivate]; + [self activateIgnoringOtherApps:YES]; + } + else + { + [[NSRunningApplication currentApplication] activateWithOptions: + (NSApplicationActivateAllWindows | NSApplicationActivateIgnoringOtherApps)]; + } +} + + + /* This is needed because otherwise we don't receive any key-up events for command-key combinations (an AppKit bug, apparently) */ - (void)sendEvent:(NSEvent *)anEvent @@ -312,6 +330,20 @@ bool wxApp::DoInitGui() { [wxNSApplication sharedApplication]; + if ( OSXIsGUIApplication() ) + { + CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle() ) ; + CFStringRef path = CFURLCopyFileSystemPath ( url , kCFURLPOSIXPathStyle ) ; + CFRelease( url ) ; + wxString app = wxCFStringRef(path).AsString(wxLocale::GetSystemEncoding()); + + // workaround is only needed for non-bundled apps + if ( !app.EndsWith(".app") ) + { + [(wxNSApplication*) [wxNSApplication sharedApplication] transformToForegroundApplication]; + } + } + appcontroller = OSXCreateAppController(); [NSApp setDelegate:appcontroller]; [NSColor setIgnoresAlpha:NO];