summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@qt.io>2016-12-02 12:03:02 +0100
committerMorten Johan Sørvig <morten.sorvig@qt.io>2017-04-12 10:27:51 +0000
commitd6c232535c760a64e6e998b1aeef2885b8bb1c96 (patch)
treed47018f41491b61394ab57d8898db4517c16cd54
parent58ac1fd7a0533eb5ae83b7df2a25afd291c4083c (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. Task-number: QTBUG-57044 Change-Id: If6248753236d7473db2b8513dba0368901f3f4cf (cherry picked from commit 2c9dc93696f32b798b872f931c102329d0ba7155) Reviewed-by: Andy Shaw <andy.shaw@qt.io>
-rw-r--r--src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm14
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.mm14
2 files changed, 18 insertions, 10 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
index caa8884661..7ae1d0cc42 100644
--- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
+++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
@@ -289,14 +289,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 necessary (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);
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm
index 659c803a19..05600e0d1a 100644
--- a/src/plugins/platforms/cocoa/qcocoaintegration.mm
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm
@@ -307,11 +307,15 @@ QCocoaIntegration::QCocoaIntegration(const QStringList &paramList)
// 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 make it take focus, also when launching
+ // from the terminal. On 10.12+ this call has been moved to applicationDidFinishLauching
+ // to work around issues with loss of focus at startup.
+ if (QSysInfo::macVersion() < QSysInfo::MV_10_12) {
+ // Ignoring other apps is necessary (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.