Conversation
…tead of CGDirectDisplayID for preferences storage appendix.
|
An other day, an other fix. Approve this one please. :) This is an addition to the bugfix release 4.0.2. Thanks! |
MonitorControl/Model/Display.swift
Outdated
| 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)) + ")" |
There was a problem hiding this comment.
Why not use string concatenation here instead? I think that might simplify this line quite a bit.
I haven't really tested it myself, because I don't really know how the virtual display feature is supposed to work, but will this handle me changing the name of the display without issues? Or is this name property a different one from the one the user can configure?
I think something like:
self.prefsId = "(\(name.filter { !$0.isWhitespace })\(vendorNumber ?? 0)\(modelNumber ?? 0)@\(self.isVirtual ? (self.serialNumber ?? 9999) : identifier))"might do the trick, is imo a bit more concise.
There was a problem hiding this comment.
That looks nicer.
Yes, this name is a permanent one and different from friendlyName which was differentiated a while back.
There was a problem hiding this comment.
Fixed that line to look nice. Approve please! Thanks! :)
There was an issue regarding virtual displays (DisplayLink, Sidecar etc) - the app uses CGDirectDisplayID as a preference ID suffix alongside the display name and vendor/model number. Since on every connect this id is changing for these displays, MonitorControl could not track preferences associated to these displays (+ the preferences store was polluted with dead items as well). This is now fixed, we now use the system generated, permanent serial number as suffix for virtual displays. For real displays we continue to use CGDirectDisplayID as the serial number is often the same for identical displays which causes issues in multi-display configs with similar physical displays.