summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@qt.io>2016-12-02 12:03:02 +0100
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2016-12-08 23:50:52 +0000
commit2c9dc93696f32b798b872f931c102329d0ba7155 (patch)
tree6a25377f2eae0b94b5f1e4c192302bf1834aaeb5 /src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
parentaec85a53df3dbe3047c6db0f6eb39cb161cd3e6b (diff)
Cocoa: Unbreak app activation on macOS Sierra
Previously, we would activate the application during QCocoaIntegration construction, which means at QApplication creation time. This now seems to interfere with application startup on macOS Sierra, where the application window ends up in an unfocused state. Move application activation to applicationDidFinishLaunching, at which point the Cocoa runtime should be completely initialized. Do this for 10.12+ only to avoid regressions/ test failures on previous versions. Change-Id: Ic5f150d53f06a302b53a3ba86a4a9b18bb2a1783 Task-number: QTBUG-57044 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm')
-rw-r--r--src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
index da755aa189..7368aabf7d 100644
--- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
+++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
@@ -282,14 +282,18 @@ QT_END_NAMESPACE
{
Q_UNUSED(aNotification);
inLaunch = false;
- // qt_release_apple_event_handler();
-
- // Insert code here to initialize your application
+ if (qEnvironmentVariableIsEmpty("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM")) {
+ if (QSysInfo::macVersion() >= QSysInfo::MV_10_12) {
+ // 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.)
+ [[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
+ }
+ }
}
-
-
- (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames
{
Q_UNUSED(filenames);