Better handling of mirrors - non primary mirror members (displays which are destination screens of a mirrored screen) are now detected and can be controlled. Not tested on Intel but should work.

This commit is contained in:
waydabber 2021-07-31 16:43:26 +02:00
parent 048ac9610d
commit db015509d6
12 changed files with 85 additions and 12 deletions

View file

@ -89,18 +89,37 @@ class AppDelegate: NSObject, NSApplicationDelegate {
func updateDisplays() {
self.clearDisplays()
for screen in NSScreen.screens {
let name: String
if #available(OSX 10.15, *) {
name = screen.localizedName
} else {
name = screen.displayName ?? NSLocalizedString("Unknown", comment: "Unknown display name")
var onlineDisplayIDs = [CGDirectDisplayID](repeating: 0, count: 10)
var displayCount: UInt32 = 0
guard CGGetOnlineDisplayList(10, &onlineDisplayIDs, &displayCount) == .success else {
os_log("Unable to get display list.", type: .info)
return
}
for onlineDisplayID in onlineDisplayIDs where onlineDisplayID != 0 {
var name: String = NSLocalizedString("Unknown", comment: "Unknown display name") + String(CGDisplaySerialNumber(onlineDisplayID))
if let screen = NSScreen.getByDisplayID(displayID: onlineDisplayID) {
if #available(OSX 10.15, *) {
name = screen.localizedName
} else {
name = screen.displayName ?? name
}
} else if CGDisplayIsInHWMirrorSet(onlineDisplayID) != 0 || CGDisplayIsInMirrorSet(onlineDisplayID) != 0 {
if let mirroredScreen = NSScreen.getByDisplayID(displayID: CGDisplayMirrorsDisplay(onlineDisplayID)) {
name = NSLocalizedString("Mirror of", comment: "Shown in case a display mirrors an other display - like 'Mirror of DisplayName")
if #available(OSX 10.15, *) {
name = "" + name + " " + String(mirroredScreen.localizedName)
} else {
name = "" + name + " " + String(mirroredScreen.displayName ?? NSLocalizedString("Unknown", comment: "Unknown display name"))
}
}
}
let id = screen.displayID
let vendorNumber = screen.vendorNumber
let modelNumber = screen.modelNumber
let id = onlineDisplayID
let vendorNumber = CGDisplayVendorNumber(onlineDisplayID)
let modelNumber = CGDisplayVendorNumber(onlineDisplayID)
let display: Display
if screen.isBuiltin {
if CGDisplayIsBuiltin(onlineDisplayID) != 0 {
display = InternalDisplay(id, name: name, vendorNumber: vendorNumber, modelNumber: modelNumber)
} else {
display = ExternalDisplay(id, name: name, vendorNumber: vendorNumber, modelNumber: modelNumber)

View file

@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>1065</string>
<string>1097</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>

View file

@ -31,6 +31,12 @@
/* Shown in the main prefs window */
"Keys" = "Tasten";
/* Shown in case a display mirrors an other display - like 'Mirror of DisplayName */
"Mirror of" = "Mirror of";
/* Mirrors */
"Mirrors" = "Mirrors";
/* Shown in the alert dialog */
"No" = "No";

View file

@ -31,6 +31,12 @@
/* Shown in the main prefs window */
"Keys" = "Keys";
/* Shown in case a display mirrors an other display - like 'Mirror of DisplayName */
"Mirror of" = "Mirror of";
/* Mirrors */
"Mirrors" = "Mirrors";
/* Shown in the alert dialog */
"No" = "No";

View file

@ -31,6 +31,12 @@
/* Shown in the main prefs window */
"Keys" = "Touches";
/* Shown in case a display mirrors an other display - like 'Mirror of DisplayName */
"Mirror of" = "Mirror of";
/* Mirrors */
"Mirrors" = "Mirrors";
/* Shown in the alert dialog */
"No" = "No";

View file

@ -31,6 +31,12 @@
/* Shown in the main prefs window */
"Keys" = "Tasti";
/* Shown in case a display mirrors an other display - like 'Mirror of DisplayName */
"Mirror of" = "Mirror of";
/* Mirrors */
"Mirrors" = "Mirrors";
/* Shown in the alert dialog */
"No" = "No";

View file

@ -31,6 +31,12 @@
/* Shown in the main prefs window */
"Keys" = "キー";
/* Shown in case a display mirrors an other display - like 'Mirror of DisplayName */
"Mirror of" = "Mirror of";
/* Mirrors */
"Mirrors" = "Mirrors";
/* Shown in the alert dialog */
"No" = "No";

View file

@ -31,6 +31,12 @@
/* Shown in the main prefs window */
"Keys" = "Klawisze";
/* Shown in case a display mirrors an other display - like 'Mirror of DisplayName */
"Mirror of" = "Mirror of";
/* Mirrors */
"Mirrors" = "Mirrors";
/* Shown in the alert dialog */
"No" = "Nie";

View file

@ -31,6 +31,12 @@
/* Shown in the main prefs window */
"Keys" = "Сочетания клавиш";
/* Shown in case a display mirrors an other display - like 'Mirror of DisplayName */
"Mirror of" = "Mirror of";
/* Mirrors */
"Mirrors" = "Mirrors";
/* Shown in the alert dialog */
"No" = "No";

View file

@ -31,6 +31,12 @@
/* Shown in the main prefs window */
"Keys" = "Клавіші";
/* Shown in case a display mirrors an other display - like 'Mirror of DisplayName */
"Mirror of" = "Mirror of";
/* Mirrors */
"Mirrors" = "Mirrors";
/* Shown in the alert dialog */
"No" = "No";

View file

@ -31,6 +31,12 @@
/* Shown in the main prefs window */
"Keys" = "快捷键";
/* Shown in case a display mirrors an other display - like 'Mirror of DisplayName */
"Mirror of" = "Mirror of";
/* Mirrors */
"Mirrors" = "Mirrors";
/* Shown in the alert dialog */
"No" = "No";

View file

@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>1065</string>
<string>1097</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSBackgroundOnly</key>