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>
This commit is contained in:
parent
aec85a53df
commit
2c9dc93696
@ -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);
|
||||
|
@ -312,11 +312,15 @@ QCocoaIntegration::QCocoaIntegration(const QStringList ¶mList)
|
||||
// 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 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.
|
||||
|
Loading…
Reference in New Issue
Block a user