mirror of https://github.com/mpv-player/mpv
mac: change display name retrieval to localizedName NSScreen property
the old displayName property via the IODisplay API is not working anymore on ARM based macs and was broken in at least one other case. instead we use the new localizedName property introduced in 10.15 of the NSScreen. we don't need any backwards compatibility since 10.15 is the oldest version we support now. configs and scripts that use the options and properties fs-screen-name, screen-name or display-names need to be adjusted since the names could differ from the previous implementation via the IODisplay API. Fixes #9697
This commit is contained in:
parent
040a921964
commit
a54cc02341
|
@ -115,6 +115,8 @@ Interface changes
|
||||||
- add hdr metadata to `video-params` property
|
- add hdr metadata to `video-params` property
|
||||||
- remove `hdr-metadata` property
|
- remove `hdr-metadata` property
|
||||||
- add `--target-gamut`
|
- add `--target-gamut`
|
||||||
|
- change the way display names are retrieved on macOS, usage of options and properties
|
||||||
|
`--fs-screen-name`, `--screen-name` and `display-names` needs to be adjusted
|
||||||
--- mpv 0.36.0 ---
|
--- mpv 0.36.0 ---
|
||||||
- add `--target-contrast`
|
- add `--target-contrast`
|
||||||
- Target luminance value is now also applied when ICC profile is used.
|
- Target luminance value is now also applied when ICC profile is used.
|
||||||
|
|
|
@ -28,37 +28,6 @@ extension NSScreen {
|
||||||
return deviceDescription[.screenNumber] as? CGDirectDisplayID ?? 0
|
return deviceDescription[.screenNumber] as? CGDirectDisplayID ?? 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public var displayName: String? {
|
|
||||||
get {
|
|
||||||
var name: String? = nil
|
|
||||||
var object: io_object_t
|
|
||||||
var iter = io_iterator_t()
|
|
||||||
let matching = IOServiceMatching("IODisplayConnect")
|
|
||||||
let result = IOServiceGetMatchingServices(kIOMasterPortDefault, matching, &iter)
|
|
||||||
|
|
||||||
if result != KERN_SUCCESS || iter == 0 { return nil }
|
|
||||||
|
|
||||||
repeat {
|
|
||||||
object = IOIteratorNext(iter)
|
|
||||||
if let info = IODisplayCreateInfoDictionary(object, IOOptionBits(kIODisplayOnlyPreferredName)).takeRetainedValue() as? [String:AnyObject],
|
|
||||||
(info[kDisplayVendorID] as? UInt32 == CGDisplayVendorNumber(displayID) &&
|
|
||||||
info[kDisplayProductID] as? UInt32 == CGDisplayModelNumber(displayID) &&
|
|
||||||
info[kDisplaySerialNumber] as? UInt32 ?? 0 == CGDisplaySerialNumber(displayID))
|
|
||||||
{
|
|
||||||
if let productNames = info["DisplayProductName"] as? [String:String],
|
|
||||||
let productName = productNames.first?.value
|
|
||||||
{
|
|
||||||
name = productName
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} while object != 0
|
|
||||||
|
|
||||||
IOObjectRelease(iter)
|
|
||||||
return name
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extension NSColor {
|
extension NSColor {
|
||||||
|
|
|
@ -396,7 +396,7 @@ class Common: NSObject {
|
||||||
|
|
||||||
func getScreenBy(name screenName: String?) -> NSScreen? {
|
func getScreenBy(name screenName: String?) -> NSScreen? {
|
||||||
for screen in NSScreen.screens {
|
for screen in NSScreen.screens {
|
||||||
if screen.displayName == screenName {
|
if screen.localizedName == screenName {
|
||||||
return screen
|
return screen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -628,7 +628,7 @@ class Common: NSObject {
|
||||||
let dnames = data!.assumingMemoryBound(to: UnsafeMutablePointer<UnsafeMutablePointer<Int8>?>?.self)
|
let dnames = data!.assumingMemoryBound(to: UnsafeMutablePointer<UnsafeMutablePointer<Int8>?>?.self)
|
||||||
var array: UnsafeMutablePointer<UnsafeMutablePointer<Int8>?>? = nil
|
var array: UnsafeMutablePointer<UnsafeMutablePointer<Int8>?>? = nil
|
||||||
var count: Int32 = 0
|
var count: Int32 = 0
|
||||||
let displayName = getCurrentScreen()?.displayName ?? "Unknown"
|
let displayName = getCurrentScreen()?.localizedName ?? "Unknown"
|
||||||
|
|
||||||
SWIFT_TARRAY_STRING_APPEND(nil, &array, &count, ta_xstrdup(nil, displayName))
|
SWIFT_TARRAY_STRING_APPEND(nil, &array, &count, ta_xstrdup(nil, displayName))
|
||||||
SWIFT_TARRAY_STRING_APPEND(nil, &array, &count, nil)
|
SWIFT_TARRAY_STRING_APPEND(nil, &array, &count, nil)
|
||||||
|
|
Loading…
Reference in New Issue