macOS: Decouple screen property updates from application delegate

Change-Id: I489c37131bf715d45f147964de4a8cd8c02adbcb
Fixes: QTBUG-72966
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Tor Arne Vestbø 2019-02-13 15:49:26 +01:00
parent 5c014a48dc
commit 10565c5ef3
3 changed files with 4 additions and 12 deletions

View File

@ -115,22 +115,10 @@ QT_USE_NAMESPACE
self = [super init];
if (self) {
inLaunch = true;
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(updateScreens:)
name:NSApplicationDidChangeScreenParametersNotification
object:NSApp];
}
return self;
}
- (void)updateScreens:(NSNotification *)notification
{
Q_UNUSED(notification);
if (QCocoaIntegration *ci = QCocoaIntegration::instance())
ci->updateScreens();
}
- (void)dealloc
{
[_dockMenu release];

View File

@ -144,6 +144,7 @@ private:
#endif
QScopedPointer<QPlatformTheme> mPlatformTheme;
QList<QCocoaScreen *> mScreens;
QMacScopedObserver m_screensObserver;
#ifndef QT_NO_CLIPBOARD
QCocoaClipboard *mCocoaClipboard;
#endif

View File

@ -206,6 +206,9 @@ QCocoaIntegration::QCocoaIntegration(const QStringList &paramList)
// by explicitly setting the presentation option to the magic 'default value',
// which will resolve to an actual value and result in screen invalidation.
cocoaApplication.presentationOptions = NSApplicationPresentationDefault;
m_screensObserver = QMacScopedObserver([NSApplication sharedApplication],
NSApplicationDidChangeScreenParametersNotification, [&]() { updateScreens(); });
updateScreens();
QMacInternalPasteboardMime::initializeMimeTypes();