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. Pick-to: 6.2 6.3 6.4 Change-Id: Ie75430df1a80808cb7b23d97d1e440d1f3bf75d6 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
5909e33d1d
commit
f7a56b32cc
@ -183,6 +183,7 @@ QCocoaScreen::~QCocoaScreen()
|
|||||||
dispatch_release(m_displayLinkSource);
|
dispatch_release(m_displayLinkSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if QT_MACOS_DEPLOYMENT_TARGET_BELOW(__MAC_10_15)
|
||||||
static QString displayName(CGDirectDisplayID displayID)
|
static QString displayName(CGDirectDisplayID displayID)
|
||||||
{
|
{
|
||||||
QIOType<io_iterator_t> iterator;
|
QIOType<io_iterator_t> iterator;
|
||||||
@ -214,6 +215,7 @@ static QString displayName(CGDirectDisplayID displayID)
|
|||||||
|
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void QCocoaScreen::update(CGDirectDisplayID displayId)
|
void QCocoaScreen::update(CGDirectDisplayID displayId)
|
||||||
{
|
{
|
||||||
@ -257,6 +259,9 @@ void QCocoaScreen::update(CGDirectDisplayID displayId)
|
|||||||
float refresh = CGDisplayModeGetRefreshRate(displayMode);
|
float refresh = CGDisplayModeGetRefreshRate(displayMode);
|
||||||
m_refreshRate = refresh > 0 ? refresh : 60.0;
|
m_refreshRate = refresh > 0 ? refresh : 60.0;
|
||||||
|
|
||||||
|
if (@available(macOS 10.15, *))
|
||||||
|
m_name = QString::fromNSString(nsScreen.localizedName);
|
||||||
|
else
|
||||||
m_name = displayName(m_displayId);
|
m_name = displayName(m_displayId);
|
||||||
|
|
||||||
const bool didChangeGeometry = m_geometry != previousGeometry || m_availableGeometry != previousAvailableGeometry;
|
const bool didChangeGeometry = m_geometry != previousGeometry || m_availableGeometry != previousAvailableGeometry;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user