macOS: Extend QCocoaScreen logging

Change-Id: I91f89ff336b3f48aea91e50860264bd8359805cb
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
bb10
Tor Arne Vestbø 2019-10-27 18:29:03 +01:00
parent 5982451ac6
commit 3ee634d520
1 changed files with 31 additions and 3 deletions

View File

@ -54,6 +54,23 @@
QT_BEGIN_NAMESPACE
namespace CoreGraphics {
Q_NAMESPACE
enum DisplayChange {
Moved = kCGDisplayMovedFlag,
SetMain = kCGDisplaySetMainFlag,
SetMode = kCGDisplaySetModeFlag,
Added = kCGDisplayAddFlag,
Removed = kCGDisplayRemoveFlag,
Enabled = kCGDisplayEnabledFlag,
Disabled = kCGDisplayDisabledFlag,
Mirrored = kCGDisplayMirrorFlag,
UnMirrored = kCGDisplayUnMirrorFlag,
DesktopShapeChanged = kCGDisplayDesktopShapeChangedFlag
};
Q_ENUM_NS(DisplayChange)
}
void QCocoaScreen::initializeScreens()
{
uint32_t displayCount = 0;
@ -73,6 +90,10 @@ void QCocoaScreen::initializeScreens()
Q_UNUSED(userInfo);
qCDebug(lcQpaScreen).verbosity(0).nospace() << "Display reconfiguration"
<< " (" << QFlags<CoreGraphics::DisplayChange>(flags) << ")"
<< " for displayId=" << displayId;
QCocoaScreen *cocoaScreen = QCocoaScreen::get(displayId);
if ((flags & kCGDisplayAddFlag) || !cocoaScreen) {
@ -99,16 +120,19 @@ void QCocoaScreen::initializeScreens()
return; // Already reconfigured
cocoaScreen->updateProperties();
qCInfo(lcQpaScreen) << "Reconfigured" << cocoaScreen;
qCInfo(lcQpaScreen).nospace() << "Reconfigured " <<
(primaryScreen() == cocoaScreen ? "primary " : "")
<< cocoaScreen;
}
}, nullptr);
}
void QCocoaScreen::add(CGDirectDisplayID displayId)
{
const bool isPrimary = CGDisplayIsMain(displayId);
QCocoaScreen *cocoaScreen = new QCocoaScreen(displayId);
qCInfo(lcQpaScreen) << "Adding" << cocoaScreen;
QWindowSystemInterface::handleScreenAdded(cocoaScreen, CGDisplayIsMain(displayId));
qCInfo(lcQpaScreen).nospace() << "Adding " << (isPrimary ? "new primary " : "") << cocoaScreen;
QWindowSystemInterface::handleScreenAdded(cocoaScreen, isPrimary);
}
QCocoaScreen::QCocoaScreen(CGDirectDisplayID displayId)
@ -140,6 +164,7 @@ void QCocoaScreen::remove()
// QCocoaWindow::windowDidChangeScreen. At that point the window will appear to have
// already changed its screen, but that's only true if comparing the Qt screens,
// not when comparing the NSScreens.
qCInfo(lcQpaScreen).nospace() << "Removing " << (primaryScreen() == this ? "current primary " : "") << this;
QWindowSystemInterface::handleScreenRemoved(this);
}
@ -639,6 +664,7 @@ QDebug operator<<(QDebug debug, const QCocoaScreen *screen)
debug << ", geometry=" << screen->geometry();
debug << ", dpr=" << screen->devicePixelRatio();
debug << ", name=" << screen->name();
debug << ", displayId=" << screen->m_displayId;
debug << ", native=" << screen->nativeScreen();
}
debug << ')';
@ -646,6 +672,8 @@ QDebug operator<<(QDebug debug, const QCocoaScreen *screen)
}
#endif // !QT_NO_DEBUG_STREAM
#include "qcocoascreen.moc"
QT_END_NAMESPACE
@implementation NSScreen (QtExtras)