diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2022-06-13 13:12:13 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2022-06-13 21:17:53 +0200 |
commit | f7a56b32cc127e340e81e3e1cdb3f24f912863af (patch) | |
tree | 05d55cf948299ea46343105a547845ba504bbac2 /src/plugins/platforms/cocoa | |
parent | 5909e33d1dea34daef271598eb1c9dd06a238801 (diff) |
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>
Diffstat (limited to 'src/plugins/platforms/cocoa')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoascreen.mm | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoascreen.mm b/src/plugins/platforms/cocoa/qcocoascreen.mm index 923e5c09ad..20efa30d3b 100644 --- a/src/plugins/platforms/cocoa/qcocoascreen.mm +++ b/src/plugins/platforms/cocoa/qcocoascreen.mm @@ -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; |