macOS: Resolve screen name via NSScreen on macOS 10.15+
Apple Silicon Macs no longer expose display information through IOKit. Luckily we can use the 10.15 localizedName property on NSString to resolve the name. Change-Id: Ie75430df1a80808cb7b23d97d1e440d1f3bf75d6 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit f7a56b32cc127e340e81e3e1cdb3f24f912863af) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
72adcf591e
commit
68f1d34a77
@ -183,6 +183,7 @@ QCocoaScreen::~QCocoaScreen()
|
||||
dispatch_release(m_displayLinkSource);
|
||||
}
|
||||
|
||||
#if QT_MACOS_DEPLOYMENT_TARGET_BELOW(__MAC_10_15)
|
||||
static QString displayName(CGDirectDisplayID displayID)
|
||||
{
|
||||
QIOType<io_iterator_t> iterator;
|
||||
@ -214,6 +215,7 @@ static QString displayName(CGDirectDisplayID displayID)
|
||||
|
||||
return QString();
|
||||
}
|
||||
#endif
|
||||
|
||||
void QCocoaScreen::update(CGDirectDisplayID displayId)
|
||||
{
|
||||
@ -257,7 +259,10 @@ void QCocoaScreen::update(CGDirectDisplayID displayId)
|
||||
float refresh = CGDisplayModeGetRefreshRate(displayMode);
|
||||
m_refreshRate = refresh > 0 ? refresh : 60.0;
|
||||
|
||||
m_name = displayName(m_displayId);
|
||||
if (@available(macOS 10.15, *))
|
||||
m_name = QString::fromNSString(nsScreen.localizedName);
|
||||
else
|
||||
m_name = displayName(m_displayId);
|
||||
|
||||
const bool didChangeGeometry = m_geometry != previousGeometry || m_availableGeometry != previousAvailableGeometry;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user