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:
parent
5c014a48dc
commit
10565c5ef3
@ -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];
|
||||
|
@ -144,6 +144,7 @@ private:
|
||||
#endif
|
||||
QScopedPointer<QPlatformTheme> mPlatformTheme;
|
||||
QList<QCocoaScreen *> mScreens;
|
||||
QMacScopedObserver m_screensObserver;
|
||||
#ifndef QT_NO_CLIPBOARD
|
||||
QCocoaClipboard *mCocoaClipboard;
|
||||
#endif
|
||||
|
@ -206,6 +206,9 @@ QCocoaIntegration::QCocoaIntegration(const QStringList ¶mList)
|
||||
// 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();
|
||||
|
Loading…
Reference in New Issue
Block a user