Update qcocoascreen.mm

This commit is contained in:
kleuter 2019-11-29 21:35:30 +01:00
parent 8c4fcbf49e
commit e7f4cef233

View File

@ -131,7 +131,7 @@ void QCocoaScreen::initializeScreens()
} }
}, nullptr); }, nullptr);
static QMacNotificationObserver screenParamaterObserver(NSApplication.sharedApplication, static QMacNotificationObserver screenParameterObserver(NSApplication.sharedApplication,
NSApplicationDidChangeScreenParametersNotification, [&]() { NSApplicationDidChangeScreenParametersNotification, [&]() {
qCDebug(lcQpaScreen) << "Received screen parameter change notification"; qCDebug(lcQpaScreen) << "Received screen parameter change notification";
updateScreensIfNeeded(); // As a last resort we update screens here updateScreensIfNeeded(); // As a last resort we update screens here
@ -187,7 +187,7 @@ void QCocoaScreen::updateScreens()
for (CGDirectDisplayID displayId : onlineDisplays) { for (CGDirectDisplayID displayId : onlineDisplays) {
Q_ASSERT(CGDisplayIsOnline(displayId)); Q_ASSERT(CGDisplayIsOnline(displayId));
if (CGDirectDisplayID mirroring = CGDisplayMirrorsDisplay(displayId)) if (CGDisplayMirrorsDisplay(displayId))
continue; continue;
// A single physical screen can map to multiple displays IDs, // A single physical screen can map to multiple displays IDs,
@ -213,9 +213,7 @@ void QCocoaScreen::updateScreens()
for (QScreen *screen : QGuiApplication::screens()) { for (QScreen *screen : QGuiApplication::screens()) {
QCocoaScreen *platformScreen = static_cast<QCocoaScreen*>(screen->handle()); QCocoaScreen *platformScreen = static_cast<QCocoaScreen*>(screen->handle());
if (!platformScreen->isOnline()) if (!platformScreen->isOnline() || platformScreen->isMirroring())
platformScreen->remove();
else if (platformScreen->isMirroring())
platformScreen->remove(); platformScreen->remove();
} }
} }