Cocoa: Add env variable for disabling foreground.
authorMorten Sorvig <morten.sorvig@nokia.com>
Tue, 4 Oct 2011 07:54:38 +0000 (09:54 +0200)
committerQt by Nokia <qt-info@nokia.com>
Tue, 4 Oct 2011 11:29:13 +0000 (13:29 +0200)
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 <qt_sanity_bot@ovi.com>
Reviewed-by: Zeno Albisser <zeno.albisser@nokia.com>
src/plugins/platforms/cocoa/qcocoaintegration.mm

index bb17c8e..6399314 100644 (file)
@@ -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();
-
-    // 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];
+    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];
+    }
 
     // ### For AA_MacPluginApplication we don't want to load the menu nib.
     // Qt 4 also does not set the application delegate, so that behavior