From 8c1be5e34d1d4b036221f503cb017d06a2c1f69e Mon Sep 17 00:00:00 2001 From: waydabber <37590873+waydabber@users.noreply.github.com> Date: Sun, 14 Nov 2021 23:10:53 +0100 Subject: [PATCH 1/5] Fixing Samsung 28E850 treated as a dummy. --- MonitorControl/Info.plist | 2 +- MonitorControl/Support/Arm64DDC.swift | 21 ++++++++++++--------- MonitorControl/Support/DisplayManager.swift | 8 ++++++-- MonitorControlHelper/Info.plist | 2 +- README.md | 4 ---- 5 files changed, 20 insertions(+), 17 deletions(-) diff --git a/MonitorControl/Info.plist b/MonitorControl/Info.plist index 3537c98e..85621d8b 100644 --- a/MonitorControl/Info.plist +++ b/MonitorControl/Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString $(MARKETING_VERSION) CFBundleVersion - 6956 + 6957 LSApplicationCategoryType public.app-category.utilities LSMinimumSystemVersion diff --git a/MonitorControl/Support/Arm64DDC.swift b/MonitorControl/Support/Arm64DDC.swift index c08ae7f9..2ac3855b 100644 --- a/MonitorControl/Support/Arm64DDC.swift +++ b/MonitorControl/Support/Arm64DDC.swift @@ -9,6 +9,7 @@ class Arm64DDC: NSObject { var service: IOAVService? var serviceLocation: Int = 0 var isDiscouraged: Bool = false + var isDummy: Bool = false } #if arch(arm64) @@ -26,7 +27,8 @@ class Arm64DDC: NSObject { for ioregServiceForMatching in ioregServicesForMatching { let score = self.ioregMatchScore(displayID: displayID, ioregEdidUUID: ioregServiceForMatching.edidUUID, ioregProductName: ioregServiceForMatching.productName, ioregSerialNumber: ioregServiceForMatching.serialNumber, serviceLocation: ioregServiceForMatching.serviceLocation) let isDiscouraged = self.checkIfDiscouraged(ioregService: ioregServiceForMatching) - let displayService = DisplayService(displayID: displayID, service: ioregServiceForMatching.service, serviceLocation: ioregServiceForMatching.serviceLocation, isDiscouraged: isDiscouraged) + let isDummy = self.checkIfDummy(ioregService: ioregServiceForMatching) + let displayService = DisplayService(displayID: displayID, service: ioregServiceForMatching.service, serviceLocation: ioregServiceForMatching.serviceLocation, isDiscouraged: isDiscouraged, isDummy: isDummy) if scoredCandidateDisplayServices[score] == nil { scoredCandidateDisplayServices[score] = [] } @@ -260,6 +262,15 @@ class Arm64DDC: NSObject { return ioregServicesForMatching } + // Check if display is a dummy + private static func checkIfDummy(ioregService: IOregService) -> Bool { + // This is a well known dummy plug + if ioregService.manufacturerID == "AOC", ioregService.productName == "28E850" { + return true + } + return false + } + // Check if it is problematic to enable DDC on the display private static func checkIfDiscouraged(ioregService: IOregService) -> Bool { var modelIdentifier: String = "" @@ -267,14 +278,6 @@ class Arm64DDC: NSObject { if let modelData = IORegistryEntryCreateCFProperty(platformExpertDevice, "model" as CFString, kCFAllocatorDefault, 0).takeRetainedValue() as? Data, let modelIdentifierCString = String(data: modelData, encoding: .utf8)?.cString(using: .utf8) { modelIdentifier = String(cString: modelIdentifierCString) } - // This is a well known dummy plug (not a real display) but it breaks DDC communication on M1 - if ioregService.manufacturerID == "AOC", ioregService.productName == "28E850" { - return true - } - // If the display contains the string "Dummy", then it is highly suspicious - if ioregService.productName.contains("Dummy") || ioregService.productName.contains("dummy") { - return true - } // First service location of Mac Mini HDMI is broken for DDC communication if ioregService.transportDownstream == "HDMI", ioregService.serviceLocation == 1, modelIdentifier == "Macmini9,1" { return true diff --git a/MonitorControl/Support/DisplayManager.swift b/MonitorControl/Support/DisplayManager.swift index 062e2485..f6e07a3f 100644 --- a/MonitorControl/Support/DisplayManager.swift +++ b/MonitorControl/Support/DisplayManager.swift @@ -313,7 +313,11 @@ class DisplayManager { os_log("Display service match successful for display %{public}@", type: .info, String(serviceMatch.displayID)) if serviceMatch.isDiscouraged { os_log("Display %{public}@ is flagged as discouraged by Arm64DDC.", type: .info, String(serviceMatch.displayID)) - otherDisplay.isDiscouraged = serviceMatch.isDiscouraged + otherDisplay.isDiscouraged = true + } else if serviceMatch.isDummy { + os_log("Display %{public}@ is flagged as dummy by Arm64DDC.", type: .info, String(serviceMatch.displayID)) + otherDisplay.isDiscouraged = true + otherDisplay.isDummy = true } else { otherDisplay.arm64ddc = DEBUG_SW ? false : true // MARK: (point of interest when testing) } @@ -396,7 +400,7 @@ class DisplayManager { static func isDummy(displayID: CGDirectDisplayID) -> Bool { let rawName = DisplayManager.getDisplayRawNameByID(displayID: displayID) var isDummy: Bool = false - if rawName == "28E850" || rawName.lowercased().contains("dummy") { + if rawName.lowercased().contains("dummy") { os_log("NOTE: Display is a dummy!", type: .info) isDummy = true } diff --git a/MonitorControlHelper/Info.plist b/MonitorControlHelper/Info.plist index 7298759a..0d25c8c9 100644 --- a/MonitorControlHelper/Info.plist +++ b/MonitorControlHelper/Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString $(MARKETING_VERSION) CFBundleVersion - 6956 + 6957 LSApplicationCategoryType public.app-category.utilities LSBackgroundOnly diff --git a/README.md b/README.md index f7d3e01c..a92b5cd4 100644 --- a/README.md +++ b/README.md @@ -99,11 +99,7 @@ _* With some limitations - full functionality available on macOS 11 Big Sur or n - LCD and LED Televisions usually do not implement DDC, these are supported using software alternatives to dim the image (some higher-end sets are able to translate this into hardware backlight dimming). - OLED or mini/micro-LED displays and televisions are fully supported using gamma table manipulation (this is a no-compromise solution for this class of displays). - DisplayLink, Airplay and Sidecar are supported using shade (dark overlay) control. - -Dummy compatibility: - - The app is compatible with [BetterDummy](https://github.com/waydabber/BetterDummy) mirrored sets. -- The app is compatible with mirrored sets that include a dummy dongle identifying as `28E850` Notable exceptions for hardware control compatibility: From a6e0402274b210c70af42179ec06745f41f7cd74 Mon Sep 17 00:00:00 2001 From: waydabber <37590873+waydabber@users.noreply.github.com> Date: Mon, 15 Nov 2021 13:56:32 +0100 Subject: [PATCH 2/5] Removed OSD lock popup alltogether --- MonitorControl.xcodeproj/project.pbxproj | 16 ++++++++-------- MonitorControl/Info.plist | 2 +- MonitorControl/Support/MediaKeyTapManager.swift | 10 ---------- MonitorControl/Support/OSDUtils.swift | 13 ------------- MonitorControlHelper/Info.plist | 2 +- 5 files changed, 10 insertions(+), 33 deletions(-) diff --git a/MonitorControl.xcodeproj/project.pbxproj b/MonitorControl.xcodeproj/project.pbxproj index 15ba7ca2..c873f71e 100644 --- a/MonitorControl.xcodeproj/project.pbxproj +++ b/MonitorControl.xcodeproj/project.pbxproj @@ -779,11 +779,11 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = MonitorControl/MonitorControlDebug.entitlements; - CODE_SIGN_IDENTITY = "-"; + CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1179; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = 299YSU96J7; ENABLE_HARDENED_RUNTIME = YES; FRAMEWORK_SEARCH_PATHS = ( "$(PROJECT_DIR)/**", @@ -814,11 +814,11 @@ buildSettings = { ARCHS = "$(ARCHS_STANDARD)"; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CODE_SIGN_IDENTITY = "-"; + CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1179; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = 299YSU96J7; ENABLE_HARDENED_RUNTIME = YES; FRAMEWORK_SEARCH_PATHS = ( "$(PROJECT_DIR)/**", @@ -852,11 +852,11 @@ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_ENTITLEMENTS = MonitorControlHelper/MonitorControlHelper.entitlements; - CODE_SIGN_IDENTITY = "-"; + CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 631; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = 299YSU96J7; ENABLE_HARDENED_RUNTIME = YES; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = MonitorControlHelper/Info.plist; @@ -881,11 +881,11 @@ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_ENTITLEMENTS = MonitorControlHelper/MonitorControlHelper.entitlements; - CODE_SIGN_IDENTITY = "-"; + CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 631; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = 299YSU96J7; ENABLE_HARDENED_RUNTIME = YES; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = MonitorControlHelper/Info.plist; diff --git a/MonitorControl/Info.plist b/MonitorControl/Info.plist index 85621d8b..4186d20b 100644 --- a/MonitorControl/Info.plist +++ b/MonitorControl/Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString $(MARKETING_VERSION) CFBundleVersion - 6957 + 6963 LSApplicationCategoryType public.app-category.utilities LSMinimumSystemVersion diff --git a/MonitorControl/Support/MediaKeyTapManager.swift b/MonitorControl/Support/MediaKeyTapManager.swift index 906156b8..adab913c 100644 --- a/MonitorControl/Support/MediaKeyTapManager.swift +++ b/MonitorControl/Support/MediaKeyTapManager.swift @@ -21,7 +21,6 @@ class MediaKeyTapManager: MediaKeyTapDelegate { return } guard app.sleepID == 0, app.reconfigureID == 0 else { - self.showOSDLock(mediaKey) return } if isPressed, self.handleOpenPrefPane(mediaKey: mediaKey, event: event, modifiers: modifiers) { @@ -68,15 +67,6 @@ class MediaKeyTapManager: MediaKeyTapDelegate { } } - private func showOSDLock(_ mediaKey: MediaKey) { - if [.brightnessUp, .brightnessDown].contains(mediaKey) { - OSDUtils.showOSDLockOnAllDisplays(osdImage: OSDUtils.OSDImage.brightness.rawValue) - } - if [.volumeUp, .volumeDown, .mute].contains(mediaKey) { - OSDUtils.showOSDLockOnAllDisplays(osdImage: OSDUtils.OSDImage.audioSpeaker.rawValue) - } - } - private func sendDisplayCommand(mediaKey: MediaKey, isRepeat: Bool, isSmallIncrement: Bool, isPressed: Bool, isContrast: Bool = false) { self.sendDisplayCommandVolumeMute(mediaKey: mediaKey, isRepeat: isRepeat, isSmallIncrement: isSmallIncrement, isPressed: isPressed) self.sendDisplayCommandBrightnessContrast(mediaKey: mediaKey, isRepeat: isRepeat, isSmallIncrement: isSmallIncrement, isPressed: isPressed, isContrast: isContrast) diff --git a/MonitorControl/Support/OSDUtils.swift b/MonitorControl/Support/OSDUtils.swift index b3b72072..a2502732 100644 --- a/MonitorControl/Support/OSDUtils.swift +++ b/MonitorControl/Support/OSDUtils.swift @@ -74,17 +74,4 @@ class OSDUtils: NSObject { static func getDistance(fromNearestChiclet chiclet: Float) -> Float { abs(chiclet.rounded(.towardZero) - chiclet) } - - static func showOSDLockOnAllDisplays(osdImage: Int64) { - var displayCount: UInt32 = 0 - var onlineDisplays = [CGDirectDisplayID](repeating: 0, count: Int(16)) - if CGGetOnlineDisplayList(16, &onlineDisplays, &displayCount) == CGError.success { - let displayIDs = onlineDisplays.prefix(Int(displayCount)) - for id in displayIDs { - if let manager = OSDManager.sharedManager() as? OSDManager { - manager.showImage(osdImage, onDisplayID: id, priority: 0x1F4, msecUntilFade: 1000, filledChiclets: 0, totalChiclets: 100, locked: true) - } - } - } - } } diff --git a/MonitorControlHelper/Info.plist b/MonitorControlHelper/Info.plist index 0d25c8c9..8895fc64 100644 --- a/MonitorControlHelper/Info.plist +++ b/MonitorControlHelper/Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString $(MARKETING_VERSION) CFBundleVersion - 6957 + 6963 LSApplicationCategoryType public.app-category.utilities LSBackgroundOnly From 23ec0240fc5cbf440d222a41800d3b525dd6394d Mon Sep 17 00:00:00 2001 From: waydabber <37590873+waydabber@users.noreply.github.com> Date: Mon, 15 Nov 2021 13:58:46 +0100 Subject: [PATCH 3/5] Fix build number conflict --- MonitorControl.xcodeproj/project.pbxproj | 16 ++++++++-------- MonitorControl/Info.plist | 2 +- MonitorControlHelper/Info.plist | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/MonitorControl.xcodeproj/project.pbxproj b/MonitorControl.xcodeproj/project.pbxproj index c873f71e..15ba7ca2 100644 --- a/MonitorControl.xcodeproj/project.pbxproj +++ b/MonitorControl.xcodeproj/project.pbxproj @@ -779,11 +779,11 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = MonitorControl/MonitorControlDebug.entitlements; - CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1179; - DEVELOPMENT_TEAM = 299YSU96J7; + DEVELOPMENT_TEAM = ""; ENABLE_HARDENED_RUNTIME = YES; FRAMEWORK_SEARCH_PATHS = ( "$(PROJECT_DIR)/**", @@ -814,11 +814,11 @@ buildSettings = { ARCHS = "$(ARCHS_STANDARD)"; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1179; - DEVELOPMENT_TEAM = 299YSU96J7; + DEVELOPMENT_TEAM = ""; ENABLE_HARDENED_RUNTIME = YES; FRAMEWORK_SEARCH_PATHS = ( "$(PROJECT_DIR)/**", @@ -852,11 +852,11 @@ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_ENTITLEMENTS = MonitorControlHelper/MonitorControlHelper.entitlements; - CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 631; - DEVELOPMENT_TEAM = 299YSU96J7; + DEVELOPMENT_TEAM = ""; ENABLE_HARDENED_RUNTIME = YES; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = MonitorControlHelper/Info.plist; @@ -881,11 +881,11 @@ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_ENTITLEMENTS = MonitorControlHelper/MonitorControlHelper.entitlements; - CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 631; - DEVELOPMENT_TEAM = 299YSU96J7; + DEVELOPMENT_TEAM = ""; ENABLE_HARDENED_RUNTIME = YES; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = MonitorControlHelper/Info.plist; diff --git a/MonitorControl/Info.plist b/MonitorControl/Info.plist index 4186d20b..85621d8b 100644 --- a/MonitorControl/Info.plist +++ b/MonitorControl/Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString $(MARKETING_VERSION) CFBundleVersion - 6963 + 6957 LSApplicationCategoryType public.app-category.utilities LSMinimumSystemVersion diff --git a/MonitorControlHelper/Info.plist b/MonitorControlHelper/Info.plist index 8895fc64..0d25c8c9 100644 --- a/MonitorControlHelper/Info.plist +++ b/MonitorControlHelper/Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString $(MARKETING_VERSION) CFBundleVersion - 6963 + 6957 LSApplicationCategoryType public.app-category.utilities LSBackgroundOnly From 635b9983e10d718fabf7215d4f1bb82eab0e96c6 Mon Sep 17 00:00:00 2001 From: waydabber <37590873+waydabber@users.noreply.github.com> Date: Tue, 16 Nov 2021 19:00:27 +0100 Subject: [PATCH 4/5] Virtual displays (Sidecar, DisplayLink etc) now use serial number instead of CGDirectDisplayID for preferences storage appendix. --- MonitorControl/Info.plist | 2 +- MonitorControl/Model/AppleDisplay.swift | 4 ++-- MonitorControl/Model/Display.swift | 24 +++++++++++---------- MonitorControl/Model/OtherDisplay.swift | 4 ++-- MonitorControl/Support/DisplayManager.swift | 5 +++-- MonitorControlHelper/Info.plist | 2 +- 6 files changed, 22 insertions(+), 19 deletions(-) diff --git a/MonitorControl/Info.plist b/MonitorControl/Info.plist index 85621d8b..4726b481 100644 --- a/MonitorControl/Info.plist +++ b/MonitorControl/Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString $(MARKETING_VERSION) CFBundleVersion - 6957 + 6959 LSApplicationCategoryType public.app-category.utilities LSMinimumSystemVersion diff --git a/MonitorControl/Model/AppleDisplay.swift b/MonitorControl/Model/AppleDisplay.swift index 68dd948e..85bc92fb 100644 --- a/MonitorControl/Model/AppleDisplay.swift +++ b/MonitorControl/Model/AppleDisplay.swift @@ -6,9 +6,9 @@ import os.log class AppleDisplay: Display { private var displayQueue: DispatchQueue - override init(_ identifier: CGDirectDisplayID, name: String, vendorNumber: UInt32?, modelNumber: UInt32?, isVirtual: Bool = false, isDummy: Bool = false) { + override init(_ identifier: CGDirectDisplayID, name: String, vendorNumber: UInt32?, modelNumber: UInt32?, serialNumber: UInt32?, isVirtual: Bool = false, isDummy: Bool = false) { self.displayQueue = DispatchQueue(label: String("displayQueue-\(identifier)")) - super.init(identifier, name: name, vendorNumber: vendorNumber, modelNumber: modelNumber, isVirtual: isVirtual, isDummy: isDummy) + super.init(identifier, name: name, vendorNumber: vendorNumber, modelNumber: modelNumber, serialNumber: serialNumber, isVirtual: isVirtual, isDummy: isDummy) } public func getAppleBrightness() -> Float { diff --git a/MonitorControl/Model/Display.swift b/MonitorControl/Model/Display.swift index 7cdae8c6..9a5b5e71 100644 --- a/MonitorControl/Model/Display.swift +++ b/MonitorControl/Model/Display.swift @@ -5,14 +5,15 @@ import Foundation import os.log class Display: Equatable { - internal let identifier: CGDirectDisplayID - internal let prefsId: String - internal var name: String - internal var vendorNumber: UInt32? - internal var modelNumber: UInt32? - internal var smoothBrightnessTransient: Float = 1 - internal var smoothBrightnessRunning: Bool = false - internal var smoothBrightnessSlow: Bool = false + let identifier: CGDirectDisplayID + let prefsId: String + var name: String + var vendorNumber: UInt32? + var modelNumber: UInt32? + var serialNumber: UInt32? + var smoothBrightnessTransient: Float = 1 + var smoothBrightnessRunning: Bool = false + var smoothBrightnessSlow: Bool = false let swBrightnessSemaphore = DispatchSemaphore(value: 1) static func == (lhs: Display, rhs: Display) -> Bool { @@ -62,15 +63,16 @@ class Display: Equatable { (key ?? PrefKey.value).rawValue + (command != nil ? String((command ?? Command.none).rawValue) : "") + self.prefsId } - internal init(_ identifier: CGDirectDisplayID, name: String, vendorNumber: UInt32?, modelNumber: UInt32?, isVirtual: Bool = false, isDummy: Bool = false) { + init(_ identifier: CGDirectDisplayID, name: String, vendorNumber: UInt32?, modelNumber: UInt32?, serialNumber: UInt32?, isVirtual: Bool = false, isDummy: Bool = false) { self.identifier = identifier self.name = name self.vendorNumber = vendorNumber self.modelNumber = modelNumber - self.prefsId = "(" + String(name.filter { !$0.isWhitespace }) + String(vendorNumber ?? 0) + String(modelNumber ?? 0) + "@" + String(identifier) + ")" - os_log("Display init with prefsIdentifier %{public}@", type: .info, self.prefsId) + self.serialNumber = serialNumber self.isVirtual = DEBUG_VIRTUAL ? true : isVirtual self.isDummy = isDummy + self.prefsId = "(" + String(name.filter { !$0.isWhitespace }) + String(vendorNumber ?? 0) + String(modelNumber ?? 0) + "@" + (self.isVirtual ? String(self.serialNumber ?? 9999) : String(identifier)) + ")" + os_log("Display init with prefsIdentifier %{public}@", type: .info, self.prefsId) self.swUpdateDefaultGammaTable() self.smoothBrightnessTransient = self.getBrightness() if self.isVirtual || self.readPrefAsBool(key: PrefKey.avoidGamma), !self.isDummy { diff --git a/MonitorControl/Model/OtherDisplay.swift b/MonitorControl/Model/OtherDisplay.swift index e91a918e..dee05ddb 100644 --- a/MonitorControl/Model/OtherDisplay.swift +++ b/MonitorControl/Model/OtherDisplay.swift @@ -26,8 +26,8 @@ class OtherDisplay: Display { set { prefs.set(newValue, forKey: PrefKey.pollingCount.rawValue + self.prefsId) } } - override init(_ identifier: CGDirectDisplayID, name: String, vendorNumber: UInt32?, modelNumber: UInt32?, isVirtual: Bool = false, isDummy: Bool = false) { - super.init(identifier, name: name, vendorNumber: vendorNumber, modelNumber: modelNumber, isVirtual: isVirtual, isDummy: isDummy) + override init(_ identifier: CGDirectDisplayID, name: String, vendorNumber: UInt32?, modelNumber: UInt32?, serialNumber: UInt32?, isVirtual: Bool = false, isDummy: Bool = false) { + super.init(identifier, name: name, vendorNumber: vendorNumber, modelNumber: modelNumber, serialNumber: serialNumber, isVirtual: isVirtual, isDummy: isDummy) if !isVirtual, !Arm64DDC.isArm64 { self.ddc = IntelDDC(for: identifier) } diff --git a/MonitorControl/Support/DisplayManager.swift b/MonitorControl/Support/DisplayManager.swift index f6e07a3f..36064c51 100644 --- a/MonitorControl/Support/DisplayManager.swift +++ b/MonitorControl/Support/DisplayManager.swift @@ -172,14 +172,15 @@ class DisplayManager { let id = onlineDisplayID let vendorNumber = CGDisplayVendorNumber(onlineDisplayID) let modelNumber = CGDisplayModelNumber(onlineDisplayID) + let serialNumber = CGDisplaySerialNumber(onlineDisplayID) let isDummy: Bool = DisplayManager.isDummy(displayID: onlineDisplayID) let isVirtual: Bool = DisplayManager.isVirtual(displayID: onlineDisplayID) if !DEBUG_SW, DisplayManager.isAppleDisplay(displayID: onlineDisplayID) { // MARK: (point of interest for testing) - let appleDisplay = AppleDisplay(id, name: name, vendorNumber: vendorNumber, modelNumber: modelNumber, isVirtual: isVirtual, isDummy: isDummy) + let appleDisplay = AppleDisplay(id, name: name, vendorNumber: vendorNumber, modelNumber: modelNumber, serialNumber: serialNumber, isVirtual: isVirtual, isDummy: isDummy) os_log("Apple display found - %{public}@", type: .info, "ID: \(appleDisplay.identifier), Name: \(appleDisplay.name) (Vendor: \(appleDisplay.vendorNumber ?? 0), Model: \(appleDisplay.modelNumber ?? 0))") self.addDisplay(display: appleDisplay) } else { - let otherDisplay = OtherDisplay(id, name: name, vendorNumber: vendorNumber, modelNumber: modelNumber, isVirtual: isVirtual, isDummy: isDummy) + let otherDisplay = OtherDisplay(id, name: name, vendorNumber: vendorNumber, modelNumber: modelNumber, serialNumber: serialNumber, isVirtual: isVirtual, isDummy: isDummy) os_log("Other display found - %{public}@", type: .info, "ID: \(otherDisplay.identifier), Name: \(otherDisplay.name) (Vendor: \(otherDisplay.vendorNumber ?? 0), Model: \(otherDisplay.modelNumber ?? 0))") self.addDisplay(display: otherDisplay) } diff --git a/MonitorControlHelper/Info.plist b/MonitorControlHelper/Info.plist index 0d25c8c9..f2272881 100644 --- a/MonitorControlHelper/Info.plist +++ b/MonitorControlHelper/Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString $(MARKETING_VERSION) CFBundleVersion - 6957 + 6959 LSApplicationCategoryType public.app-category.utilities LSBackgroundOnly From c81c47794fb3e032493b60824f2b9cd56af73941 Mon Sep 17 00:00:00 2001 From: waydabber <37590873+waydabber@users.noreply.github.com> Date: Tue, 16 Nov 2021 22:15:36 +0100 Subject: [PATCH 5/5] Made display pref id creation look nice. --- MonitorControl/Info.plist | 2 +- MonitorControl/Model/Display.swift | 2 +- MonitorControlHelper/Info.plist | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MonitorControl/Info.plist b/MonitorControl/Info.plist index 4726b481..90310173 100644 --- a/MonitorControl/Info.plist +++ b/MonitorControl/Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString $(MARKETING_VERSION) CFBundleVersion - 6959 + 6965 LSApplicationCategoryType public.app-category.utilities LSMinimumSystemVersion diff --git a/MonitorControl/Model/Display.swift b/MonitorControl/Model/Display.swift index 9a5b5e71..b661249b 100644 --- a/MonitorControl/Model/Display.swift +++ b/MonitorControl/Model/Display.swift @@ -71,7 +71,7 @@ class Display: Equatable { self.serialNumber = serialNumber self.isVirtual = DEBUG_VIRTUAL ? true : isVirtual self.isDummy = isDummy - self.prefsId = "(" + String(name.filter { !$0.isWhitespace }) + String(vendorNumber ?? 0) + String(modelNumber ?? 0) + "@" + (self.isVirtual ? String(self.serialNumber ?? 9999) : String(identifier)) + ")" + self.prefsId = "(\(name.filter { !$0.isWhitespace })\(vendorNumber ?? 0)\(modelNumber ?? 0)@\(self.isVirtual ? (self.serialNumber ?? 9999) : identifier))" os_log("Display init with prefsIdentifier %{public}@", type: .info, self.prefsId) self.swUpdateDefaultGammaTable() self.smoothBrightnessTransient = self.getBrightness() diff --git a/MonitorControlHelper/Info.plist b/MonitorControlHelper/Info.plist index f2272881..f9d7f9ce 100644 --- a/MonitorControlHelper/Info.plist +++ b/MonitorControlHelper/Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString $(MARKETING_VERSION) CFBundleVersion - 6959 + 6965 LSApplicationCategoryType public.app-category.utilities LSBackgroundOnly