From 5066c914bdf8a911eb769abb4003e154334a459c Mon Sep 17 00:00:00 2001 From: Morten Sorvig Date: Tue, 4 Oct 2011 09:54:38 +0200 Subject: [PATCH] Cocoa: Add env variable for disabling foreground. Setting QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM prevents the process from having an dock icon and taking focus. Change-Id: Id127967d8ec1dadda790128f36a7c1f50d581433 Reviewed-on: http://codereview.qt-project.org/5968 Reviewed-by: Qt Sanity Bot Reviewed-by: Zeno Albisser --- .../platforms/cocoa/qcocoaintegration.mm | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index bb17c8eef7..63993146bd 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -87,18 +87,20 @@ QCocoaIntegration::QCocoaIntegration() QNSApplication *cocoaApplication = [QNSApplication sharedApplication]; - // Applications launched from plain executables (without an app - // bundle) are "background" applications that does not take keybaord - // focus or have a dock icon or task switcher entry. Qt Gui apps generally - // wants to be foreground applications so change the process type. (But - // see the function implementation for exceptions.) - qt_mac_transformProccessToForegroundApplication(); + if (qgetenv("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM").isEmpty()) { + // Applications launched from plain executables (without an app + // bundle) are "background" applications that does not take keybaord + // focus or have a dock icon or task switcher entry. Qt Gui apps generally + // wants to be foreground applications so change the process type. (But + // see the function implementation for exceptions.) + qt_mac_transformProccessToForegroundApplication(); - // Move the application window to front to avoid launching behind the terminal. - // Ignoring other apps is neccessary (we must ignore the terminal), but makes - // Qt apps play slightly less nice with other apps when lanching from Finder - // (See the activateIgnoringOtherApps docs.) - [cocoaApplication activateIgnoringOtherApps : YES]; + // Move the application window to front to avoid launching behind the terminal. + // Ignoring other apps is neccessary (we must ignore the terminal), but makes + // Qt apps play slightly less nice with other apps when lanching from Finder + // (See the activateIgnoringOtherApps docs.) + [cocoaApplication activateIgnoringOtherApps : YES]; + } // ### For AA_MacPluginApplication we don't want to load the menu nib. // Qt 4 also does not set the application delegate, so that behavior